Name
gl.ColorPointer -- define an array of colors
Synopsis
gl.ColorPointer(colorArray[, size])
Function
gl.ColorPointer() specifies an array of color components to use when rendering. colorArray can be either a one-dimensional table consisting of an arbitrary number of consecutive color values or a two-dimensional table consisting of an arbitrary number of subtables which contain 3 or 4 color values each. If colorArray is a one-dimensional table, you need to pass the optional size argument as well to define the size of each color component in colorArray. size must be either 3 or 4. If colorArray is a two-dimensional table, size is automatically determined by the number of items in the first subtable, which must be either three or four as well.

When using a two-dimensional table, please keep in mind that the number of color values in each subtable must be constant. It is not allowed to use differing numbers of color values in the individual subtables. The number of color values is defined by the number of elements in the first subtable and all following subtables must use the very same number of color values.

If you pass Nil in colorArray, the color array buffer will be freed but it won't be removed from OpenGL. You need to do this manually, e.g. by disabling the color array or defining a new one.

To enable and disable the color array, call gl.EnableClientState() and gl.DisableClientState() with the argument #GL_COLOR_ARRAY. If enabled, the color array is used when gl.DrawArrays(), gl.DrawElements(), or gl.ArrayElement() is called.

The color array is initially disabled and isn't accessed when gl.DrawArrays(), gl.DrawElements(), or gl.ArrayElement() is called.

Execution of gl.ColorPointer() is not allowed between the execution of gl.Begin() and the corresponding execution of gl.End(), but an error may or may not be generated. If no error is generated, the operation is undefined.

gl.ColorPointer() is typically implemented on the client side.

Color array parameters are client-side state and are therefore not saved or restored by gl.PushAttrib() and gl.PopAttrib(). Use gl.PushClientAttrib() and gl.PopClientAttrib() instead.

Please consult an OpenGL reference manual for more information.

Inputs
colorArray
one- or two-dimensional table containing color values or Nil (see above)
size
optional: size of each color component; must be either 3 or 4 and is only used with one-dimensional tables (see above)
Errors
#GL_INVALID_VALUE is generated if size is not 3 or 4.

Associated gets
gl.IsEnabled() with argument #GL_COLOR_ARRAY

gl.Get() with argument #GL_COLOR_ARRAY_SIZE

gl.Get() with argument #GL_COLOR_ARRAY_TYPE

gl.Get() with argument #GL_COLOR_ARRAY_STRIDE

gl.Get() with argument #GL_COLOR_ARRAY_POINTER


Show TOC