TextureTorus

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:

  1. Before running TextureTorus, you should try out the simpler WrapTorus and LightTorus programs.  For a simpler setting illustrating the use of textures, see TextureBMP.
  2. Compile and run the program.  Test out the keyboard controls.  The very last control (only) is new and not in LightTorus.
    1. Press arrow keys (left, right, up and down) to make the torus rotate.
    2. Press "s" to single step the animation,
    3. Press "a" to start the animation running again without stopping.  (Undoes the "s" effect.)
    4. Press "r" to reset the torus back to its original orientation with no velocity.
    5. Press "0" (zero) to zero the velocity of the torus, but leave its position fixed.
    6. Press "W" to increase the number of wraps,  "w" to decrease the number of wraps.
    7. Press "N" to increase the number of segments per wrap.  "n" to decrease the number of segments per wrap.
    8. Press "q" to toggle between drawing quadrangles and triangles.
    9. Press "p" to toggle between rendering in filled polygon mode, and in wireframe mode.
    10. Press "f" to toggle between flat shading and smooth shading.
    11. Press "0" (zero) and "1" (one) to toggle the lights (Light #0 and light #1) off and on.
    12. 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.
    13. Press "t" to toggle the texture off and on.
  3. 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 visible..