#include int height=0; int width=0; void mydisplay(){ glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0,0.0,0.0); // top left: top view glViewport(0, height/2, width/2, height/2); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-3.0, 3.0, -3.0, 3.0, 1.0, 50.0); gluLookAt(0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); //glCallList(object); glutSolidTeapot(0.9); // top right: right view glViewport(width/2, height/2, width/2, height/2); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-3.0, 3.0, -3.0, 3.0, 1.0, 50.0); gluLookAt(5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); //glCallList(object); glutSolidTeapot(0.6); // bottom left: front view glViewport(0, 0, width/2, height/2); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-3.0, 3.0, -3.0, 3.0, 1.0, 50.0); gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); //glCallList(object); glutSolidTeapot(0.6); // bottom right: rotating perspective view glViewport(width/2, 0, width/2, height/2); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(70.0, 1.0, 1, 50); gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); //glRotatef(30.0, 1.0, 0.0, 0.0); glPushMatrix(); glRotatef(40, 0.0, 1.0, 0.0); //glCallList(object); glutSolidTeapot(1.0); glPopMatrix(); glColor3f(0.0,1.0,0.0); glutWireCube(0.5); glFlush(); } void mykey(unsigned char key, int x, int y) { if(key=='r') { int mod=glutGetModifiers(); if(mod==GLUT_ACTIVE_ALT) exit(0); } } void mykey1(int key, int x, int y) { if(key==GLUT_KEY_F1) { int mod=glutGetModifiers(); if(mod==GLUT_ACTIVE_ALT) exit(0); } } void myreshap(int w, int h) { height=h; width=w; } void main(){ glutInitWindowSize(600,600); glutCreateWindow("simple"); glutDisplayFunc(mydisplay); glutKeyboardFunc(mykey); glutSpecialFunc(mykey1); glutReshapeFunc(myreshap); glutMainLoop();}