TextureTorus is a C++ program illustrating the use of OpenGL.
It is intended to accompany the book 3D Computer Graphics: A mathematical
approach with OpenGL, by S. Buss, Cambridge University Press, 2003.
However, it can be used independently as well.
TextureTorus draws a torus in a non-standard way, as a ribbon of quad
strips that wrap around the torus in one long strip. The C code consists of two
source files, TextureTorus.cpp and TextureTorus.h.
There are several options available for downloading this program:
Things to try out:
- Before running TextureTorus, you should try out the simpler WrapTorus and LightTorus programs. For a
simpler setting illustrating the use of textures, see TextureBMP.
- Compile and run the program. Test out the keyboard controls. The very last
control (only) is new and not in LightTorus.
- Press arrow keys (left, right, up and down) to make the torus rotate.
- Press "s" to single step the animation,
- Press "a" to start the animation running again without stopping. (Undoes
the "s" effect.)
- Press "r" to reset the torus back to its original orientation with no
- Press "0" (zero) to zero the velocity of the torus, but leave its position
- Press "W" to increase the number of wraps, "w" to decrease the
number of wraps.
- Press "N" to increase the number of segments per wrap. "n" to
decrease the number of segments per wrap.
- Press "q" to toggle between drawing quadrangles and triangles.
- Press "p" to toggle between rendering in filled polygon mode, and in wireframe
- Press "f" to toggle between flat shading and smooth shading.
- Press "0" (zero) and "1" (one) to toggle the lights (Light #0 and
light #1) off and on.
- Press "l" to toggle local mode off and on. This command switches between
having a local viewer and a positional light and having a non-local viewer (i.e.,
positioned at a point at infinity) and a directional light.
- Press "t" to toggle the texture off and on.
- Observe the diffuse lighting, and how the lightness of the textured torus chnges with
the brightness of the diffuse lighting. Note that specular highlights are not