The glColorPointer function defines an array of colors.
void glColorPointer(
GLint size,
GLenum type,
GLsizei stride,
GLsizei count,
const GLvoid * pointer
);
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. Starting from the first color array element, count indicates the total number of static elements. You can modify static elements, but once the elements are modified, you must explicitly specify the array again before using the array for any rendering. Nonstatic color array elements are not accessed until you call glDrawArrays or glArrayElement.
The color array is enabled when you specify the GL_COLOR_ARRAY constant with glEnableClientState. Calling glArrayElement, or glDrawArrays uses the color array that is thus enabled. By default, the color array is disabled. The glColorPointer calls are not 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
The following are the error codes generated and their conditions.
Error Code | Condition |
---|---|
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. |
glArrayElement, glBegin, glDrawArrays, glEdgeFlagPointer, glEnableClientState, glEnd, glGet, glGetString, glGetPointerv, glIndexPointer, glIsEnabled, glNormalPointer, glPopAttrib, glPushAttrib, glTexCoordPointer, glVertexPointer