CPSC 324, Spring 2001 Information For First Test ------------------------------------------------------------------------ The first test for this course will be given on Thursday, February 23. Here is a list of some of the terms and ideas that you should be familiar with for this test: computer graphics GLUT API functions: painting programs glutInitDisplayMode() drawing programs glutMouseFunc() pixels glutKeyboardFunc() geometric modeling glutReshapeFunc() attributes (such as color) glutDisplayFunc() rendering glutIdleFunc() geometric transformations glutPostRedisplay() computer animation OpenGL OpenGL API functions: GLU glVertex3f, glVertex2f GLUT (why does it exist) glRectf Mesa glColor3f single-buffered graphics glClearColor double-buffered graphics glClear vertices glViewport 3D coordinates glBegin, glEnd polygon glFrustum convex polygon glOrtho color gluLookAt RGB color space glTranslatef HSV color space glScalef indexed colors glRotatef modeling transformation glMatrixMode translation glPushMatrix scaling glPopMatrix rotation about a point in 2D rotation about a line in 3D Constants for glBegin: projection transformation GL_POLYGON perspective projection GL_POINTS orthogonal projection GL_LINES clipping GL_LINE_LOOP view volume GL_LINE_STRIP combining transformations OpenGL as a state machine camera analogy for 3D viewing viewing transformation wireframe RGBA colors about the GIMP: filters brushes gradients gradient tool color blending and opacity selection tools selecting by color layers ------------------------------------------------------------------------ Here are a few questions from tests given in this course in previous years: 1. An OpenGL program has an "idle" callback function that includes the command "spin += 2;", where spin is a global variable. Here are two display functions that could be used in the program. Describe and/or draw the animations produced by each, and explain the difference. (Assume that the clear color is white, the drawing color is black, and the projection was set with "glOrtho(-5,5,-5,5,-1,1)".) void display() { void display() { glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT); glLoadIdentity(); glLoadIdentity(); glRotatef(spin,0,0,1); glTranslatef(3,0,0); glTranslatef(3,0,0); glRotatef(spin,0,0,1); glRect(-1,-1,1,1); glRect(-1,-1,1,1); glutSwapBuffers(); glutSwapBuffers(); } } 2. This question uses the following object: (OBJECT NOT SHOWN HERE -- MAKE ONE UP) a) Show how this object will appear in OpenGL if it is drawn as a wireframe model and the following command is used to set up the projection transformation. (The default viewing transformation is used, with no modeling transformation.) glOrtho(-3,3,-3,3,-3,3); b) Repeat part (a) using the following commands to set up the projection and viewing transformations: gluLookAt(0,0,5, 0,0,0, 0,1,0); gluPerspective(45,1,1,10); 3. What OpenGL code would you use to draw a red triangle that lies in the (x,y)-plane and has vertices at (-1,-1), (1,-1), and (0,2) ? 4. Before a scene is displayed in OpenGL, it is clipped to the view volume. Explain what this means.