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 by callback functions. This is set up during initialization by passing function pointers to functions such as glutDisplayFunc, glutReshapeFunc, and glutKeyboardFunc.

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

The parameter to glutInitDisplayMode() in main() specifies the initial display mode. A display mode consists of properties such as being double buffered, having a stencil buffer, and having an alpha component. In the sample code the parameter is GLUT_RGBA | GLUT_DOUBLE which specifies a double buffered RGBA display mode.

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?

glViewPort() sets the portion of the window that OpenGL uses. glOrtho() sets up the coordinate system. glOrtho() does more but in 2D applications like our current assignment its effect is to set the coordinate system.


Draws a square in the middle of the screen and a centered 'X' (2 lines) with a width and height equal to that of the window.

Pressing any key other than escape changes the color of the 'X' and the square. The color cycles between red, green, and blue. Pressing escape exits the program.

last edited 2007-01-19 00:02:40 by norad