1

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

4

1 回答 1

1

除了 GLUT_DOUBLE 和缓冲区交换之外,我还必须采取其他步骤吗?

由于您正在创建多个窗口,因此您必须在回调中调用glutSetWindow()

freeglut 有一个扩展(不起作用)来创建共享的 opengl 上下文,但原始的 glut 不支持它。

于 2013-09-25T17:26:56.080 回答