Home | People | Curriculum | Projects | Resources | Media

Computer Graphics

CMSC 212

Haverford College

Fall 2003

Lab 1

Monday, September 22

Mouse & Keyboard Interaction, and 2D Transformations, with OpenGL

Design and implement a C++ program using OpenGL calls to permit the user to point to a position in the drawing window and click to draw a shape using the following scheme:

The position of the mouse click indicates the center of the shape. The size of the shape should be (roughly) 30-50 pixels "diameter". You are welcome to experiment with "click and drag" for drawing these shapes, then the size is variable [+10].

The lab is completed as follows:

  1. Add the following functions: (Note: the function signature may change if you use "click and drag")
  2. Draw shapes at mouse down clicks until the 'T' key is entered. You will need to save a representation of each shape, including it location, in some type of list, basically saving the universe.
  3. Transform the universe of shapes using the OpenGL functions: Transformations are indicated by the following keystrokes:
    • r: shift right (or use right arrow)
    • l: shift left (or use left arrow)
    • u: shift up (or use up arrow)
    • d: shift down (or use down arrow)
    • x: expand (double in size)
    • s: shrink (halve in size)
    • c: clockwise rotation of 45 degrees
    • w: counter-clockwise rotation of 45 degrees
  4. After each transformation, the projection matrix is updated, and you will need to redraw the universe by travering your list and rendering the newly generate vertices and edges of the polygons.
  5. Make, run, and test the completed program.
  6. Document your code appropriately (especially including your name in the source).
  7. Submit your work using submit
  8. Extra Credit: eventually shear (h) will be added, but you can do this now [+5] by using glLoadMatrix() and glMultMatrix()

Links for CS212 -- Other CS212 Assignments: 0 1 2 3 4 5 6 7

Haverford College Page maintained by John Dougherty, David Wonnacott, and Rachel Heaton.
Computer Science Department, Haverford College.