Coms 385 Assignment 2 Fall 2003
The glut Library
This assignment will explore the glut library by testing the various glut callback functions and experimenting with the window initialization functions.
1. Open the file CallbackTest.cpp in the folder Coms385/Koether on the hsc-acad-fs server and add it to the OpenGL Project.
2. Begin execution of the program. Arrange the windows to that you can read the text window. What appears there initially? What does this tell you? Why was display() called twice?
3. Quit the program. Comment out the function call to glutPostRedisplay() in the function reshape(). Run the program again. How many times was display() called? Why would display() make a call to glutPostRedisplay()? Quit the program and uncomment the call to glutPostRedisplay().
4. Run the program again. Use the mouse to resize the window by dragging one of its edges or corners. What functions are called? How many times?
During the rest of this assignment, if the text window becomes unreadable, then quit and restart the program. You may need to do this several times.
5. While the program is running and the mouse is within the graphics window, press any ASCII key (letter, digit, punctuation) on the keyboard. Type both lowercase and uppercase letters. What function was called? Now hold the CTRL key while typing a letter. How is the numerical value received by the keyboard() function related to the ASCII value of the letter?
6. While the program is running and the mouse is within the graphics window, press one of the special keys (arrow keys, function keys, Home, Page Up, etc.). Do not press Enter or Delete. Press keys on the numeric keypad.
7. While the program is running and the mouse is within the graphics window, click the mouse. What function was called and what values did it receive? How many clicks were registered? Now right-click and answer the same questions.
8. Restart the program so that the graphics window will be its original size, 640 ´ 480. Click in the upperleftmost corner of the window. What are the coordinates? Now do the same in the upperrightmost, lowerrighmost, and lowerleftmost corners. How many pixels wide and tall is the window (not counting the border and the title bar)? In which direction is the x coordinate increasing, left or right? In which direction is the y coordinate increasing, up or down?
9. Click once in the text window and then click once in the graphics window. Which functions were called? Why?
10. Quit the program. In the main function, uncomment the glutMotionFunc() function call. Run the program. Press the mouse button and move the mouse around. Which function is called? How many times? While holding the mouse button down, move the mouse outside the graphics window. What happens?
11. Quit the program. In the main function, comment out the glutMotionFunc() function call and uncomment the glutPassiveMotionFunc() function call. Run the program. Without pressing the mouse button, move the mouse around, both inside and outside the graphics window. What happens?
12. Quit the program. Comment out the glutPassiveMotionFunc() function call. Also comment out the calls to glutInitWindowSize()
and glutInitWindowPosition(). Run the program. What effect do these functions have on the
graphics window?