Figure 2.9: ColorMaterial operation. Material properties are continuously updated from the current color while ColorMaterial is enabled and has the appropriate mode. Only the front material properties are included in this figure. The back material properties are treated identically.
It is possible to attach one or more material properties to the current color, so that they continuously track its component values. This behavior is enabled and disabled by calling Enable or Disable with the symbolic value COLOR_MATERIAL.
The command that controls which of these modes is selected is
void ColorMaterial ( enum face, enum mode ) ;
face is one of FRONT, BACK, or FRONT_AND_BACK, indicating whether the front material, back material, or both are affected by the current color. mode is one of EMISSION, AMBIENT, DIFFUSE, SPECULAR, or AMBIENT_AND_DIFFUSE and specifies which material property or properties track the current color. If mode is EMISSION, AMBIENT, DIFFUSE, or SPECULAR, then the value of , , or , respectively, will track the current color. If mode is AMBIENT_AND_DIFFUSE, both and track the current color. The replacements made to material properties are permanent; the replaced values remain until changed by either sending a new color or by setting a new material value when ColorMaterial is not currently enabled to override that particular value. When COLOR_MATERIAL is enabled, the indicated parameter or parameters always track the current color. For instance, calling
ColorMaterial ( FRONT, AMBIENT )
while COLOR_MATERIAL is enabled sets the front material to the value of the current color.