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



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();
}

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

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