1. In a GLUT program, how is control passed back to the programmer? How is this set up during initialization?

  • Control is passed back to the programmer through callback functions such as glutKeyboardFunc(). During initialization function pointers are passed to the callback functions. In this program whenever a key is pressed keyboard() is called as specified in main() by glutKeyboardFunc( keyboard ).

2. What does the parameter to glutInitDisplayMode() in main() specify?

  • The glutInitDisplayMode() in main() specifies the display mode for the window. In this case it is specifying to us RGBA (GLUT_RGBA) instead of color-indexing and to use a double buffer (GLUT_DOUBLE) instead of a single one. The double buffer allows for smooth animation (ability to swap front and back buffers).

3. What do the calls to glOrtho() and glViewport() in the reshape() function accomplish? If the window is to be resized, why might we want to change this?

  • glOrtho() creates an orthographic parallel viewing volume. It specifies the left, right, top, bottom, near and far edges of the box of the viewing volume. glViewport sets up the drawing region. it speficies the bottom left corner of the region and then height and width of the region. If the window is to be resized you don't want to fix the drawing region as the window resizing is unlikely to have an affect.