glDrawElements Function

Syntax

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

Arguments

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_OPERATIONThe mode argument was either set to GL_GEOMETRY_PRIMITIVE_DMP when a geometry shader had not been linked to the current program, or it was set to a value other than GL_GEOMETRY_PRIMITIVE_DMP when a geometry shader had been linked to the current program.

Revision History

2010/01/07
Initial version.

CONFIDENTIAL