CS312 Lab 7: Textures

 

  1. Copy the demo executables texture from ~dxu/handouts/cs312/gldemo to your own directory. Run. Note that these demonstrate legacy OpenGL texturing commands, however, they are nevertheless good to play with to learn about texture related parameters and the effects of the choice of texture coordinates. In particular, the glTextureParameteri commands, which are still valid.
  2. Copy the demo executables texcube-* and its associated textures glass.ppm, metal.ppm and kira.ppm from ~dxu/handouts/cs312/to your own directory. Run.
    1. Arrow keys to rotate cube
    2. '-'/'=' to zoom in and out
    3. 's' to stop and 'r' to reset
    4. Switch texture maps with keys '0'-'3'. '0' and '1' load the same texture, but '1' is mipmapped and '0' is not. Zoom out (a lot) to see the difference, you should see a lot of aliasing errors in '0'.
  3. Write a program to display a texture mapped cube (all 6 sides).
    1. In the handouts directory, there is a sub directory containing textures in ppm format ~dxu/handouts/cs312/ppms
    2. ppm (Portable Pixel Map) is an image file format and you can find out more about it with the unix command "man ppm"
    3. ppms can come in one of two versions, an ASCII and a corresponding binary version (i.e. the color information stored as ASCII text or as binary). The ASCII format is easier to process (since it's human-readable), but is much larger and less space-efficient than the binary version.
    4. In ~dxu/handouts/cs312/glcode there is a read_ppm.c and the associate read_ppm.h that contains two functions that will read an ASCII or binary ppm.
    5. Most image viewer such as Gimp or Irfanview (Windows) can convert a ppm from binary to ASCII and the otherway around. Some of the sample textures in the handouts directory come in both formats.
    6. Also in ~dxu/handouts/cs312/glcode the file stb_image.h is a light-weight image library that will load most other popular image formats (oddly not ppm though).