include more low-level bindings
[clinton/guile-figl.git] / upstream-man-pages / man4 / glMultiDrawElementsIndirect.xml
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="glMultiDrawElementsIndirect">
5 <refmeta>
6 <refmetainfo>
7 <copyright>
8 <year>2012</year>
9 <holder>Khronos Group.</holder>
10 </copyright>
11 </refmetainfo>
12 <refentrytitle>glMultiDrawElementsIndirect</refentrytitle>
13 <manvolnum>3G</manvolnum>
14 </refmeta>
15 <refnamediv>
16 <refname>glMultiDrawElementsIndirect</refname>
17 <refpurpose>render indexed primitives from array data, taking parameters from memory</refpurpose>
18 </refnamediv>
19 <refsynopsisdiv><title>C Specification</title>
20 <funcsynopsis>
21 <funcprototype>
22 <funcdef>void <function>glMultiDrawElementsIndirect</function></funcdef>
23 <paramdef>GLenum <parameter>mode</parameter></paramdef>
24 <paramdef>GLenum <parameter>type</parameter></paramdef>
25 <paramdef>const void *<parameter>indirect</parameter></paramdef>
26 <paramdef>GLsizei <parameter>drawcount</parameter></paramdef>
27 <paramdef>GLsizei <parameter>stride</parameter></paramdef>
28 </funcprototype>
29 </funcsynopsis>
30 </refsynopsisdiv>
31 <!-- eqn: ignoring delim $$ -->
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
51 <constant>GL_PATCHES</constant>
52 are accepted.
53 </para>
54 </listitem>
55 </varlistentry>
56 <varlistentry>
57 <term><parameter>type</parameter></term>
58 <listitem>
59 <para>
60 Specifies the type of data in the buffer bound to the <constant>GL_ELEMENT_ARRAY_BUFFER</constant> binding.
61 </para>
62 </listitem>
63 </varlistentry>
64 <varlistentry>
65 <term><parameter>indirect</parameter></term>
66 <listitem>
67 <para>
68 Specifies the address of a structure containing an array of draw parameters.
69 </para>
70 </listitem>
71 </varlistentry>
72 <varlistentry>
73 <term><parameter>drawcount</parameter></term>
74 <listitem>
75 <para>
76 Specifies the number of elements in the array addressed by <parameter>indirect</parameter>.
77 </para>
78 </listitem>
79 </varlistentry>
80 <varlistentry>
81 <term><parameter>stride</parameter></term>
82 <listitem>
83 <para>
84 Specifies the distance in basic machine units between elements of the draw parameter array.
85 </para>
86 </listitem>
87 </varlistentry>
88 </variablelist>
89 </refsect1>
90 <refsect1 id="description"><title>Description</title>
91 <para>
92 <function>glMultiDrawElementsIndirect</function> specifies multiple indexed geometric primitives
93 with very few subroutine calls. <function>glMultiDrawElementsIndirect</function> behaves
94 similarly to a multitude of calls to <citerefentry><refentrytitle>glDrawElementsInstancedBaseVertexBaseInstance</refentrytitle></citerefentry>,
95 execpt that the parameters to <citerefentry><refentrytitle>glDrawElementsInstancedBaseVertexBaseInstance</refentrytitle></citerefentry>
96 are stored in an array in memory at the address given by <parameter>indirect</parameter>, separated
97 by the stride, in basic machine units, specified by <parameter>stride</parameter>. If <parameter>stride</parameter>
98 is zero, then the array is assumed to be tightly packed in memory.
99 </para>
100 <para>
101 The parameters addressed by <parameter>indirect</parameter> are packed into a structure
102 that takes the form (in C):
103 <programlisting><![CDATA[ typedef struct {
104 uint count;
105 uint primCount;
106 uint firstIndex;
107 uint baseVertex;
108 uint baseInstance;
109 } DrawElementsIndirectCommand;]]></programlisting>
110 </para>
111 <para>
112 A single call to <function>glMultiDrawElementsIndirect</function> is equivalent, assuming no errors
113 are generated to:
114 <programlisting><![CDATA[ GLsizei n;
115 for (n = 0; n < drawcount; n++)
116 {
117 const DrawElementsIndirectCommand *cmd;
118 if (stride != 0)
119 {
120 cmd = (const DrawElementsIndirectCommand *)((uintptr)indirect + n * stride);
121 }
122 else
123 {
124 cmd = (const DrawElementsIndirectCommand *)indirect + n;
125 }
126
127 glDrawElementsInstancedBaseVertexBaseInstance(mode,
128 cmd->count,
129 type,
130 cmd->firstIndex + size-of-type,
131 cmd->primCount,
132 cmd->baseVertex,
133 cmd->baseInstance);
134 }]]></programlisting>
135 </para>
136 <para>
137 If a buffer is bound to the <constant>GL_DRAW_INDIRECT_BUFFER</constant> binding at the time
138 of a call to <function>glDrawElementsIndirect</function>, <parameter>indirect</parameter>
139 is interpreted as an offset, in basic machine units, into that buffer and the parameter
140 data is read from the buffer rather than from client memory.
141 </para>
142 <para>
143 Note that indices stored in client memory are not supported. If no buffer is bound to the
144 <constant>GL_ELEMENT_ARRAY_BUFFER</constant> binding, an error will be generated.
145 </para>
146 <para>
147 The results of the operation are undefined if the <code>reservedMustBeZero</code> member
148 of the parameter structure is non-zero. However, no error is generated in this case.
149 </para>
150 <para>
151 Vertex attributes that are modified by <function>glDrawElementsIndirect</function> have an
152 unspecified value after <function>glDrawElementsIndirect</function> returns. Attributes that aren't
153 modified remain well defined.
154 </para>
155 </refsect1>
156 <refsect1 id="notes"><title>Notes</title>
157 <para>
158 The <parameter>baseInstance</parameter> member of the <parameter>DrawElementsIndirectCommand</parameter>
159 structure is defined only if the GL version is 4.2 or greater. For versions of the GL less than 4.2,
160 this parameter is present but is reserved and should be set to zero. On earlier versions of the GL,
161 behavior is undefined if it is non-zero.
162 </para>
163 </refsect1>
164 <refsect1 id="errors"><title>Errors</title>
165 <para>
166 <constant>GL_INVALID_ENUM</constant> is generated if <parameter>mode</parameter> is not an accepted value.
167 </para>
168 <para>
169 <constant>GL_INVALID_VALUE</constant> is generated if <parameter>stride</parameter> is not a multiple
170 of four.
171 </para>
172 <para>
173 <constant>GL_INVALID_VALUE</constant> is generated if <parameter>drawcount</parameter> is negative.
174 </para>
175 <para>
176 <constant>GL_INVALID_OPERATION</constant> is generated if no buffer is bound to the <constant>GL_ELEMENT_ARRAY_BUFFER</constant>
177 binding, or if such a buffer's data store is currently mapped.
178 </para>
179 <para>
180 <constant>GL_INVALID_OPERATION</constant> is generated if a non-zero buffer object name is bound to an
181 enabled array or to the <constant>GL_DRAW_INDIRECT_BUFFER</constant> binding and the buffer object's data store is currently mapped.
182 </para>
183 <para>
184 <constant>GL_INVALID_OPERATION</constant> is generated if a geometry shader is active and <parameter>mode</parameter>
185 is incompatible with the input primitive type of the geometry shader in the currently installed program object.
186 </para>
187 <para>
188 <constant>GL_INVALID_OPERATION</constant> is generated if <parameter>mode</parameter> is <constant>GL_PATCHES</constant>
189 and no tessellation control shader is active.
190 </para>
191 </refsect1>
192 <refsect1 id="seealso"><title>See Also</title>
193 <para>
194 <citerefentry><refentrytitle>glDrawArrays</refentrytitle></citerefentry>,
195 <citerefentry><refentrytitle>glDrawArraysInstanced</refentrytitle></citerefentry>,
196 <citerefentry><refentrytitle>glDrawArraysIndirect</refentrytitle></citerefentry>,
197 <citerefentry><refentrytitle>glDrawElements</refentrytitle></citerefentry>,
198 <citerefentry><refentrytitle>glDrawRangeElements</refentrytitle></citerefentry>,
199 <citerefentry><refentrytitle>glDrawElementsIndirect</refentrytitle></citerefentry>,
200 <citerefentry><refentrytitle>glMultiDrawArraysIndirect</refentrytitle></citerefentry>
201 </para>
202 </refsect1>
203 <refsect1 id="Copyright"><title>Copyright</title>
204 <para>
205 Copyright <trademark class="copyright"></trademark> 2010-2012 Khronos Group.
206 This material may be distributed subject to the terms and conditions set forth in
207 the Open Publication License, v 1.0, 8 June 1999.
208 <ulink url="http://opencontent.org/openpub/">http://opencontent.org/openpub/</ulink>.
209 </para>
210 </refsect1>
211 </refentry>