Project 1

Objective
Demonstrate skills in using a compiler and the Visual Studio facility. Additionally, demonstrate an understanding of how to create geometry in OpenGL using glBegin, glVertex, glColor, and glEnd.

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

Download the .zip file containing the framework for lab1:

lab1.zip

Use unzip or WinZip to unpack this file into a directory of it's own. We suggest the directory be called "lab1".

Your assignment
Click on the "File" menu in Microsoft Visual Studio select "Open" and choose redraw.c. Your assignment is to add some geometry to the redraw function to draw a table and something on the table. You can draw the table with any of the solid shapes in OpenGL, like GL_QUADS or GL_POLYGON. The viewing transformation is already set up so that you're 20 units away from the origin at [0,0,0], and your field of view includes about 24 units around the origin. If you want to imagine that the units are feet, that would probably work about right. For example, you could build a table of GL_QUADS about 4 feet high and 3 feet across. We have also included code so that you can control your scene with the mouse. Click the left mouse button then drag to move. Drag right and left to move around the scene and up and down to move closer or farther away.

We would like you to use glBegin and glEnd to create the table itself, but you can use any other primitives to put things on the table. GLUT has many primitives like dodecahedrons and spheres. In addition, we have provided a drawTeapot function that takes an x, y, and z position and draws a teapot. The teapot is around one and a half units tall.

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

At least one of the triangles, quads, or polygons you make must have a color for each vertex, and at least one must have just one color for the whole triangle/quad/polygon. Once your program is running, you can force OpenGL to draw objects with flat shading by pressing "s". Then you can go back to smooth shading with "s" again.

We have provided the GLUT keyboard callback in redraw.c. For extra credit, you can add a key to turn on and off wireframe mode. This is controlled by glPolygonMode.

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

lab1sample.exe

You can download this program and run it. Make sure you download it into the same directory as the other lab 1 files, because it uses a DLL (shared library) that is in the .zip file. You can also download it separately from glut32.dll if you want to run the sample in a different directory.

Here's what it should look like:

Click and drag to move the scene. Try pressing "s" multiple times while looking closely at the table legs. It should be clear that one leg is using per-vertex colors but the others are not. Zoom in on the teapot and watch how it changes when you press "s".

We have implemented the "w" key to change back and forth from wireframe. Press the "w" key while looking at the teapot.

Submitting your results
Mail your redraw.c file to Brad Grantham at grantham@plunk.org by Wednesday night at 7 PM.