CPSC 441: Computer Graphics

Fall 2008


Assignment 1: Simple GLUT/OpenGL Application [50 points]

Due 9/7

Purpose:
The purpose of this assignment is to become familar with OpenGL and event-driven programming using GLUT.

Description:
1. Send an email cc'd to both the instructor and TA. Include the following information in the message: Your Name, classification (junior/senior/grad student), major, and one or two interesting facts about yourself. The email address you send the email from should be the one you want to use to receive information about the class.

2. Implement the program found on pages 24-25 of the OpenGL programming guide (copy the program and add the appropriate #include's). Once you have the program running, experiment with changing some of the values to get a feel for what the program does. Now we'll replace parts of the program to do something different.
  • Make the window have a width to height ratio of 4:3 with the title "your name - Assignment 1"
  • Replace the rectange by a convex, filled (gray) polygon with at least 6 sides. Outline the boundary of the polygon by drawing lines around the edges, each in a different color. (See Chapter 2 of the OpenGL Programming guide for help on drawing polygons and lines.)
  • When the user presses the left mouse button, make the polygon spin clockwise about its center. When the user presses the right mouse button, make the polygon spin counter-clockwise. When the user releases either the left or right mouse button, the polygon should stop spinning.
  • While the left/right mouse button is pressed (and the polygon is spinning), you should let the user control the speed of the polygon. Here is how the control should work (assume the point at which they first click down on the mouse button is the "home" position): Moving the mouse up from the home position should make it go faster, moving it down from the home position should make it go slower. This speed change should apply only while the button is pressed - after releasing the button, the speed should be "forgotten", so that the starting spinning speed is the same each time the button is pressed.
  • While the left/right mouse button is pressed, moving the mouse to the left or right from the home position should increase/decrease the intensity of the filled portion of the polygon. This change should only occur while the left or right mouse buttons are pressed.
  • When the user presses and holds the middle mouse button, the polygon should translate in a corresponding manner on the screen. That is, if the user moves the mouse up, the polygon should move up (the same for left, right, down, etc...). This translation effect should not end when the user releases the mouse button. Also note that the polygon should still continue to spin around its center and not the center of the screen.
  • Change the color of the background of the window to cyan, magenta, yellow, or white when the 'c', 'm', 'y', or 'w' key is hit respectively.
Grading:
[3] email with name, classification, major
[2] one or two facts in email
[5] Window correct size and title
[10] Draw polygon with at least 6 sides with outline and correct colors
[5] Clockwise spin when left mouse button pressed
[5] Counter-clockwise spin when right mouse button pressed
[5] Speed changes smoothly when dragging left/right mouse button up/down
[5] Filled polygon intensity changes smoothly when dragging left/right mouse button left/right
[5] Polygon translates when dragging middle mouse button
[5] Background color changes with key press