This week I worked with texture mapping on a curved surface, texture mapping with lighting, and fog. To map a texture onto a curved surface, the texture needs to be bound with a call to glBindTexture within the same glPushMatrix ... glPopMatrix block as the drawing code for the surface. Environment variables also need to be set to allow mapping onto a curve. The code for setting these variables is as follows:
glTexGenf(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGenf(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glEnable(GL_S);
glEnable(GL_T);

This code allows both the s and t coordinates of the texture to be mapped onto a spherical surface.

In the last few weeks, the textures on the robot's torso and face did not support lighting. This was because lighting and shading only work on textures when the texture environment is in GL_MODULATE or GL_BLEND mode. GL_MODULATE modulates the color of the texture with the background color. GL_BLEND blends the texture color with the background color or a user-specified color array. Other environment modes disable lighting for mapped textures.

Fog in OpenGL turned out to be quite easy to implement. OpenGL has a built-in fog feature activated with the following code:
glEnable(GL_FOG);
glFogf(GL_FOG_MODE, GL_LINEAR); // Fog mode can be GL_LINEAR, GL_EXP, or GL_EXP2.
                                // GL_LINEAR enables depth cueing.
                                // GL_EXP is for heavy fog.
                                // GL_EXP2 is for haze.
glFogf(GL_FOG_DENSITY, 0.1f);
glFogf(GL_FOG_START, 1.0f);  // Distance from camera where fog should start.
glFogf(GL_FOG_END, 150.0f);  // Distance from camera where fog should end.
glFogfv(GL_FOG_COLOR, fog_color);  // Set fog color to blend with scene. fog_color is an array of 
                                   // color values.

Key bindings
F1 - Switch texture on robot's torso.
F2 - Cycle through background scenes.
F3 - Switch fog on and off. Fog is on by default.
q - Exit program.