Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: when to call glutSetWindow()??

  1. #1
    Intern Contributor
    Join Date
    Mar 2008
    Posts
    91

    when to call glutSetWindow()??

    Below is an example. If I call glutSetWindow(TopViewID); before setting the properties of TopViewID, the cube only gets displayed in the subwindow. If I call glutSetWindow(MainID) after setting the properties of TopViewID, the cube only gets displayed in the main window.

    If I call DrawCube() instead of glCallList(OBJECT); in both display() functions then the cube is displayed in both the main window and the sub window no matter when I call glutSetWindow().

    Why is this?? Are display lists in some way linked to a window?

    Thanks,

    Dave

    Code :
     
    int main()
    {
    MainID = glutCreateWindow("LidarSimulation");
    	glMatrixMode(GL_MODELVIEW);
    	glLoadIdentity();
    	gluPerspective(50, 1, 1, 100);
    	gluLookAt(0, 0, 10, 0, 0, 0, 0, 1, 0);	
     
    	TopViewID = glutCreateSubWindow(MainID, 0, 0, 300, 200);
     
            //glutSetWindow(TopViewID); /*IMPORTANT LINE*/
     
    	glutDisplayFunc(DisplayTopView);
    	gluPerspective(50, 3./2., 1, 100);
    	gluLookAt(0, 0, 10, 0, 0, 0, 0, 1, 0);
     
            //glutSetWindow(MainID);/*IMPORTANT LINE*/
     
            OBJECT = glGenLists(1);
    	glNewList(OBJECT, GL_COMPILE);
    		DrawCube();
    	glEndList();
    }
     
    void DisplayTopView(void)
    {
    	glutSetWindow(TopViewID);
    	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    	glCallList(OBJECT);
    	//DrawCube();
    }
     
    void display(void)
    {
    	glutSetWindow(MainID);
            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    	glCallList(OBJECT);
    	//DrawCube();
    }

  2. #2
    Intern Contributor
    Join Date
    Mar 2008
    Posts
    91

    Re: when to call glutSetWindow()??

    ok, turns out I was way off base...

    Each window/subwindow has its own set of display lists!! so the problem was that I was not creating the list for each window, so when I was calling glCallList(OBJECT) in the subdisplay(), list 1 (the value of OBJECT) was not defined in the subwindow context!

    So now my question is -

    I am trying to have a "top view" subwindow, which displays exactly the same thing that is in the main window, just looking down at it. Do I really have to create every list twice, one normally and once after calling glutSetWindow(TopViewID) ?

    Is there not a better way to do this?

    Thanks,

    Dave

  3. #3
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,575

    Re: when to call glutSetWindow()??

    there is wglShareLists, but no idea how to integrate it with glut.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •