CS 381 HW4--Lighting!

This homework is based on the "glsl_primitives" program. You can download buildable source and a prebuilt binary for Windows and Linux (Zip, Tar-gzip).  You WILL have to recompile this program to finish this homework, so try out your compilers early! It's been tested with Visual C++ 2003 in the Chapman Lab, Visual C++ 2005 "Express" (download free from Microsoft), Code::Blocks, and Linux.

I'd like you to write ONE program that does the following things:

  1. Draws a sphere using 64 stacks (divisions along the Z axis) and 100 slices (divisions along the XY axis) instead of the default, which is 20 stacks and 50 slices. Feel free to also divide up the sphere by latitude, instead of by Z stack.
  2. Draws the amount of illumination received by the sphere from a white light source far away in the +Y direction, and a red light source far away in the +X direction. Treat the sphere as a completely diffuse white object. Your shading should look good with GL_TRIANGLE_STRIP.
  3. Also has a "Teapot" in the "Model" popup menu, and renders the teapot using the same illumination as the sphere. Note that your single program should be able to switch at runtime between Teapot and Sphere mode, but I don't care if you have any other objects...

Turn in your finished C++ "main.cpp", vertex program "vertex.txt", and fragment program "fragment.txt" files via blackboard. Please do NOT turn in any of the OpenGL libraries included in glsl_primitive--I've already got 'em, thanks!

Due midnight Thursday, October 5th.  WARNING: If your C++ or vertex programs don't compile, you won't get any points!  Be sure to try them out before submitting them! If Blackboard doesn't work for you, or you don't have an account, you can email this homework to me at ffosl@uaf.edu.


HINT: glutSolidTeapot draws a teapot, but the "size" parameter only affects the builtin OpenGL matrix "gl_ModelViewMatrix", which your vertex.txt probably doesn't and need not read. For help on lighting, check out last Thursday's and this Tuesday's lecture notes!
Back to CS 381 Home Back to CS Home Back to UAF Home