Paolo Bezoari CS148 Assignment 1

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

In a GLUT program, control is passed back to the programmer using callback functions that we specify for certain events. For example, we use the glutKeyboardFunc() function to set the function to call when a keyboard press is detected and we use the glutReshapeFunc() function to set the function to call when the display is resized.

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

GLUT_RGBA sets the window mode to RGBA (red-green-blue-alpha) and GLUT_DOUBLE enables double buffering of the window. By OR-ing these 2 parameters, we enable them both.

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() performs an orthographic projection of the space, thereby flattening it. The different parameters to glOrtho() specify the location of the projection plane in space. glViewport() specifies the area of the window where we should draw. If the window is to be resized, we might want to change the parameters to glOrtho() and glViewport() so that the aspect ratio of the shape stays the same for example.

last edited 2007-01-19 00:15:04 by haruko