/* In this lab, we will consider the viewing transformation, the modeling transformation, and the projection transformation. Answer the questions below, the answers will be discussed in lecture. 1. Compile and run this code. 2. Does the image look 3-dimensional? Why? NO, using Orthogonal projection, and looking right down the z-axis at the cube, plus there is a glLoadIdentity() 3. Minimize the output window, and then maximize it. Does the image change? Do you expect it to? No, it doesn't change. There is no reshape function, so the its just the default. 4. Comment out the glLoadIdentity(); in display() and recompile. 5. Now, minimize and maximize the window a few times. If the camera is moving back after each min and max, why doesn't the image "move away" from us? Cause its Orthographic projection, no sense of distance. 6. Comment out the glOrtho() in reshape() and uncomment the glFrustum() . The glLoadIdentity(); in display() should still be commented. Recompile. 7. Minimize the output window, and then maximize it. Does the image change? Do you expect it to? The image disappears, since it moves out of the clipping volume. The GluLookAt is like a translation. 8. Uncomment the glLoadIdentity(); in display() and recompile. 9. Minimize the output window, and then maximize it, and confirm that the output doesn't change. 10. Replace the call to gluLookAt() in display() with glTranslatef( , , ); Fill in the parameters so that it functions the same as the gluLookAt call. What parameters did you use, and why did they work? 11. Uncomment the glScale(); in display() and recompile. What changes? */ #include #include void myInit () { glClearColor(1.0 , 1.0 , 1.0 , 1.0); } void display () { glClear(GL_COLOR_BUFFER_BIT); glColor3f(0.0 , 0.0 , 0.0); glLoadIdentity(); // Viewing (NOT Viewport) transformation //gluLookAt(0.0 , 0.0 , 5.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0); glTranslatef( 0 , 0 , -5 ); // Modeling transformation glScalef(1.0 , 2.0 , 1.0); glutWireCube(1.0); glFlush(); } void reshape (GLint w, GLint h) { glViewport(0,0,w,h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); // Projection transformation //glOrtho(-1.0,1.0,-1.0,1.0,0,100); glFrustum(-1.0,1.0,-1.0,1.0,1.5,20.0); glMatrixMode(GL_MODELVIEW); } void keyboard (unsigned char key , int x, int y) { if ( key=='q' || key=='Q' ) { exit( 0 ); } } int main( int argc, char** argv ) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(500,500); glutInitWindowPosition(100,100); glutCreateWindow(argv[0]); myInit(); glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc(keyboard); glutMainLoop(); return 0; }