Commit | Line | Data |
---|---|---|
7faf1d71 AW |
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="glDrawElementsInstancedBaseInstance"> | |
5 | <refmeta> | |
6 | <refmetainfo> | |
7 | <copyright> | |
8 | <year>2011</year> | |
9 | <holder>Khronos Group</holder> | |
10 | </copyright> | |
11 | </refmetainfo> | |
12 | <refentrytitle>glDrawElementsInstancedBaseInstance</refentrytitle> | |
13 | <manvolnum>3G</manvolnum> | |
14 | </refmeta> | |
15 | <refnamediv> | |
16 | <refname>glDrawElementsInstancedBaseInstance</refname> | |
17 | <refpurpose>draw multiple instances of a set of elements with offset applied to instanced attributes</refpurpose> | |
18 | </refnamediv> | |
19 | <refsynopsisdiv><title>C Specification</title> | |
20 | <funcsynopsis> | |
21 | <funcprototype> | |
22 | <funcdef>void <function>glDrawElementsInstancedBaseInstance</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> | |
28 | <paramdef>GLuitn <parameter>baseinstance</parameter></paramdef> | |
29 | </funcprototype> | |
30 | </funcsynopsis> | |
31 | </refsynopsisdiv> | |
32 | <refsect1 id="parameters"><title>Parameters</title> | |
33 | <variablelist> | |
34 | <varlistentry> | |
35 | <term><parameter>mode</parameter></term> | |
36 | <listitem> | |
37 | <para> | |
38 | Specifies what kind of primitives to render. | |
39 | Symbolic constants | |
40 | <constant>GL_POINTS</constant>, | |
41 | <constant>GL_LINE_STRIP</constant>, | |
42 | <constant>GL_LINE_LOOP</constant>, | |
43 | <constant>GL_LINES</constant>, | |
44 | <constant>GL_LINE_STRIP_ADJACENCY</constant>, | |
45 | <constant>GL_LINES_ADJACENCY</constant>, | |
46 | <constant>GL_TRIANGLE_STRIP</constant>, | |
47 | <constant>GL_TRIANGLE_FAN</constant>, | |
48 | <constant>GL_TRIANGLES</constant>, | |
49 | <constant>GL_TRIANGLE_STRIP_ADJACENCY</constant>, | |
50 | <constant>GL_TRIANGLES_ADJACENCY</constant> and <constant>GL_PATCHES</constant> | |
51 | are accepted. | |
52 | </para> | |
53 | </listitem> | |
54 | </varlistentry> | |
55 | <varlistentry> | |
56 | <term><parameter>count</parameter></term> | |
57 | <listitem> | |
58 | <para> | |
59 | Specifies the number of elements to be rendered. | |
60 | </para> | |
61 | </listitem> | |
62 | </varlistentry> | |
63 | <varlistentry> | |
64 | <term><parameter>type</parameter></term> | |
65 | <listitem> | |
66 | <para> | |
67 | Specifies the type of the values in <parameter>indices</parameter>. Must be one of <constant>GL_UNSIGNED_BYTE</constant>, | |
68 | <constant>GL_UNSIGNED_SHORT</constant>, or <constant>GL_UNSIGNED_INT</constant>. | |
69 | </para> | |
70 | </listitem> | |
71 | </varlistentry> | |
72 | <varlistentry> | |
73 | <term><parameter>indices</parameter></term> | |
74 | <listitem> | |
75 | <para> | |
76 | Specifies a pointer to the location where the indices are stored. | |
77 | </para> | |
78 | </listitem> | |
79 | </varlistentry> | |
80 | <varlistentry> | |
81 | <term><parameter>primcount</parameter></term> | |
82 | <listitem> | |
83 | <para> | |
84 | Specifies the number of instances of the specified range of indices to be rendered. | |
85 | </para> | |
86 | </listitem> | |
87 | </varlistentry> | |
88 | <varlistentry> | |
89 | <term><parameter>baseinstance</parameter></term> | |
90 | <listitem> | |
91 | <para> | |
92 | Specifies the base instance for use in fetching instanced vertex attributes. | |
93 | </para> | |
94 | </listitem> | |
95 | </varlistentry> | |
96 | </variablelist> | |
97 | </refsect1> | |
98 | <refsect1 id="description"><title>Description</title> | |
99 | <para> | |
100 | <function>glDrawElementsInstancedBaseInstance</function> behaves identically to <citerefentry><refentrytitle>glDrawElements</refentrytitle></citerefentry> | |
101 | except that <parameter>primcount</parameter> instances of the set of elements are executed and the value of the internal counter | |
102 | <parameter>instanceID</parameter> advances for each iteration. <parameter>instanceID</parameter> is an internal 32-bit integer counter | |
103 | that may be read by a vertex shader as <constant>gl_InstanceID</constant>. | |
104 | </para> | |
105 | <para> | |
106 | <function>glDrawElementsInstancedBaseInstance</function> has the same effect as: | |
107 | <programlisting><![CDATA[ if (mode, count, or type is invalid ) | |
108 | generate appropriate error | |
109 | else { | |
110 | for (int i = 0; i < primcount ; i++) { | |
111 | instanceID = i; | |
112 | glDrawElements(mode, count, type, indices); | |
113 | } | |
114 | instanceID = 0; | |
115 | }]]></programlisting> | |
116 | </para> | |
117 | <para> | |
118 | Specific vertex attributes may be classified as <emphasis>instanced</emphasis> through the use of | |
119 | <citerefentry><refentrytitle>glVertexAttribDivisor</refentrytitle></citerefentry>. Instanced vertex attributes | |
120 | supply per-instance vertex data to the vertex shader. The index of the vertex fetched from the enabled instanced vertex | |
121 | attribute arrays is calculated as | |
122 | <mml:math> | |
123 | <mml:mrow> | |
124 | <mml:mfenced open = '⌊' close = '⌋'> | |
125 | <mml:mfrac> | |
126 | <mml:mrow> | |
127 | <mml:mi>gl</mml:mi> | |
128 | <mml:mo>_</mml:mo> | |
129 | <mml:mi>InstanceID</mml:mi> | |
130 | </mml:mrow> | |
131 | <mml:mi>divisor</mml:mi> | |
132 | </mml:mfrac> | |
133 | </mml:mfenced> | |
134 | <mml:mo lspace='2px' rspace='2px'>+</mml:mo> | |
135 | <mml:mi>baseInstance</mml:mi> | |
136 | </mml:mrow> | |
137 | </mml:math>. Note that <parameter>baseinstance</parameter> does not affect the shader-visible value of <constant>gl_InstanceID</constant>. | |
138 | </para> | |
139 | </refsect1> | |
140 | <refsect1 id="notes"><title>Notes</title> | |
141 | <para> | |
142 | <function>glDrawElementsInstancedBaseInstance</function> is available only if the GL version is 4.2 or greater. | |
143 | </para> | |
144 | <para> | |
145 | <constant>GL_LINE_STRIP_ADJACENCY</constant>, | |
146 | <constant>GL_LINES_ADJACENCY</constant>, | |
147 | <constant>GL_TRIANGLE_STRIP_ADJACENCY</constant> and | |
148 | <constant>GL_TRIANGLES_ADJACENCY</constant> | |
149 | are available only if the GL version is 3.2 or greater. | |
150 | </para> | |
151 | </refsect1> | |
152 | <refsect1 id="errors"><title>Errors</title> | |
153 | <para> | |
154 | <constant>GL_INVALID_ENUM</constant> is generated if <parameter>mode</parameter> is not one of <constant>GL_POINTS</constant>, | |
155 | <constant>GL_LINE_STRIP</constant>, <constant>GL_LINE_LOOP</constant>, <constant>GL_LINES</constant>, | |
156 | <constant>GL_TRIANGLE_STRIP</constant>, <constant>GL_TRIANGLE_FAN</constant>, or <constant>GL_TRIANGLES</constant>. | |
157 | </para> | |
158 | <para> | |
159 | <constant>GL_INVALID_VALUE</constant> is generated if <parameter>count</parameter> or <parameter>primcount</parameter> are negative. | |
160 | </para> | |
161 | <para> | |
162 | <constant>GL_INVALID_OPERATION</constant> is generated if a geometry shader is active and <parameter>mode</parameter> | |
163 | is incompatible with the input primitive type of the geometry shader in the currently installed program object. | |
164 | </para> | |
165 | <para> | |
166 | <constant>GL_INVALID_OPERATION</constant> is generated if a non-zero buffer object name is bound to an | |
167 | enabled array and the buffer object's data store is currently mapped. | |
168 | </para> | |
169 | </refsect1> | |
170 | <refsect1 id="seealso"><title>See Also</title> | |
171 | <para> | |
172 | <citerefentry><refentrytitle>glDrawElements</refentrytitle></citerefentry>, | |
173 | <citerefentry><refentrytitle>glDrawArraysInstanced</refentrytitle></citerefentry> | |
174 | </para> | |
175 | </refsect1> | |
176 | <refsect1 id="Copyright"><title>Copyright</title> | |
177 | <para> | |
178 | Copyright <trademark class="copyright"></trademark> 2011 Khronos Group. | |
179 | This material may be distributed subject to the terms and conditions set forth in | |
180 | the Open Publication License, v 1.0, 8 June 1999. | |
181 | <ulink url="http://opencontent.org/openpub/">http://opencontent.org/openpub/</ulink>. | |
182 | </para> | |
183 | </refsect1> | |
184 | </refentry> |