glColorPointer function

The glColorPointer function defines an array of colors.

Syntax

void WINAPI glColorPointer(
         GLint   size,
         GLenum  type,
         GLsizei stride,
   const GLvoid  *pointer
);

Parameters

size

The number of components per color. The value must be either 3 or 4.

type

The data type of each color component in a color array. Acceptable data types are specified with the following constants: GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT, GL_UNSIGNED_SHORT, GL_INT, GL_UNSIGNED_INT, GL_FLOAT, or GL_DOUBLE.

stride

The byte offset between consecutive colors. When stride is zero, the colors are tightly packed in the array.

pointer

A pointer to the first component of the first color element in a color array.

Return value

This function does not return a value.

Error codes

The following error codes can be retrieved by the glGetError function.

Name Meaning
GL_INVALID_VALUE
size was not 3 or 4.
GL_INVALID_ENUM
type was not an accepted value.
GL_INVALID_VALUE
stride or count was negative.

Remarks

The glColorPointer function specifies the location and data format of an array of color components to use when rendering. The stride parameter determines the byte offset from one color to the next, enabling the packing of vertex attributes in a single array or storage in separate arrays. In some implementations, storing vertex attributes in a single array can be more efficient than the use of separate arrays.

Enabled the color array by specifying the GL_COLOR_ARRAY constant with glEnableClientState. Calling glArrayElement, glDrawElements, or glDrawArrays uses the color array that is thus enabled. By default, the color array is disabled. The glColorPointer calls cannot by entered in display lists.

When you specify a color array using glColorPointer, the values of all the function's color array parameters are saved in a client-side state, and you can cache static array elements. Because the color array parameters are in a client-side state, glPushAttrib and glPopAttrib do not save or restore the parameters' values.

Although specifying the color array within glBegin and glend pairs does not generate an error, the results are undefined.

The following functions retrieve information related to the glColorPointer function:

glIsEnabled with argument GL_COLOR_ARRAY

glGet with argument GL_COLOR_ARRAY_SIZE

glGet with argument GL_COLOR_ARRAY_TYPE

glGet with argument GL_COLOR_ARRAY_STRIDE

glGet with argument GL_COLOR_ARRAY_COUNT

glGetPointerv with argument GL_COLOR_ARRAY_POINTER

Requirements

Requirement Value
Minimum supported client
Windows 2000 Professional [desktop apps only]
Minimum supported server
Windows 2000 Server [desktop apps only]
Header
Gl.h
Library
Opengl32.lib
DLL
Opengl32.dll

See also

glArrayElement

glBegin

glDrawArrays

glEdgeFlagPointer

glEnableClientState

glEnd

glGet

glGetString

glGetPointerv

glIndexPointer

glIsEnabled

glNormalPointer

glPopAttrib

glPushAttrib

glTexCoordPointer

glVertexPointer