

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Due: Wednesday September 28th at 11:59pm
Goal: Setup a 3D OpenGL program with a perspective viewing window, and some simple geometry. Get a feel for how OpenGL manipulates objects in 3D.
Problem 1 (20 points): Write a OpenGL/GLUT program which renders 3D geometry into a 640 × 480 window. Use the whole window as the viewport (i.e., a 640 × 480 viewing area).
Hint: The answer may not be your first thought. This is a bit tricky. You can check your answer by comparing your answer with the matrix gluLookAt() creates. You can get this matrix by reading back the modelview matrix using the following code: GLfloat gluLookAtMatrix[16]; glMatrixMode(GL MODELVIEW); glLoadIdentity(); gluLookAt( < ...fill in correct values... > ); glGetFloatv( GL MODELVIEW MATRIX, gluLookAtMatrix ); printf(‘‘%f %f %f %f\n’’, gluLookAtMatrix[0], gluLookAtMatrix[4], < ...etc... >); printf(‘‘%f %f %f %f\n’’, gluLookAtMatrix[1], gluLookAtMatrix[5], < ...etc... >); < ...etc... >
Note: You will get strange or unexpected behavior as this cone rotates around the y -axis. This is fine. Fixing this problem is the extra credit.
Hint: Use glutSolidTeapot() , which you can read about on page 688.
Extra Credit (2 points): Why do the cones drawn in Parts G and H look strange? Put the answer in your README. Fix the problem in your prorgram, and add a keyboard callback (using the ’x’ key) to swtich back and forth between the fixed and unfixed versions. To get credit, the discontinuity apparent in the cones must go away.