Graphics Reference
In-Depth Information
to the OpenGL ES engine. To render using an instanced draw call, use the
following commands:
void
glDrawArraysInstanced
(GLenum
mode,
GLint
first,
GLsizei
count,
GLsizei
instanceCount
)
void
glDrawElementsInstanced
(GLenum
mode,
GLsizei
count,
GLenum
type,
const GLvoid
*indices,
GLsizei
instanceCount
)
mode
specifies the primitive to render; valid values are
GL_POINTS
GL_LINES
GL_LINE_STRIP
GL_LINE_LOOP
GL_TRIANGLES
GL_TRIANGLE_STRIP
GL_TRIANGLE_FAN
first
specifies the starting vertex index in the enabled vertex arrays
(
glDrawArraysInstanced
only)
count
specifies the number of indices to be drawn
type
specifies the type of element indices stored in
indices
(
glDrawElementsInstanced
only);
valid values are
GL_UNSIGNED_BYTE
GL_UNSIGNED_SHORT
GL_UNSIGNED_INT
indices
specifies a pointer to the location where element indices are stored
(
glDrawElementsInstanced
only)
instanceCount
specifies the number of instances of the primitive to be
drawn
Two methods may be used to access per-instance data. The first method is
to instruct OpenGL ES to read vertex attributes once or multiple times per
instance using the following command:
void
glVertexAttribDivisor
(GLuint
index,
GLuint
divisor
)
index
specifies the index of the generic vertex attribute
divisor
specifies the number of instances that will pass between
updates of the generic attribute at slot
index