[ Previous | Next | Contents | Glossary | Home | Search ]
OpenGL 1.1 for AIX: Reference Manual

glColor Subroutine

Purpose

Sets the current color.

Library

OpenGL C bindings library: libGL.a

C Syntax

glColor3b, glColor3d, glColor3f, glColor3i, glColor3s,
 glColor3ub,
glColor3ui, glColor3us, glColor4b, glColor4d, glColor4f, glColor4i,
glColor4s, glColor4ub, glColor4ui, glColor4us, glColor3bv, 
glColor3dv, glColor3fv, glColor3iv, glColor3sv, glColor3ubv, 
glColor3uiv, glColor3usv, glColor4bv, glColor4dv, glColor4fv, 
glColor4iv, glColor4sv, glColor4ubv, glColor4uiv, glColor4usv
 -set the current color
void glColor3b
void glColor3b(GLbyte Red, GLbyte Green, GLbyte Blue)
void glColor3d(GLdouble Red, GLdouble Green, GLdouble Blue)
void glColor 3f(GLfloat Red, GLfloat Green, GLfloat Blue)
void glColor3i(GLint Red, GLint Green, GLint Blue)
void glColor3s(GLshort Red, GLshort Green, GLshort Blue)
void glColor3ub(GLubyte Red, GLubyte Green, GLubyte Blue)
void glColor3ui(GLuint Red, GLuint Green, GLuint Blue)
void glColor 3us(GLshort Red, GLshort Green, GLshort Blue)
void glColor4b(GLbyte Red, GLbyte Green, GLbyte Blue, GLbyte Alpha)
void glColor4d(GLdouble Red, GLdouble Green, GLdouble Blue, GLdouble Alpha)
void glColor4f(GLfloat Red, GLfloat Green, GLfloat Blue, GLfloat Alpha)
void glColor4i(GLint Red, GLint Green, GLint Blue, GLint Alpha)
void glColor 4s(GLshort Red, GLshort Green, GLshort Blue, GLshort Alpha)
void glColor4ub(GLubyte Red, GLubyte Green, GLubyte Blue, GLubyte Alpha)
void glColor4ui (GLuint Red, GLuint Green, GLuint Blue, GLuint Alpha)
void glColor4us(GLshort Red, GLshort Green, GLshort Blue, GLshort Alpha)
void glColor3bv(const GLbyte *Variable)
void glColor3dv(const GLdouble *Variable)
void glColor3fv(const GLfloat *Variable)
void glColor3iv(const GLint *Variable)
void glColor3sv(const GLshort *Variable)
void glColor3ubv(const GLubyte *Variable)
void glColor3uiv(const GLuint *Variable)
void glColor3usv(const GLushort *Variable)
void glColor4bv(const GLbyte *Variable)
void glColor4dv(const GLdouble *Variable)
void glColor4fv(const GLfloat *Variable)
void glColor4iv(const GLint *Variable)
void glColor 4sv(const GLshort *Variable)
void glColor4ubv(const GLubyte *Variable)
void glColor4uiv(const GLuint *Variable)
void glColorusv(const GLushort *Variable)

Parameters

Red Specifies a red value for the current color. The initial value is 1 (one).
Green Specifies a green value for the current color. The initial value is 1 (one).
Blue Specifies a blue value for the current color. The initial value is 1 (one).
Alpha Specifies a new alpha value for the current color. Included only in the four-argument glColor subroutine. The initial value is 1 (one).
Variable Specifies a pointer to an array that contains red, green, blue, and (sometimes) alpha values.

Description

The Graphics Library stores both a current single-valued color index and a current four-valued red, green, blue, alpha (RGBA) color. The glColor subroutine sets a new four-valued RGBA color. The glColor subroutine has two major variants: glColor3 and glColor4. glColor3 variants specify new red, green, and blue values explicitly, and set the current alpha value to 1.0 implicitly. glColor4 variants specify all four color components explicitly.

glColor3b, glColor4b, glColor3s, glColor4s, glColor3i, and glColor4i take 3 or 4 unsigned byte, short, or long integers as arguments. When v is appended to the name, the color subroutines can take a pointer to an array of such values.

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 (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. Floating-point values are mapped directly.

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

Notes

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.

Associated Gets

Associated gets for the glColor subroutine are as follows. (See the glGet subroutine for more information.)

glGet with argument GL_CURRENT_COLOR

glGet with argument GL_RGBA_MODE.

Files

/usr/include/GL/gl.h Contains C language constants, variable type definitions, and ANSI function prototypes for OpenGL.

Related Information

The glBegin subroutine, glColorPointer subroutine, glColorPointerEXT subroutine, glEnd subroutine, glIndex subroutine.

OpenGL Overview.


[ Previous | Next | Contents | Glossary | Home | Search ]