FreeGlut 和 OpenGL多窗口显示

假装没事ソ 提交于 2020-03-02 02:55:25

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

QQ截图20120821221242

#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();
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!