/* In this lab, you will render 4 built-in objects from GLUT. 1. Open a browser and load: http://www.opengl.org/resources/libraries/glut/spec3/node80.html#SECTION000120000000000000000 to find the documentation on GLUT built-ins. 2. You should do viewport transformations to fit all 4 objects into one window. Your window is 800 pixels wide, by 200 pixels tall, so each viewport will be 200 by 200 pixels. You'll need to choose the lower left corner. 3. You should also use glRotatef or glScalef to make sure the objects fit in the viewport and so they have a pleasing angle (don't forget the push'es and pop's) */ #include #include void myInit() { glEnable(GL_DEPTH_TEST); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-1.5,1.5,-1.5,1.5,-10,20.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0,0,5 , 0,0,0 , 0,1,0); } void display() { glClearColor(1.0 , 1.0 , 1.0 , 0.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColor3f(0.0 , 0.0 , 0.0); // teapot glViewport( 0 , 0 ,200,200); glutWireTeapot( 1.0 ); // torus glViewport( 200 , 0 ,200,200); glPushMatrix(); glRotatef(45,1,0,0); glutWireTorus(0.5,1.0,10,10); glPopMatrix(); // cone glViewport( 400 , 0 ,200,200); glPushMatrix(); glRotatef(-45,1,0,0); glRotatef(-45,0,1,0); glutWireCone(0.5,0.75,10,10); glPopMatrix(); // dodecahedron glViewport( 600 , 0 ,200,200); glPushMatrix(); glRotatef(-45,1,0,0); glRotatef(-45,0,1,0); glScalef(0.5,0.5,0.5); glutWireDodecahedron(); glPopMatrix(); glFlush(); } void keyboard(unsigned char key, GLint x, GLint y) { switch (key) { case 'q': exit( 0 ); break; } return; } int main (int argc , char **argv) { glutInit(&argc,argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(800,200); glutInitWindowPosition(0,0); glutCreateWindow("Glut Objects"); myInit(); glutDisplayFunc(display); glutKeyboardFunc(keyboard); glutMainLoop(); return 0; }