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
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:
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 modulates the color of the texture with the background
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:
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.