Assignment 1: Jan 17, 2006
My program uses a series of well placed lines to create an illusion of a gradient. There are also 5 blue triangles and 4 loop lines. Press the space bar to change background colors.
Question 1: In a GLUT program, how is control passed back to the programmer? How is this set up during initialization? Control is passed back to the programmer by user-defined functions. These functions are setup during initialization by passing its function pointer as parameters. For example, in main, we have glutDisplayFunc, which takes a function that renders images on the screen; glutReshapeFunc, which takes a function that designates how to adjust the screen perspectives; and glutKeyboardFunc, which takes a function that specifies how the program responds to keyboard input.
Question 2: What does the parameter to glutInitDisplayMode() specify? glutInitDisplayMode's parameter specifies the display mode, which defines information about the color mode and buffers (how many and type). These are predefined constants in GLUT. Bitwise OR is used to get the correct combination. In our case, we have "GLUT_RGBA | GLUT_DOUBLE," which describes RGBA color and a double buffered window.
Question 3: What do the calls to glOrtho() and glViewport() accomplish? Reshape is called whenever we need to recompute window perspectives/coordinates. glOrtho sets the logical coordinates and depth of the window, while glViewport sets the area of the window which the images are drawn. Thus, in our call, the coordinate system goes from 0 to 1 for both x,y, with a depth from -1 to 1. We will be using the full window for the images.