Test # 2

Open-book test. No collaboration allowed.

 

Part I. Lighting and materials

 

Use light.cpp and material.cpp as the starting framework for this homework and use OpenGL lighting mechanism described in chapter 5 of OpenGL programming Guide to accomplish the tasks described below. For each task, please write a separate .cpp file. (For example, task1.cpp, task2.cpp, task3.cpp, …), and send them as attachments of an email to me together with answers to the questions associated with the programming tasks.

 

You may need to set the viewing volume appropriately to make the scenes visible.

 

Task 1: Scene 1: Set up two unit spheres and a light.

 

Task 2: Scene 2: Add a second light into scene 1.

 

Task 3: Scene 3: Add a second light into scene 1.

 

Task 4: Scene 4: Make the light in scene 1 revolve around a fixed point

 

 

 

Part II: Texture mapping

 

Task 5: Enable lighting with at least one light source and render six objects with texture mapping as described in the following. You can either display them all together as 6 objects in a scene in a single program or as separate objects in separate scenes in one or more programs. Either way is fine. (Useful references: key OpenGL texture mapping commands.)

  1. Create and load a texture object loaded with a red-and-black checker board image. (Useful reference: texbind.cpp)
  2. Create and load another texture object loaded with an image of a photo scanned or downloaded. (Useful reference: cubeTex.zip) You should include tga.h and tga.cpp in your project and use the function void CreateTexture(GLuint textureArray[], char *strFileName, int textureID) implemented in tga.cpp to load an image from a .tga image file. Note that you can use photoshop or image composer to easily convert any JPEG or JIF image file to or from a .tga image file.)
  3. Do texture mapping to have the checker board image mapped onto a rectangle, a glutSolidTeapot and a gluCylinder in the scene.
  4. Do texture mapping to have the real world image mapped onto a rectangle, a glutSolidTeapot and a gluCylinder.

 

 

More references: See OpenGL 1.1 reference guide about

 

To see a sample TGA picture and an example executable rendering a glutSolidTeapot with texture mapping, download, unzip, and play with this sample demo program.