glut多窗口(子窗口)程序的实现:类似MFC的拆分窗口,http://hi.baidu.com/gongziya/item/fc232eac321212a628ce9d30
和:http://www.lighthouse3d.com/tutorials/glut-tutorial/subwindows/
多个窗口(不是子窗口):http://www.cs.uml.edu/~hmasterm/Charts/Managing_Multiple_Windows.pdf
和:http://www.cs.uml.edu/~hmasterm/Charts/Managing_Multiple_Windows.pdf
#include <Windows.h> #include <GL/GL.h> #include <GL/freeglut.h>
void window1_reshape(int width, int height)
{
}
void window1_display()
{
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(1.0,1.0,0.0,1.);
glBegin(GL_TRIANGLES);
glVertex3f(-0.5,-0.5,0.0);
glVertex3f(0.5,0.0,0.0);
glVertex3f(0.0,0.5,0.0);
glEnd();
glutSwapBuffers();
}
void window2_reshape(int width, int height)
{
}
void window2_display()
{
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(1.0,0.0,0.0,1.);
glBegin(GL_TRIANGLES);
glVertex3f(-0.5,-0.5,0.0);
glVertex3f(0.5,0.0,0.0);
glVertex3f(0.0,0.5,0.0);
glEnd();
glFlush();
glutSwapBuffers();
}
void main(int argc, char **argv)
{
int window1 = 0 , window2= 0;
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB |GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(500, 500);
// create the first window
window1 = glutCreateWindow("First Window - Perspective View");
// register callbacks for first window, which is now current
glutReshapeFunc(window1_reshape);
glutDisplayFunc(window1_display);
//glutMouseFunc(window1_mouse);
//create the second window
window2 = glutCreateWindow("Second Window - Top/Down View");
//define a window position for second window
glutPositionWindow(520,20);
// register callbacks for second window, which is now current
glutReshapeFunc(window2_reshape);
glutDisplayFunc(window2_display);
//glutMouseFunc(window1_mouse); //note we share the mouse function
//glutIdleFunc(spinCube); //idle function is not associated with a window
glutMainLoop();
}
来源:https://www.cnblogs.com/USTC-fuxm/archive/2012/08/21/2649902.html
