PaulLin/Assignment 1

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

The control is in the form of events, which the programmer needs to write functions to handle. OTherwise the program just runs an endless loop while waiting for events. For example, the "display" function is called whenever GLUT needs to redraw the window and display (glutDisplayFunc(display);) This is set up during initialisation by assigning the functions to specific events, which in this case is to execute "display" when the glutDisplayFunc is invoked. The programmer can also set up events for keyboard events and mouse events.

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

It specifies what type of window we want to create. For example, we can describe the colour options, and whether we want to use a single buffering or double buffering. For us, it specifies we want the RGBA colour model, and double buffering.

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 glOrtho() tells the system the coordinate system we want to use, for example, the x-axis from -1 to 1, and y-axis from -5 to 5. The glViewport() tells the system which part of the window we want to use, if we don't want to use the entire window. This is specified in pixels. We may want to change this when we resize windows, to maintain the x/y ratio so that the drawing doesn't get distorted.

Recent