'\" t
.\"     Title: glDrawElementsInstanced
.\"    Author: [FIXME: author] [see http://docbook.sf.net/el/author]
.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
.\"      Date: 03/08/2011
.\"    Manual: OpenGL 3.3
.\"    Source: OpenGL 3.3
.\"  Language: English
.\"
.TH "GLDRAWELEMENTSINSTAN" "3G" "03/08/2011" "OpenGL 3.3" "OpenGL 3\&.3"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
glDrawElementsInstanced \- draw multiple instances of a set of elements
.SH "C SPECIFICATION"
.HP \w'void\ glDrawElementsInstanced('u
.BI "void glDrawElementsInstanced(GLenum\ " "mode" ", GLsizei\ " "count" ", GLenum\ " "type" ", const\ void\ *\ " "indices" ", GLsizei\ " "primcount" ");"
.SH "PARAMETERS"
.PP
\fImode\fR
.RS 4
Specifies what kind of primitives to render\&. Symbolic constants
\fBGL_POINTS\fR,
\fBGL_LINE_STRIP\fR,
\fBGL_LINE_LOOP\fR,
\fBGL_LINES\fR,
\fBGL_LINE_STRIP_ADJACENCY\fR,
\fBGL_LINES_ADJACENCY\fR,
\fBGL_TRIANGLE_STRIP\fR,
\fBGL_TRIANGLE_FAN\fR,
\fBGL_TRIANGLES\fR,
\fBGL_TRIANGLE_STRIP_ADJACENCY\fR
and
\fBGL_TRIANGLES_ADJACENCY\fR
are accepted\&.
.RE
.PP
\fIcount\fR
.RS 4
Specifies the number of elements to be rendered\&.
.RE
.PP
\fItype\fR
.RS 4
Specifies the type of the values in
\fIindices\fR\&. Must be one of
\fBGL_UNSIGNED_BYTE\fR,
\fBGL_UNSIGNED_SHORT\fR, or
\fBGL_UNSIGNED_INT\fR\&.
.RE
.PP
\fIindices\fR
.RS 4
Specifies a pointer to the location where the indices are stored\&.
.RE
.PP
\fIprimcount\fR
.RS 4
Specifies the number of instances of the specified range of indices to be rendered\&.
.RE
.SH "DESCRIPTION"
.PP

\fBglDrawElementsInstanced\fR
behaves identically to
\fBglDrawElements\fR()
except that
\fIprimcount\fR
instances of the set of elements are executed and the value of the internal counter
\fIinstanceID\fR
advances for each iteration\&.
\fIinstanceID\fR
is an internal 32\-bit integer counter that may be read by a vertex shader as
\fBgl_InstanceID\fR\&.
.PP

\fBglDrawElementsInstanced\fR
has the same effect as:
.sp
.if n \{\
.RS 4
.\}
.nf
    if (mode, count, or type is invalid )
        generate appropriate error
    else {
        for (int i = 0; i < primcount ; i++) {
            instanceID = i;
            glDrawElements(mode, count, type, indices);
        }
        instanceID = 0;
    }
.fi
.if n \{\
.RE
.\}
.sp
.SH "NOTES"
.PP

\fBglDrawElementsInstanced\fR
is available only if the GL version is 3\&.1 or greater\&.
.PP

\fBGL_LINE_STRIP_ADJACENCY\fR,
\fBGL_LINES_ADJACENCY\fR,
\fBGL_TRIANGLE_STRIP_ADJACENCY\fR
and
\fBGL_TRIANGLES_ADJACENCY\fR
are available only if the GL version is 3\&.2 or greater\&.
.SH "ERRORS"
.PP

\fBGL_INVALID_ENUM\fR
is generated if
\fImode\fR
is not one of
\fBGL_POINTS\fR,
\fBGL_LINE_STRIP\fR,
\fBGL_LINE_LOOP\fR,
\fBGL_LINES\fR,
\fBGL_TRIANGLE_STRIP\fR,
\fBGL_TRIANGLE_FAN\fR, or
\fBGL_TRIANGLES\fR\&.
.PP

\fBGL_INVALID_VALUE\fR
is generated if
\fIcount\fR
or
\fIprimcount\fR
are negative\&.
.PP

\fBGL_INVALID_OPERATION\fR
is generated if a geometry shader is active and
\fImode\fR
is incompatible with the input primitive type of the geometry shader in the currently installed program object\&.
.PP

\fBGL_INVALID_OPERATION\fR
is generated if a non\-zero buffer object name is bound to an enabled array and the buffer object\*(Aqs data store is currently mapped\&.
.SH "SEE ALSO"
.PP

\fBglDrawElements\fR(),
\fBglDrawArraysInstanced\fR()
.SH "COPYRIGHT"
.PP
Copyright
\(co
2010 Khronos Group\&. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1\&.0, 8 June 1999\&.
\m[blue]\fBhttp://opencontent\&.org/openpub/\fR\m[]\&.
