Assignment 1 CS 148 Due 01/18/07

Answers to questions from #2

  • 1 Control is passed back to the programmer during various events that occur during program execution, specifically in this code example via keystrokes and window resizing. During initialization, the programmer sets up handlers that will be executed when these events occur, via calls to glutReshapeFunc and glutKeyboardFunc.

  • 2 The parameters to glInitDisplayMode ( in this case GLUT_RGBA | GLUT_DOUBLE ) specify that we wish to use the Red-Green-Blue-Alpha display mode (GLUT_RGBA, as opposed to GLUT_INDEX or GLUT_LUMINANCE ) , and that we wish to use double-buffering (GLUT_DOUBLE, as opposed to GLUT_SINGLE or GLUT_ACCUM).

  • 3 glOrtho appears to define the boundaries of the drawable area. The first four values given to glOrtho specify the left, right, bottom, and top boundaries of the drawing area. Thus if we call glOrtho( 0., 1., 0., 1., -1., 1. ); as is done in the given code, a triangle drawn between vertexes (0.0, 0.9) (0.5, 0.5) (1.0, 0.0) will fit fully within the drawing area. If we change the call to be glOrtho( 0., 0.8., 0., 1., -1., 1. );, the right portion of same said triangle would be clipped off since it is "out of bounds". The fifth and sixth values given to glOrtho aren't as clear... manual pages for the function indicate these specify the "back" and "front" values. This refers to something depth related. glViewport seems to work as a sort of "use this much window area to display the drawing" specifying function. In the given code the call is glViewport( 0, 0, w, h );, which indicates the entire window should be used to display the drawn image. If instead we use glViewport(0, 0, w/2, h/2); then the drawn image still appears, but shrunken down and only displayed in the lower left hand corner of the window.