Stupid.Fat.Cat
Stupid.Fat.Cat

Reputation: 11295

OpenGL Issues with GLUT_DOUBLE and two windows

I'm using Sumanta Guha's code sample and I'm trying to create two windows. Using the following code:

int main(int argc, char **argv) 
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);

// First top-level window definition.
glutInitWindowSize(250, 500); 
glutInitWindowPosition(100, 100);

// Create the first window and return id.
id1 = glutCreateWindow("windows.cpp - window 1"); 

// Initialization, display, and other routines of the first window. 
setup1();
glutDisplayFunc(drawScene1); 
glutReshapeFunc(resize1);
glutKeyboardFunc(keyInput); // Routine is shared by both windows.

// Second top-level window definition.
glutInitWindowSize(250, 500); 
glutInitWindowPosition(400, 100);

// Create the second window and return id.
id2 = glutCreateWindow("windows.cpp - window 2"); 

// Initialization, display, and other routines of the second window. 
setup2(); 
glutDisplayFunc(drawScene2); 
glutReshapeFunc(resize2);
glutKeyboardFunc(keyInput); // Routine is shared by both windows.

glutMainLoop();

return 0;   
}

I'm using Windows 7, and normally it should display two windows. But as you can see, only one Window displays properly and the other one doesn't seem to work quite as well. Are there additional steps that I have to take other than GLUT_DOUBLE and buffer swap?

enter image description here

Upvotes: 1

Views: 431

Answers (1)

BЈовић
BЈовић

Reputation: 64223

Are there additional steps that I have to take other than GLUT_DOUBLE and buffer swap?

Since you are creating multiple windows, you have to call glutSetWindow() in your callbacks.

freeglut has an extension (which doesn't work) to create a shared opengl context, but the original glut doesn't support it.

Upvotes: 1

Related Questions