glColor3f (1.0, 0.0, 0.0); /* the current RGB color is red: */
/* full red, no green, no blue. */
glBegin (GL_POINTS);
glVertex3fv (point_array);
glEnd ();
voidglColor3{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);
It sets the current red, green, blue, and alpha values.
If you do not supply an alpha value, it's automatically set to 1.0.
Floating-point data types should typically range between 0.0 and 1.0, the minimum and maximum values that can be stored in the framebuffer.
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 zero 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.
| Suffix | Data Type | Minimum Value | Min Value Maps to | Maximum Value | Max Value Maps to |
|---|---|---|---|---|---|
| b | 1-byte integer | -128 | -1.0 | 127 | 1.0 |
| s | 2-byte integer | -32,768 | -1.0 | 32,767 | 1.0 |
| i | 4-byte integer | -2,147,483,648 | -1.0 | 2,147,483,647 | 1.0 |
| ub | unsigned 1-byte integer | 0 | 0.0 | 255 | 1.0 |
| us | unsigned 2-byte integer | 0 | 0.0 | 65,535 | 1.0 |
| ui | unsigned 4-byte integer | 0 | 0.0 | 4,294,967,295 | 1.0 |
This value used by glClear to clear the color buffers with glClear( GL_COLOR_BUFFER_BIT ).