Name
gl.ColorMaterial -- cause a material color to track the current color
Synopsis
gl.ColorMaterial(face, mode)
Function
gl.ColorMaterial() specifies which material parameters track the current color. When #GL_COLOR_MATERIAL is enabled, the material parameter or parameters specified by mode, of the material or materials specified by face, track the current color at all times. face can be set to #GL_FRONT, #GL_BACK, or #GL_FRONT_AND_BACK. The initial value is #GL_FRONT_AND_BACK.

The following values can be passed in the mode parameter: #GL_EMISSION, #GL_AMBIENT, #GL_DIFFUSE, #GL_SPECULAR, and #GL_AMBIENT_AND_DIFFUSE. The initial value is #GL_AMBIENT_AND_DIFFUSE.

To enable and disable #GL_COLOR_MATERIAL, call gl.Enable() and gl.Disable() with argument #GL_COLOR_MATERIAL. #GL_COLOR_MATERIAL is initially disabled.

gl.ColorMaterial() makes it possible to change a subset of material parameters for each vertex using only the gl.Color() command, without calling gl.Material(). If only such a subset of parameters is to be specified for each vertex, calling gl.ColorMaterial() is preferable to calling gl.Material().

Call gl.ColorMaterial() before enabling #GL_COLOR_MATERIAL.

Calling gl.DrawElements() or gl.DrawArrays() may leave the current color indeterminate, if the color array is enabled. If gl.ColorMaterial() is enabled while the current color is indeterminate, the lighting material state specified by face and mode is also indeterminate.

If the GL version is 1.1 or greater, and #GL_COLOR_MATERIAL is enabled, evaluated color values affect the results of the lighting equation as if the current color were being modified, but no change is made to the tracking lighting parameter of the current color.

Please consult an OpenGL reference manual for more information.

Inputs
face
specifies whether front, back, or both front and back material parameters should track the current color
mode
specifies which of several material parameters track the current color (see above)
Errors
#GL_INVALID_ENUM is generated if face or mode is not an accepted value.

#GL_INVALID_OPERATION is generated if gl.ColorMaterial() is executed between the execution of gl.Begin() and the corresponding execution of gl.End()

Associated gets
gl.IsEnabled() with argument #GL_COLOR_MATERIAL

gl.Get() with argument #GL_COLOR_MATERIAL_PARAMETER

gl.Get() with argument #GL_COLOR_MATERIAL_FACE


Show TOC