glVertexPointer

The glVertexPointer function defines an array of vertex data.

void glVertexPointer(
  GLint size,             
  GLenum type,            
  GLsizei stride,         
  GLsizei count,          
  const GLvoid *pointer   
);
 

Parameters

size
The number of coordinates per vertex. The value of size must be 2, 3, or 4.
type
The data type of each coordinate in the array using the following symbolic constants: GL_SHORT, GL_INT, GL_FLOAT, and GL_DOUBLE.
stride
The byte offset between consecutive vertices. When stride is zero, the vertices are tightly packed in the array.
count
The number of vertices, counting from the first, that are static.
pointer
A pointer to the first coordinate of the first vertex in the array.

Remarks

The glVertexPointer function specifies the location and data of an array of vertex coordinates to use when rendering. The size parameter specifies the number of coordinates per vertex. The type parameter specifies the data type of each vertex coordinate. The stride parameter determines the byte offset from one vertex to the next, enabling the packing of vertices and attributes in a single array or storage in separate arrays. In some implementations, storing the vertices and attributes in a single array can be more efficient than using separate arrays. Starting from the first vertex element, the count parameter indicates the total number of static elements. Your application can modify static elements, but once the elements are modified, the application must explicitly specify the array again before using the array for any rendering. Non-static array elements are not accessed until you call glDrawArrays or glArrayElement.

A vertex array is enabled when you specify the GL_VERTEX_ARRAY constant with glEnableClientState. When enabled, glDrawArrays and glArrayElement use the vertex array. By default, the vertex array is disabled.

You cannot include glVertexPointer in display lists.

When you specify a vertex array using glVertexPointer, the values of all the function's vertex array parameters are saved in a client-side state and static array elements can be cached. Because the vertex array parameters are client-side state, their values are not saved or restored by glPushAttrib and glPopAttrib.

Although no error is generated if you call glVertexPointer within glBegin and glEnd pairs, the results are undefined.

The following functions retrieve information related to glVertexPointer:

glGet with argument GL_VERTEX_ARRAY_SIZE

glGet with argument GL_VERTEX_ARRAY_STRIDE

glGet with argument GL_VERTEX_ARRAY_COUNT

glGet with argument GL_VERTEX_ARRAY_TYPE

glGetPointerv with argument GL_VERTEX_ARRAY_POINTER

glIsEnabled with argument GL_VERTEX_ARRAY

Error Codes

The following are the error codes generated and their conditions.

Error Code Condition
GL_INVALID_VALUE size was not 2, 3, or 4.
GL_INVALID_ENUM type was not an accepted value.
GL_INVALID_VALUE stride or count was negative.

See Also

glArrayElement, glColorPointer, glDrawArrays, glEdgeFlagPointer, glEnableClientState, glGetPointerv, glGetString, glIndexPointer, glIsEnabled, glNormalPointer, glTexCoordPointer