The glColorMaterial function causes a material color to track the current color.
void glColorMaterial(
GLenum face,
GLenum mode
);
The glColorMaterial function specifies which material parameters track the current color. When you enable GL_COLOR_MATERIAL, the material parameter or parameters specified by mode, of the material or materials specified by face, track the current color at all times. You enable and disable GL_COLOR_MATERIAL with the functions glEnable and glDisable, which you call with GL_COLOR_MATERIAL as their argument. By default, GL_COLOR_MATERIAL is disabled.
With glColorMaterial, you can change a subset of material parameters for each vertex using only the glColor function, without calling glMaterial. If you are going to specify only such a subset of parameters for each vertex, it is better to do so with glColorMaterial than with glMaterial.
The following functions retrieve information related to glColorMaterial:
glGet with argument GL_COLOR_MATERIAL_PARAMETER
glGet with argument GL_COLOR_MATERIAL_FACE
glIsEnabled with argument GL_COLOR_MATERIAL
The following are the error codes generated and their conditions.
Error Code | Condition |
---|---|
GL_INVALID_ENUM | face or mode was not an accepted value. |
GL_INVALID_OPERATION | glColorMaterial was called between a call to glBegin and the corresponding call to glEnd. |
Windows NT: Use version 3.5 and later.
Windows: Use Windows 95 and later.
Windows CE: Unsupported.
Header: Declared in gl.h.
Import Library: Link with opengl32.lib.
glBegin, glColor, glDisable, glEnable, glEnd, glGet, glIsEnabled, glLight, glLightModel, glMaterial