Project 3

Objective
Demonstrate your knowledge of lighting.

Setup
As usual, we assume you are using Windows 2000 with Visual C++ 6.0. For more information, please read the COEN290 Lab Page.

This project builds on the program you built in Lab 2. Make a copy of your lab 2 directory and call it "lab 3". (You don't have to call it "lab 3" exactly but you are responsible for keeping track of your files so that you create a project for lab 3 and don't get confused between lab 2 and lab 3.) All the stuff will still be called "lab 2"-something, but that doesn't matter.

Double-click lab2.dsw and open main.c. Find the line that looks like

    glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
and delete it. This line told OpenGL to make glColor calls replace the current material. If you recompile and run your program right now, everything should be gray, because there are no glMaterial calls. That's part of your assignment.

Your assignment
Your assignment is to:

It may seem like a lot but it's really not that bad.

Most of you created flat polygons for the table surface and legs for lab1 and lab2. When we say "solid objects", we want you to create objects that have depth to them. You can choose one of a few ways to do this.

In order to rotate the light, you will have to change the light's location on every frame. You can do this by specifying the light's location using the glLight functions inside glPushMatrix, glPopMatrix, glScale, and possibly glRotate, just like the light was a geometric object. You can turn

To change the material colors of an object, use glMaterial. Remember that you can use glMaterial between glBegin and glEnd, but that may make your program slow, so don't get into that habit. Set the material before you call glBegin. (If you want to know about changing the colors per-vertex, remember that you used glColor before, and we can tell you more about that if you want.)

Finally, we would like you to change the light color on a keyboard command. Our suggestion is to have three keys and three different colors. You change the light color using glLight

I want you to add a bunch of printf statements in main() to print out how to control your program, also. Ask me if you need help with printf.

Remember that if you turn in a 100% program by the due date, but don't get extra credit working until afterwards, you can still get half of your extra credit up to a week after the due date. You can also turn in a partially complete program by the due date, then turn in the complete program afterwards to gain more points. For example, if I grade you at 90 for the on-time program because you didn't finish something, but you finish it and add extra credit stuff by Friday and it's worth 105 points, then your final grade will be 97.5.

You can compile and run your program using the "Build" menu and the "Execute" option.

Sample
We've created a version of lab 3 as if we had completed the lab already.

lab3sample.exe

You can download this program and run it. Make sure you download it into the same directory as the other lab 3 files, because it uses a DLL (shared library) that is in the .zip file.

Press 1, 2, and 3 to see the different lights we set up.

Submitting your results
Mail your main.c and redraw.c file to Brad Grantham at grantham@plunk.org by Wednesday night, Februrary 21st at 7 PM.