Exactly one page like "JosephBonneau" found, redirecting to page.

    JosephBonneau/Assignment1

Assignment 1 Answers

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

Control is passed back via a callback function which is passed as a parameter (namely a C++ function pointer) to the function glutDisplayFunc(). This function is then called by the GLUT library code after initialization is complete. Funcion pointers are also used to specify behavior on window reshape, keyboard, and mouse events.

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

There is only one parameter, an integer, but it is used to specify a number of initialization options by taking the bitwise-OR of several possible flags. Single or double buffering is selected by using the GLUT_SINGLE or GLUT_DOUBLE commands. The color selection scheme is selected using GLUT_RGBA or GLUT_INDEX. There are more advanced flags available as well such as GLUT_ACCUM, GLUT_ALPHA, GLUT_STEREO, etc. which we don't need for Assignment 1.

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?

The glViewport() function specifies which portion of the window we which to draw to, in the assignment we want to draw onto the whole window. The glOrtho() command specifies a matrix which transforms the coordinate system. This lets us define our coordinate system however it is convenient for the program we are writing. If the window is resized, we may want to change the coordinate system based on the new window size, this lets us keep the aspect ratio or size fixed during resize operations.

Recent