Choosing RGBA vs Color Index Mode
  • Most of the time RGBA is the obvious choice
    • Advanced OGL features (lighting, texturing, fog ....)  are supported
  •  Certain circumstances may encourage CI mode
    • Limited HW visuals (fewer shades of a single component)
    • Color map animation

     

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  Switching  between CI and RGB mode
  • Unfortunately, you can't 
    • A window is bound to a visual during initalization
    • Separate windows may be specified however ...

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  Specifying Color
  • The current color is an OpenGL state variable
    •  
      set_color(RED); 
      draw_item(A); 
      draw_item(B); 
      set_color(GREEN); 
      set_color(BLUE); 
      draw_item(C);
  •  RGBA Mode:
    •  
      void glColor3{b s i f d ub us ui} (TYPEr, TYPEg, TYPEb); 
      void glColor4{b s i f d ub us ui} (TYPEr, TYPEg, TYPEb, TYPEa); 
      void glColor3{b s i f d ub us ui}v (const TYPE*v); 
      void glColor4{b s i f d ub us ui}v (const TYPE*v);
  •  Color Index Mode
    •  
      void glIndex{sifd ub}(TYPE c); 
      void glIndex{sifd ub}v(const TYPE *c);

      Clear color:

      void glClearIndex(GLfloat cindex);


    NOTE!  There are NO OpenGL commands to load colormap table values (this is a function of the window manager).  The GLUT API provides glutSetColor() to interface with the WM.
     


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  Specifying a Shading Model
  • How an object is colored is specified with glShadeModel ( GL_SMOOTH| GL_FLAT)
  •  Smooth shading will interpolate the vertex values across the polygon with Gouraud shading
  • This can be problimatic for CI mode (choose your colormap carefully!)
  • Flat shading will color the entire primitive the same color


  • Image from: http://www.cognivis.com/book/rend.htm
     
     
     
     
     
     
     

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  Homework
  • Modify the glutSpin application to render the color of each vertex based on its height 
  •  Extra credit:  
    • carefully choose colors which enhance the perception of the shape of the surface
    • Modify the color array to determine your ability to discriminate shades

     
     
     
     
     
     

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  End of Presentation
  • Fin 6
  •  

  •  
  •  

  •  

     
     
     
     
     
     
     


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  End of Presentation
  • Fin 7
  •  

  •  
  •  

  •  

     
     
     
     
     
     
     


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  End of Presentation
  • Fin 8
  •  

  •  
  •  

  •  

     
     
     
     
     
     
     


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  End of Presentation
  • Fin 9
  •  

  •  
  •  

  •  

     
     
     
     
     
     
     


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

  End of Presentation
  • Fin 10
  •  

  •  
  •  

  •