我正在使用Sumanta Guha的代码示例,并试图创建两个窗口。使用以下代码:

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

我正在使用Windows 7,通常它应该显示两个窗口。但是正如您所看到的,只有一个窗口可以正确显示,而另一个窗口似乎不能正常工作。除了GLUT_DOUBLE和缓冲区交换之外,我还需要采取其他步骤吗?

最佳答案



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

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

关于c++ - GLUT_DOUBLE和两个窗口的OpenGL问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19010941/

10-11 21:28