Computer Science 4160 - Computer Graphics
Assignment 1
Fall 2004


Due September 23, 11:59pm


This assignment was designed with 2 main goals: This assignment also gives you a chance to play around a little and explore. In particular, the assignment skeleton is written in OpenGL. While not absolutely required for this assignment, it would help for later assignments (which will require extensive use of OpenGL) if you could at least understand the framework (we'll discuss this briefly in class) and you may also want to play around with it a little. However, do note the submission requirements to not submit any modifications to the main assignment framework.

General Information

This assignment will ask you to fill in the code to allow rotation of the viewpoint around a scene.

Post any questions you have to the newsgroup. Other students will want to see the answers too. Do not post anything resembling code.

Getting started

This assignment is only supported for windows. Specifically, it was created with C++ Visual Studio 6.0. Try to get access to a computer with this software. If you plan to use UNIX, start early so you have time to contact the system administrator about problems you encounter (such as setting up glut, or finding the directory where gl.h is located).
  1. You probably already have openGL set up on your computer. Search for gl.h to see if you have it. If not, go to and follow the instructions on downloading the appropriate files.
  2. You probably don't already have Glut set up. If you want, you can also find the download for that package from Alternatively, you can download the three necessary files from You will have to set up your path to point to the location of the dll.
  3. Download the assignment: HW1: Transformations.
  4. Unzip
  5. Run hw1_solution.exe. If you get an error message about glut32.dll, try adjusting your path, or simply copying it into the same directory.
  6. Compile and run the files as is.
  7. You should see the same teapot on a blue background, but the arrow keys won't work. Your job will be to make them work.

ONLY MAKE CHANGES TO Transform.cpp. Do not add any #include lines to the code. Do not change Transform.h. If you do make changes to any of the other files, make sure your solution works without those changes. You will only be submitting Transform.cpp.

The files nv_mathdecl.h, nv_algebra.cpp, nv_math.h and nv_algebra.h are provided as helper files. Don't worry about the details of these files. Concentrate on main.cpp. That said, You will probably have a much easier time if you look at set_rot().


You will be implementing a classic crystal ball interface. This simulates a world in which the viewer is glued to the outside of a transparent sphere, looking in. The sphere is centered at the origin, and that is the direction towards which your eye is always pointing. At the origin, there is something interesting to look at -- in this case, a teapot.

You can change the viewpoint by rotating the crystal ball in any direction about the origin. Usually this is done with a mouse, but you will be using the keyboard for this assignment to make things easier. You must think about how the position of the eye and direction of the up vector change with left-right or up-down rotations.

Fill in the parts of Transform.cpp that say "//FILL IN YOUR CODE HERE". First, you should fill in left() and up(). Once these are working, fill in lookAt().

The compiled correct solution has been provided for you. Your solution must behave identically to hw1_solution.exe. All you need to test this is to press the arrow keys a few times and toggle 'g' to make sure your lookAt() works.

You should paly around with the solution to try and make the red and blue light line up by updating one and not the other (press 'h' when the solution is running). Also, you will have to answer a question in the submission email (see below).


You may submit more than once. Only the last submission will be graded.

When you are satisfied with you results, submit via email as described below:
From: [you]
Subject: HW1 - [your name]
Attachment: Tranform.cpp (do not include it as text. Make sure it's a seperate file attachment.)
Body: Your name and email.
Describe why it is that the red light seems to provide more than just a point light source, illuminating the entire half of the teapot, while the blue light leaves most of the teapot dark, only illuminating as a point source. The answer can be found in the red book (Woo), on page 189.

If you did not use Visual Studio on a Windows platform, please describe what you did to complete this assignment.