glDrawElements

glDrawElements Function

Syntax

GL_APICALL void GL_APIENTRY glDrawElements(
     GLenum mode,
     GLsizei count,
     GLenum type,
     const void * indices
);

Parameters

Name Description
in mode Primitive mode
in count Amount of vertex data to render
in type Data type for the vertex indices
in indices Pointer to a vertex index, or offset to the region to start using within the vertex indices

Return Values

No values are returned.

Description

Uses vertex indices to render primitives.

Uses a vertex index array to access an array of vertex data. Set mode to one of the following values when the geometry shader is not in use.
GL_TRIANGLES Triangles
GL_TRIANGLE_STRIP Triangle strip
GL_TRIANGLE_FAN Triangle fan

Specify a value of GL_GEOMETRY_PRIMITIVE_DMP when the geometry shader is in use.

Set type to the type of the vertex index array. Specify a value of GL_UNSIGNED_BYTE or GL_UNSIGNED_SHORT.

When vertex buffer objects are not in use, set indices with a pointer to the vertex indices. When vertex buffer objects are in use, set indices with the offset to the region to start using within the vertex indices.

This function generates the following errors.
GL_INVALID_ENUMThe mode or type argument was set to an invalid value.
GL_INVALID_FRAMEBUFFER_OPERATIONThe framebuffer was configured incorrectly.
GL_INVALID_OPERATIONThis function was called without any command-list objects bound.
GL_INVALID_OPERATIONGL_GEOMETRY_PRIMITIVE_DMP is specified for mode and a geometry shader is not linked to the current program
GL_GEOMETRY_PRIMITIVE_DMP is specified for mode and a geometry shader is linked to the current program
The specified number of vertex attributes exceeds the maximum allowed (Note 1)
Placement restrictions on vertex data are violated (Note 2)

Note 1: Maximum of 16 when not using a vertex buffer, and a maximum of 12 when using a vertex buffer
Note2: When using a vertex buffer and 12 vertex attributes are used as vertex arrays (when glEnableVertexAttribArray is called on all vertex attributes)

Also, because this function performs a process for each state corresponding to nngxValidateState, when using the gl API, an error may occur for reasons not listed above. In this case, it is possible to narrow down the reason for the error by calling the nngxValidateState function for each state before calling this function.

Revision History

2011/12/02
Added information related to vertex attributes as causes of the GL_INVALID_OPERATION error.
2011/06/15
Added internal processes and how to check error causes
2010/01/07
Initial version.

CONFIDENTIAL