You are not allowed to use this action.

    Assignment 1

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

The programmer passes in functions such as display, reshape and keyboard to the GLUT functions and GLUT calls these functions when appropriate. The GLUT functions for these functions are: glutDisplayFunc( display ); glutReshapeFunc( reshape ); glutKeyboardFunc( keyboard );

Display gets called when glut displays a new screen (either on its own or when the programmer forces it), reshape gets called when the window is reshaped and keyboard gets called when the user of the program presses a key.

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

It specifies the display mode, usually with the bitwise OR-ing of GLUT display mode bit masks (color scheme).

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() specifies the coordinate system (in this case to go from 0 to 1 on all 3 axis, putting 0 in the lower left corner). glViewport() sets the pixel rectangle for drawing to be the rectangle in the arguments (in this case the entire window). As currently coded if we use the coordinate system, shapes will automatically scale when resizing the window, we might want the glOrtho() arguments to be a factor of the number of pixels and keep shapes the same size even when we resize the window.

Recent