Texture Mapping

Download the C version or Java version of the texture mapping sample program and extract it.

Inside is source code and three texture map images. The two .pnm images can be viewed by the gThumb graphics utility or similar programs. The raw .lum file was specially created with Photoshop for this lab.

Compile and run the program. You should see a cube with a red brick pattern.

1. Modify the texture coordinates so that the brick pattern is the right way up for the side faces of the cube.

2. Modify the texture coordinates so that the brick texture is repeated several times across each face. (Save a copy of the original coordinates.) Start with a 4 by 4 repeat, then try 4 by 2.

3. Extend the texture coordinate array with new values and modify the texture face index array so that the brick texture is repeated a different number of times across two faces than the others.

4. Change the display code to bind the dice texture map instead. Modify the texture coordinate and index arrays so that the faces of the cube are correctly numbered.

5. Optional - write a new drawSphere function/method and use it instead of the cube. Use a GLU quadric, not GLUT, and enable texture coordinate generation with gluQuadricTexture.

6. Optional - the program includes the original cube menu to change colors, which doesn't work. Load and bind the raw format bricks luminance texture (1 byte per pixel) instead of the RGB version. Go back to the original single copy texture coordinates and change the texture mode from GL_DECAL to GL_MODULATE. Now what happens when you change the cube color?

7. Optional - add menu commands to switch between the brick and dice textures.