Method GL.glColor()


Method glColor

void glColor(float|int red, float|int green, float|int blue, float|int|void alpha)
void glColor(array(float|int) v)

Description

The GL stores both a current single-valued color index and a current four-valued RGBA color. glColor sets a new four-valued RGBA color. If no alpha value has been given, 1.0 (full intensity) is implied.

Current color values are stored in floating-point format, with unspecified mantissa and exponent sizes. Unsigned integer color components, when specified, are linearly mapped to floating-point values such that the largest representable value maps to 1.0 (full intensity), and 0 maps to 0.0 (zero intensity). Signed integer color components, when specified, are linearly mapped to floating-point values such that the most positive representable value maps to 1.0, and the most negative representable value maps to -1.0. (Note that this mapping does not convert 0 precisely to 0.0.) Floating-point values are mapped directly.

Neither floating-point nor signed integer values are clamped to the range [0, 1] before the current color is updated. However, color components are clamped to this range before they are interpolated or written into a color buffer.

Parameter red
Parameter green
Parameter blue

Specify new red, green, and blue values for the current color.

Parameter alpha

Specifies a new alpha value for the current color.

Parameter v

Specifies an array that contains red, green, blue, and (sometimes) alpha values.

Note

The initial value for the current color is (1, 1, 1, 1).

The current color can be updated at any time. In particular, glColor can be called between a call to glBegin and the corresponding call to glEnd.

See also

glColorPointer, glIndex, glSecondaryColor