Yeunjin Kong/Assignment 1 Writeup
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 through callback functions. In Assignment 1, glutKeyboardFunc() is such function. During initialization, function pointers to user-defined functions are passed to callback functions as parameters. In Assignment 1, keyboard() is such function.
2. What does the parameter to glutInitDisplayMode() in main() specify?
The parameters to glutInitDisplayMode() specify the display mode of the window, such as RGBA or color-index, or single-or double-buffered. The main function of Assignment 1 has two parameters. The first parameter GLUT_RGBA specifies to use an RGBA color model. The second parameter GLUT_DOUBLE specifies to use a double-buffered window.
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 OpenGL assumes as it draws the image and how the image gets mapped to the screen. glViewport() specifies the transformation of x and y coordinates from normalized coordinates to window coordinates. Thus in main.cpp, every time the window is resized, the coordinate system is set to have 0 and 1 as the lower and upper bounds for both x and y coordinates, the nearest depth is set to 0 and the farthest depth is set to 1. This helps the relative proportion of what is being drawn changes as the window is resized.