CS312 Lab 6: Transparencies

 

  1. Copy the demo executable fog from ~eeaton/public/cs312/handouts/gldemo to your own directory. Run.
  2. Copy the demo executable cube-sphere from ~eeaton/public/cs312/handouts/ to your own directory. Run
  3. Copy the demo executable cube-alpha and the texture glass.ppm from ~eeaton/public/cs312/handouts/ to your own directory. Run.
  4. Write your own versions of cube-sphere and cube-alpha.
    1. Use glutSolidSphere and glutSolidCube for cube-sphere.
    2. Transparent textures are obtained using the fact that OpenGL multiplies texture color with light/material color. Thus, applying texture as usual, and specifying a translucent white material will make your texture transparent. The easiest way is to simply call glColor4f(1.0, 1.0, 1.0, 0.5); somewhere in init() and then call glEnable(GL_COLOR_MATERIAL); Enabling this automatically specifies a material that comforms to your current drawing color, specified by glColor*
    3. Remember to request the GLUT_ALPHA buffer
    4. Remember to turn on blending
    5. You may need to turn off the depth test for blending to work properly (depends on your drawing order)
    6. Experiment with source and destination alphas to get the desired effects.
  5. Submit your lab as a tarball that extracts to its own directory to ~eeaton/submit/cs312/username/.