glColorPointer

[New - Windows 95, OEM Service Release 2]

The glColorPointer function defines an array of colors.

void glColorPointer(

    GLint size,

 

    GLenum type,

 

    GLsizei stride,

 

    GLsizei count,

 

    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.

count

The number of static colors, counting from the first color.

pointer

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

 

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. 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 glDrawArrays08Q9TG or glArrayElementMRW2UC.

The color array is enabled when you specify the GL_COLOR_ARRAY constant with glEnableClientState162GK9.. 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, glPushAttrib2Z6IY_ and glPopAttrib2Z6IY_ do not save or restore the parameters  values.

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

The following functions retrieve information related to the glColorPointer function:

glIsEnabled1MZ_ZK. with argument GL_COLOR_ARRAY

glGet8KNKTW 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

glGetPointervI_4O5F with argument GL_COLOR_ARRAY_POINTER

 

Error Codes

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.

 

See Also

glArrayElement, glBegin, glDrawArrays, glEdgeFlagPointer, glEnableClientState, glEnd, glGet, glGetString, glGetPointerv, glIndexPointer, glIsEnabled, glNormalPointer, glPopAttrib, glPushAttrib, glTexCoordPointer, glVertexPointer