1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <!DOCTYPE book PUBLIC
"-//OASIS//DTD DocBook MathML Module V1.1b1//EN"
3 "http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd">
4 <refentry id=
"glDrawElementsInstanced">
9 <holder>Khronos Group
</holder>
12 <refentrytitle>glDrawElementsInstanced
</refentrytitle>
13 <manvolnum>3G
</manvolnum>
16 <refname>glDrawElementsInstanced
</refname>
17 <refpurpose>draw multiple instances of a set of elements
</refpurpose>
19 <refsynopsisdiv><title>C Specification
</title>
22 <funcdef>void
<function>glDrawElementsInstanced
</function></funcdef>
23 <paramdef>GLenum
<parameter>mode
</parameter></paramdef>
24 <paramdef>GLsizei
<parameter>count
</parameter></paramdef>
25 <paramdef>GLenum
<parameter>type
</parameter></paramdef>
26 <paramdef>const void *
<parameter>indices
</parameter></paramdef>
27 <paramdef>GLsizei
<parameter>primcount
</parameter></paramdef>
31 <refsect1 id=
"parameters"><title>Parameters
</title>
34 <term><parameter>mode
</parameter></term>
37 Specifies what kind of primitives to render.
39 <constant>GL_POINTS
</constant>,
40 <constant>GL_LINE_STRIP
</constant>,
41 <constant>GL_LINE_LOOP
</constant>,
42 <constant>GL_LINES
</constant>,
43 <constant>GL_LINE_STRIP_ADJACENCY
</constant>,
44 <constant>GL_LINES_ADJACENCY
</constant>,
45 <constant>GL_TRIANGLE_STRIP
</constant>,
46 <constant>GL_TRIANGLE_FAN
</constant>,
47 <constant>GL_TRIANGLES
</constant>,
48 <constant>GL_TRIANGLE_STRIP_ADJACENCY
</constant> and
49 <constant>GL_TRIANGLES_ADJACENCY
</constant>
55 <term><parameter>count
</parameter></term>
58 Specifies the number of elements to be rendered.
63 <term><parameter>type
</parameter></term>
66 Specifies the type of the values in
<parameter>indices
</parameter>. Must be one of
<constant>GL_UNSIGNED_BYTE
</constant>,
67 <constant>GL_UNSIGNED_SHORT
</constant>, or
<constant>GL_UNSIGNED_INT
</constant>.
72 <term><parameter>indices
</parameter></term>
75 Specifies a pointer to the location where the indices are stored.
80 <term><parameter>primcount
</parameter></term>
83 Specifies the number of instances of the specified range of indices to be rendered.
89 <refsect1 id=
"description"><title>Description
</title>
91 <function>glDrawElementsInstanced
</function> behaves identically to
<citerefentry><refentrytitle>glDrawElements
</refentrytitle></citerefentry>
92 except that
<parameter>primcount
</parameter> instances of the set of elements are executed and the value of the internal counter
93 <parameter>instanceID
</parameter> advances for each iteration.
<parameter>instanceID
</parameter> is an internal
32-bit integer counter
94 that may be read by a vertex shader as
<constant>gl_InstanceID
</constant>.
97 <function>glDrawElementsInstanced
</function> has the same effect as:
98 <programlisting><![CDATA[ if (mode, count, or type is invalid )
99 generate appropriate error
101 for (int i =
0; i < primcount ; i++) {
103 glDrawElements(mode, count, type, indices);
106 }]]
></programlisting>
109 <refsect1 id=
"notes"><title>Notes
</title>
111 <function>glDrawElementsInstanced
</function> is available only if the GL version is
3.1 or greater.
114 <constant>GL_LINE_STRIP_ADJACENCY
</constant>,
115 <constant>GL_LINES_ADJACENCY
</constant>,
116 <constant>GL_TRIANGLE_STRIP_ADJACENCY
</constant> and
117 <constant>GL_TRIANGLES_ADJACENCY
</constant>
118 are available only if the GL version is
3.2 or greater.
121 <refsect1 id=
"errors"><title>Errors
</title>
123 <constant>GL_INVALID_ENUM
</constant> is generated if
<parameter>mode
</parameter> is not one of
<constant>GL_POINTS
</constant>,
124 <constant>GL_LINE_STRIP
</constant>,
<constant>GL_LINE_LOOP
</constant>,
<constant>GL_LINES
</constant>,
125 <constant>GL_TRIANGLE_STRIP
</constant>,
<constant>GL_TRIANGLE_FAN
</constant>, or
<constant>GL_TRIANGLES
</constant>.
128 <constant>GL_INVALID_VALUE
</constant> is generated if
<parameter>count
</parameter> or
<parameter>primcount
</parameter> are negative.
131 <constant>GL_INVALID_OPERATION
</constant> is generated if a geometry shader is active and
<parameter>mode
</parameter>
132 is incompatible with the input primitive type of the geometry shader in the currently installed program object.
135 <constant>GL_INVALID_OPERATION
</constant> is generated if a non-zero buffer object name is bound to an
136 enabled array and the buffer object's data store is currently mapped.
139 <refsect1 id=
"seealso"><title>See Also
</title>
141 <citerefentry><refentrytitle>glDrawElements
</refentrytitle></citerefentry>,
142 <citerefentry><refentrytitle>glDrawArraysInstanced
</refentrytitle></citerefentry>
145 <refsect1 id=
"Copyright"><title>Copyright
</title>
147 Copyright
<trademark class=
"copyright"></trademark> 2010 Khronos Group.
148 This material may be distributed subject to the terms and conditions set forth in
149 the Open Publication License, v
1.0,
8 June
1999.
150 <ulink url=
"http://opencontent.org/openpub/">http://opencontent.org/openpub/
</ulink>.