CS 621Contemporary Computer Graphics
Lab 9
Dr. Tong Yu, Winter 2008
Moving Light and Material Color
Login and open two windows, one for editing and one for compiling
and executing programs. (
Try to reduce the browser size so that it won't occupy the whole
screen and you can observe a few things on the screen at the same time. )
Copy the program movelight.cpp from the lecture notes.
Compile and execute it.
Modify the program in the following manner:
- Make the light translate past the object instead of rotating
around it. Hint: Use glTranslated() rather than the first
glRotated() in display(), and choose an appropriate value to use
instead of spin.
- Change the attenuation so that the light decreases in intensity
as it's moved away from the object. Hint: Add calls to glLight*() to
set the desired attenuation parameters.
Copy the program colormat.cpp from /pool/u/class/cs420/lighting.
Compile and execute it. Click the mouse to see the change in colors.
Modify the program in the following manner
- Change the global ambient light in the scene. Hint: Alter the value of the GL_LIGHT_MODEL_AMBIENT parameter.
- Change the diffuse, ambient, and specular reflection parameters, the shininess exponent, and the emission color. Hint: Use the glMaterial*() command, but avoid making excessive calls.
- Remove all the glMaterialfv() calls, and use the more efficient glColorMaterial() calls to achieve the same lighting.