
Homework 2 : Due Sept. 5, 2007
CS 470
August 28, 2007
1 2D Interactive Graphics
The goal of this homework is to learn to write GLUT callback functions for rendering and user
input, and to become familiar with OpenGL through basic 2D rendering. You may use the files from
homework 1 as a starting point.
1.1 Specification
Your will create an interactive 2D application with the following features:
•10% - Window management : Open a 480 ×480 window. The text in the titlebar should read
’Homework 2’.
•10% - OpenGL drawing : The background color (use glClearColor) should be white. Draw
a grid of gray horizontal and vertical lines spaced 0.1 units apart. The grid lines through the
origin should be 2 pixels wide, all others should be 1 pixel wide. This grid background should
appear behind all other graphics.
•10% - OpenGL drawing : Render a square polygon 0.5 units wide using points and lines.
Render the vertex points in red, four pixels wide. Render the edges of the polygon in blue,
with 2 pixel wide lines. The square should initially be positioned with its center at the origin.
•20% - GLUT text : Using the appropriate OpenGL functions and glut bitmap text rou-
tines, write a function DrawText(float x, float y, float z, void* font, char* text).
Draw your name in the lower left-hand corner of the screen using this function. The text in
this assignment should appear on top of all other graphics.
•20% - Special keyboard callback : Pressing the arrow keys will translate the square 0.1 units
in the corresponding direction.
•10% - Mouse callback : Pressing the left mouse button will reset the square to its original
location (centered at the origin).
•10% - Keyboard callback : Pressing the ESC key should cause the program to exit.
•10% - Documentation : Create a README file with your name and a description of which
features work correctly.
Either full or zero credit will be given for each of these specifications.
2 What to turn in
Submit all source code, a README file, and a working project file or Makefile which builds an
executable named ’hw2’ or ’hw2.exe’. Turn in a single tarred and gzipped, or zipped file by the start
of class on the due date (ecampus or on CD).
1