
Problem Set 0
CMSC 427 โ Computer Graphics
Assigned February 1, 2005
Due February 8, 2005
This problem set will introduce OpenGL programming. You will start with a simple,
working OpenGL program and modify it. The source code for this problem is available
from the class web page.
1. 25 points. Modify the program so that instead of displaying a triangle, it displays
a square.
2. 12.5 points. Now modify your program to accept keyboard input. Your program
should allow the user to change the color of the square, by pressing the r (red), g
(green), or b (blue) keys.
3. 12.5 points. Now modify your program so that it accepts input from the mouse.
If the user right clicks the mouse, with the mouse over the square, turn the square
into a diamond.
4. 50 points. Now we will modify the program to allow more continuous user input
so that the user can drag the square around. Modify your program so that if the
user left clicks the mouse while the mouse is on top of the square, and then holds
the mouse button down and drags the mouse, then the square will be dragged by
the mouse.
a. As the square is being dragged, the mouse pointer should remain over the
same point on the square as it was when the mouse was initially clicked.
As the mouse is moving, the square should move continuously with the
mouse.
b. If the user clicks the left mouse button with the mouse outside of the
square and then drags the mouse, the square should not move, even if the
mouse is dragged over the square.
You do not have to worry about dragging a diamond that might be produced by a
right mouse click.