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