DMS 423 Midterm Exam

Name:                                                                         

  1. [1 point]   True or False:      Every distinct real world color can be described by a distinct RGB color value.

  2. [1 point]   True or False:      Double buffering increases the frame rate of a program.

  3. [1 point]   True or False:      Double buffering increases the amount of memory used by a program.

  4. [1 point]   True or False:      JPEG is the best file format for images that will be used as OpenGL textures.

  5. [1 point]   True or False:      The aspect ratio of an orthographic projection (gluOrtho2D) must be the same as the aspect ratio of the window on the display.

  6. [2 points] Which of these two CMY colors will appear brighter?:

                 (0.5, 0, 0)        (0, 1, 0.25)

  7. [2 points] Approximately how many bytes of data are in a 10 second clip of CD-quality, stereophonic sound?




  8. [2 points] Which direction should the following code fragment cause the shape to spin: clockwise or counter-clockwise?
    glRotatef(time.time()*2, 0, 0, 1)
    drawShape()
    

  9. [3 points] Outline some code that would gradually brighten the background color of a scene from black to full yellow over the course of 10 seconds - identify both the calculations and the OpenGL calls that are required.












    For the next 3 questions, suppose you were creating a real-time status display for baseball broadcasts, that shows the positions of up to 4 runners around the bases. Each runner is drawn as a circle; the bases are 4 squares; the outline of the diamond is 4 lines.

  10. [3 points] List all the glBegin() calls, and the number of glVertex calls that follow each, needed to draw the bases and diamond (but not the players).
    e.g. "glBegin(GL_POINTS), followed by 7 vertices, ..."










  11. [3 points] Assume the real-time runner position data is being provided in two variables: numRunners - the number of runners, and runnerPos - an array of X/Y values (e.g. runnerPos = [ [5, 0], [15, 10] ]), and you have a function drawPlayer() to draw a circle centered at (0,0). Outline the code necessary to draw the runners.















  12. [3 points] If you wanted to make it possible to switch the status display between filling the window and only occupying a small corner of the window, what OpenGL code would you need to add, and where (in relation to the other code of the previous two questions)?








  13. [3 points] If drawSquare() draws a 1x1 square centered at (0,0), sketch the layout of shapes drawn by the following code, relative to the world coordinate system:
    glLoadIdentity()
    glTranslatef(3, 0, 0)
    drawSquare()
    glPushMatrix()
    glTranslatef(-6, 0, 0)
    drawSquare()
    glPopMatrix()
    glPushMatrix()
    glTranslatef(0, 3, 0)
    glRotatef(45, 0, 0, 1)
    drawSquare()
    glPushMatrix()
    glTranslatef(3, 0, 0)
    drawSquare()
    glPopMatrix()
    glPopMatrix()
    

  14. [2 points] What RGB color would be stored in the frame buffer, after drawing a pixel having RGBA value (0.7, 0.5, 0.0, 0.5) over a pixel having RGBA value (0.2, 0.2, 0.2, 0.2), with the "standard" glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) enabled?






  15. [2 points] What RGB color would be stored in the frame buffer, after drawing a pixel having RGBA value (0.7, 0.5, 0.0, 0.5) over a pixel having RGBA value (0.2, 0.2, 0.2, 0.2), with glBlendFunc(GL_ONE, GL_ONE) enabled?






    The following 3 questions use the texture at right - a single cross centered in the texture image.
  16. [3 points] What are the (approximate) texture coordinates required to draw a textured rectangle such as the one below?
    glBegin(GL_QUADS)
    
    glTexCoord2f(          ,           )
    glVertex2f(-3, -2)
    
    glTexCoord2f(          ,           )
    glVertex2f(3, -2)
    
    glTexCoord2f(          ,           )
    glVertex2f(3, 2)
    
    glTexCoord2f(          ,           )
    glVertex2f(-3, 2)
    
    glEnd()
    


  17. [3 points] What are the texture coordinates required to draw a textured rectangle such as the one below?
    glBegin(GL_QUADS)
    
    glTexCoord2f(          ,           )
    glVertex2f(-3, -2)
    
    glTexCoord2f(          ,           )
    glVertex2f(3, -2)
    
    glTexCoord2f(          ,           )
    glVertex2f(3, 2)
    
    glTexCoord2f(          ,           )
    glVertex2f(-3, 2)
    
    glEnd()
    


  18. [2 points] What would need to be changed in a program that draws the rectangle on the left, in order to draw the rectangle on the right?
           

  19. [3 points] Write some code that will pick a random point (X,Y) inside a bounding circle that has a center (CX, CY) and a radius R.



























  20. [3 points] Suppose you wanted to simulate a joystick's X & Y input values using the mouse, where the X & Y values are based on the mouse pointer position in the window, but only while the left mouse button is held down (at all other times, it has the value 0,0). What input events will your code have to watch for, and what will it do in response to each type of event? (Exact code is not needed, just a general description of the various actions.)