JavaScript EditorFree JavaScript Editor     Ajax Editor 

Main Page
Previous Page
Next Page



glVertexAttribPointer Defines a generic vertex attribute array

C Specification

void glVertexAttribPointer(GLuint index,
                           GLint size,
                           GLenum type,
                           GLboolean normalized,
                           GLsizei stride,
                           const GLvoid *pointer)



Specifies the index of the generic vertex attribute to be modified.


Specifies the number of values for each element of the generic vertex attribute array. Must be 1, 2, 3, or 4.


Specifies the data type of each component in the array. Symbolic constants GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT, GL_UNSIGNED_SHORT, GL_INT, GL_UNSIGNED_INT, GL_FLOAT, and GL_DOUBLE are accepted.


Specifies whether fixed-point data values should be normalized (GL_TRUE) or converted directly as fixed-point values (GL_FALSE) when they are accessed.


Specifies the byte offset between consecutive attribute values. If stride is 0 (the initial value), the attribute values are understood to be tightly packed in the array.


Specifies a pointer to the first component of the first attribute value in the array.


glVertexAttribPointer specifies the location and data format of an array of generic vertex attribute values to use when rendering. size specifies the number of components per attribute and must be 1, 2, 3, or 4. type specifies the data type of each component, and stride specifies the byte stride from one attribute to the next, allowing attribute values to be intermixed with other attribute values or stored in a separate array. A value of 0 for stride means that the values are stored sequentially in memory with no gaps between successive elements. If set to GL_TRUE, normalized means that values stored in an integer format are to be mapped to the range [1,1] (for signed values) or [0,1] (for unsigned values) when they are accessed and converted to floating point. Otherwise, values are converted to floats directly without normalization.

When a generic vertex attribute array is specified, size, type, normalized, stride, and pointer are saved as client-side state.

To enable and disable the generic vertex attribute array, call glEnableVertexAttribArray and glDisableVertexAttribArray with index. If enabled, the generic vertex attribute array is used when glDrawArrays, glDrawElements, glDrawRangeElements, glArrayElement, glMultiDrawElements, or glMultiDrawArrays is called.


glVertexAttribPointer is available only if the GL version is 2.0 or greater.

Each generic vertex attribute array is initially disabled and is not accessed when glDrawArrays, glDrawElements, glDrawRangeElements, glArrayElement, glMultiDrawElements, or glMultiDrawArrays is called.

Execution of glVertexAttribPointer is not allowed between the execution of glBegin and glEnd, but an error may or may not be generated. If no error is generated, the operation is undefined.

glVertexAttribPointer is typically implemented on the client side.

Generic vertex attribute array parameters are client-side state and are therefore not saved or restored by glPushAttrib and glPopAttrib. Use glPushClientAttrib and glPopClientAttrib instead.


GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.

GL_INVALID_VALUE is generated if size is not 1, 2, 3, or 4.

GL_INVALID_ENUM is generated if type is not an accepted value.

GL_INVALID_VALUE is generated if stride is negative.

Associated Gets

glGet with argument GL_MAX_VERTEX_ATTRIBS

glGetVertexAttrib with arguments index and the name of a vertex attribute parameter

glGetVertexAttribPointer with arguments index and GL_VERTEX_ATTRIB_ARRAY_POINTER

See Also

glArrayElement, glBindAttribLocation, glDisableVertexAttribArray, glDrawArrays, glDrawElements, glDrawRangeElements, glEnableVertexAttribArray, glMultiDrawArrays, glMultiDrawElements, glPopClientAttrib, glPushClientAttrib, glVertexAttrib

Previous Page
Next Page

JavaScript EditorAjax Editor     JavaScript Editor