Results 1 to 5 of 5

Thread: Creating window, initializing opengl

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2011

    Creating window, initializing opengl


    im using VS 2010 C++ Express
    I created empty project and put there window. I need that on the button press it will create the openGL window. I found the code for creating the window but it access wrong memory address. The code for create and initialize window is as usual:
    Code :
     	glutInit(&argc, argv);
    	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
    	glutInitWindowSize(400, 400);

    pleas help, im new to opengl.

  2. #2
    Senior Member Regular Contributor Rosario Leonardi's Avatar
    Join Date
    Aug 2008

    Re: Creating window, initializing opengl

    I don't like to be rude.. but the web is full of tutorial that explain how to create a window with an openGl context.

    Then when you ask for help can you please explain your problem properly? Witch line give you the segmentation fault? Can we see the call stack? Witch version of glut are you using? Windows? 64bit?
    Are you using Unicode but your library don't support them?
    Those four line of code are correct, so the problem must be elsewhere.
    ~ ~ I tell you, realtime 3D is made of blood, sweat and screams! ~ ~

  3. #3
    Newbie OpenGL Pro
    Join Date
    Jan 2007

    Re: Creating window, initializing opengl

    Rule #1 - always, always, always, when you're trying something new for the first time, run your program in the debugger. In MSVC go to Configuration Manager, set your Active Configuration to "Debug", press Ctrl-Shift-B to build, then F5 to debug. If your program crashes it will halt on the line it crashed on and you can do lots of cool stuff like examine the values of variables, the contents of memory locations, the call stack, and other useful things.

    In your case my suspicion is - like Rosario said - that your project is set up to use Unicode and that's conflicting with GLUT. Another possibility is conflicts between the Visual C++ runtime you've selected and GLUT. You should know how to modify these in your project properties - learning how to get the best use out of your IDE is a vital part of programming.

    Rule #2 - you say that you're new to OpenGL, so don't try anything fancy. Your first program should be as basic as possible. Creating a new Window on a button press and setting up OpenGL in that window is something fancy; don't do this. Instead create a simple one window program that just glClears the screen, then put a triangle on it, then colour the triangle, texture it and light it if you want, and make it spin. Your first objective is to understand how OpenGL interacts with the windowing system and successfully get something on-screen, nothing more. Anything else is only going to distract you from what you need to know when starting out.

  4. #4
    Senior Member Regular Contributor
    Join Date
    Mar 2003
    Los Angeles

    Re: Creating window, initializing opengl

    In all my years of doing OpenGL, I've never tried to do what you want to do. The closest I've come is to run a program that does some calculations, then opens a GL window. Question: are you able to open a GL window without pushing a button, i.e. by doing something basic like one of the first few NeHe Tutorials? That would be a good start, because it would tell us that you have the basic graphics correct. Then, we could concentrate on the button thing. How are you going to create a button without having a graphics window open? A button is a graphic and must be displayed in a graphics window. So maybe you are asking, if I have one window open with a button in it (another challenge), how do I open a second window when I push the button?
    Am I doing your homework for you?

  5. #5
    Junior Member Newbie
    Join Date
    Jan 2011

    Re: Creating window, initializing opengl

    Thank lads,

    i managed it. The problem was that i was trying initialized by glutInit() with empty arguments. Stupid i know.

Similar Threads

  1. OpenGL Creating Window
    By killermud in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 07-15-2013, 08:42 AM
  2. using opengl without creating window
    By shivmitra in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 07-02-2011, 05:40 AM
  3. initializing openGL window
    By mfarhan1 in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 11-14-2003, 11:34 PM
  4. Replies: 6
    Last Post: 05-05-2001, 10:04 PM
  5. Creating menus in an opengl window???
    By StudentFYP in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 03-05-2001, 04:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean