Assignment One Answers
1. Control is passed back through the use of callback functions. These are registered using glutDisplayFunc(), glutReshapeFunc(), glutKeyboardFunc(), glutMouseFunc(), etc. The functions registered are called whenever the corresponding event occurs (a window reshape, keyboard event, mouse event, etc.), and then the programmer is able to take control back from the library code.
2. This parameter specifies the display mode of the program. Available settings are RGBA or color-index and single- or double-buffered, as well as others. These options are specified by combining the constants GLUT_RGBA or GLUT_INDEX and GLUT_SINGLE or GLUT_DOUBLE using a bitwise OR.
3. glOrtho sets the projection transformation, or the viewable volume of the drawing space. glViewport sets the viewport tranformation, or the portion of the drawing space which should be displayed in the window. When the window is resized, we may want to do one of two things: 1) reduce/enlarge/resize the viewport transformation or 2) ensure that the viewport transformation is updated to keep it constant relative to the size of the window.
Program Operation
This is a simple mock-up of PacMan. Hitting the j and l keys makes PacMan go left and right, respectively, and the spacebar switches his direction. The inner blue rectangle is a line loop, while the outer one is the outline of a quad. Both sets of lines are of width 2.