DavidGobaud/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 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 (Bluebook states "multiply the current matrix by an orthographic matrix" - http://www.rush3d.com/reference/opengl-bluebook-1.0/ch05.html#id5511492) but in 2D applications like our current assignment its effect is to set the coordinate system. We might want to change this when a window is resized if the coordinate system changes with the window size. An example is a coordinate system that has a 1:1 mapping with pixels.


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.

Recent