Commit | Line | Data |
---|---|---|
7faf1d71 AW |
1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "xhtml1-transitional.dtd"> | |
3 | <!-- saved from url=(0013)about:internet --> | |
4 | <?xml-stylesheet type="text/xsl" href="mathml.xsl"?><html xmlns="http://www.w3.org/1999/xhtml" xmlns:pref="http://www.w3.org/2002/Math/preference" pref:renderer="mathplayer-dl"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><link rel="stylesheet" type="text/css" href="opengl-man.css" /><title>glMultiDrawElementsIndirect - OpenGL 4 Reference Pages</title><meta name="generator" content="DocBook XSL Stylesheets V1.69.1" /></head><body><div class="refentry" lang="en" xml:lang="en"><a id="glMultiDrawElementsIndirect"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>glMultiDrawElementsIndirect — render indexed primitives from array data, taking parameters from memory</p></div><div class="refsynopsisdiv"><h2>C Specification</h2><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0"><tr><td><code class="funcdef">void <b class="fsfunc">glMultiDrawElementsIndirect</b>(</code></td><td>GLenum </td><td><var class="pdparam">mode</var>, </td></tr><tr><td> </td><td>GLenum </td><td><var class="pdparam">type</var>, </td></tr><tr><td> </td><td>const void * </td><td><var class="pdparam">indirect</var>, </td></tr><tr><td> </td><td>GLsizei </td><td><var class="pdparam">drawcount</var>, </td></tr><tr><td> </td><td>GLsizei </td><td><var class="pdparam">stride</var><code>)</code>;</td></tr></table></div></div><div class="refsect1" lang="en" xml:lang="en"><a id="parameters"></a><h2>Parameters</h2><div class="variablelist"><dl><dt><span class="term"><em class="parameter"><code>mode</code></em></span></dt><dd><p> | |
5 | Specifies what kind of primitives to render. | |
6 | Symbolic constants | |
7 | <code class="constant">GL_POINTS</code>, | |
8 | <code class="constant">GL_LINE_STRIP</code>, | |
9 | <code class="constant">GL_LINE_LOOP</code>, | |
10 | <code class="constant">GL_LINES</code>, | |
11 | <code class="constant">GL_LINE_STRIP_ADJACENCY</code>, | |
12 | <code class="constant">GL_LINES_ADJACENCY</code>, | |
13 | <code class="constant">GL_TRIANGLE_STRIP</code>, | |
14 | <code class="constant">GL_TRIANGLE_FAN</code>, | |
15 | <code class="constant">GL_TRIANGLES</code>, | |
16 | <code class="constant">GL_TRIANGLE_STRIP_ADJACENCY</code>, | |
17 | <code class="constant">GL_TRIANGLES_ADJACENCY</code>, and | |
18 | <code class="constant">GL_PATCHES</code> | |
19 | are accepted. | |
20 | </p></dd><dt><span class="term"><em class="parameter"><code>type</code></em></span></dt><dd><p> | |
21 | Specifies the type of data in the buffer bound to the <code class="constant">GL_ELEMENT_ARRAY_BUFFER</code> binding. | |
22 | </p></dd><dt><span class="term"><em class="parameter"><code>indirect</code></em></span></dt><dd><p> | |
23 | Specifies the address of a structure containing an array of draw parameters. | |
24 | </p></dd><dt><span class="term"><em class="parameter"><code>drawcount</code></em></span></dt><dd><p> | |
25 | Specifies the number of elements in the array addressed by <em class="parameter"><code>indirect</code></em>. | |
26 | </p></dd><dt><span class="term"><em class="parameter"><code>stride</code></em></span></dt><dd><p> | |
27 | Specifies the distance in basic machine units between elements of the draw parameter array. | |
28 | </p></dd></dl></div></div><div class="refsect1" lang="en" xml:lang="en"><a id="description"></a><h2>Description</h2><p> | |
29 | <code class="function">glMultiDrawElementsIndirect</code> specifies multiple indexed geometric primitives | |
30 | with very few subroutine calls. <code class="function">glMultiDrawElementsIndirect</code> behaves | |
31 | similarly to a multitude of calls to <a href="glDrawElementsInstancedBaseVertexBaseInstance.xml"><span class="citerefentry"><span class="refentrytitle">glDrawElementsInstancedBaseVertexBaseInstance</span></span></a>, | |
32 | execpt that the parameters to <a href="glDrawElementsInstancedBaseVertexBaseInstance.xml"><span class="citerefentry"><span class="refentrytitle">glDrawElementsInstancedBaseVertexBaseInstance</span></span></a> | |
33 | are stored in an array in memory at the address given by <em class="parameter"><code>indirect</code></em>, separated | |
34 | by the stride, in basic machine units, specified by <em class="parameter"><code>stride</code></em>. If <em class="parameter"><code>stride</code></em> | |
35 | is zero, then the array is assumed to be tightly packed in memory. | |
36 | </p><p> | |
37 | The parameters addressed by <em class="parameter"><code>indirect</code></em> are packed into a structure | |
38 | that takes the form (in C): | |
39 | </p><pre class="programlisting"> typedef struct { | |
40 | uint count; | |
41 | uint primCount; | |
42 | uint firstIndex; | |
43 | uint baseVertex; | |
44 | uint baseInstance; | |
45 | } DrawElementsIndirectCommand;</pre><p> | |
46 | </p><p> | |
47 | A single call to <code class="function">glMultiDrawElementsIndirect</code> is equivalent, assuming no errors | |
48 | are generated to: | |
49 | </p><pre class="programlisting"> GLsizei n; | |
50 | for (n = 0; n < drawcount; n++) | |
51 | { | |
52 | const DrawElementsIndirectCommand *cmd; | |
53 | if (stride != 0) | |
54 | { | |
55 | cmd = (const DrawElementsIndirectCommand *)((uintptr)indirect + n * stride); | |
56 | } | |
57 | else | |
58 | { | |
59 | cmd = (const DrawElementsIndirectCommand *)indirect + n; | |
60 | } | |
61 | ||
62 | glDrawElementsInstancedBaseVertexBaseInstance(mode, | |
63 | cmd->count, | |
64 | type, | |
65 | cmd->firstIndex + size-of-type, | |
66 | cmd->primCount, | |
67 | cmd->baseVertex, | |
68 | cmd->baseInstance); | |
69 | }</pre><p> | |
70 | </p><p> | |
71 | If a buffer is bound to the <code class="constant">GL_DRAW_INDIRECT_BUFFER</code> binding at the time | |
72 | of a call to <code class="function">glDrawElementsIndirect</code>, <em class="parameter"><code>indirect</code></em> | |
73 | is interpreted as an offset, in basic machine units, into that buffer and the parameter | |
74 | data is read from the buffer rather than from client memory. | |
75 | </p><p> | |
76 | Note that indices stored in client memory are not supported. If no buffer is bound to the | |
77 | <code class="constant">GL_ELEMENT_ARRAY_BUFFER</code> binding, an error will be generated. | |
78 | </p><p> | |
79 | The results of the operation are undefined if the <code class="code">reservedMustBeZero</code> member | |
80 | of the parameter structure is non-zero. However, no error is generated in this case. | |
81 | </p><p> | |
82 | Vertex attributes that are modified by <code class="function">glDrawElementsIndirect</code> have an | |
83 | unspecified value after <code class="function">glDrawElementsIndirect</code> returns. Attributes that aren't | |
84 | modified remain well defined. | |
85 | </p></div><div class="refsect1" lang="en" xml:lang="en"><a id="notes"></a><h2>Notes</h2><p> | |
86 | The <em class="parameter"><code>baseInstance</code></em> member of the <em class="parameter"><code>DrawElementsIndirectCommand</code></em> | |
87 | structure is defined only if the GL version is 4.2 or greater. For versions of the GL less than 4.2, | |
88 | this parameter is present but is reserved and should be set to zero. On earlier versions of the GL, | |
89 | behavior is undefined if it is non-zero. | |
90 | </p></div><div class="refsect1" lang="en" xml:lang="en"><a id="errors"></a><h2>Errors</h2><p> | |
91 | <code class="constant">GL_INVALID_ENUM</code> is generated if <em class="parameter"><code>mode</code></em> is not an accepted value. | |
92 | </p><p> | |
93 | <code class="constant">GL_INVALID_VALUE</code> is generated if <em class="parameter"><code>stride</code></em> is not a multiple | |
94 | of four. | |
95 | </p><p> | |
96 | <code class="constant">GL_INVALID_VALUE</code> is generated if <em class="parameter"><code>drawcount</code></em> is negative. | |
97 | </p><p> | |
98 | <code class="constant">GL_INVALID_OPERATION</code> is generated if no buffer is bound to the <code class="constant">GL_ELEMENT_ARRAY_BUFFER</code> | |
99 | binding, or if such a buffer's data store is currently mapped. | |
100 | </p><p> | |
101 | <code class="constant">GL_INVALID_OPERATION</code> is generated if a non-zero buffer object name is bound to an | |
102 | enabled array or to the <code class="constant">GL_DRAW_INDIRECT_BUFFER</code> binding and the buffer object's data store is currently mapped. | |
103 | </p><p> | |
104 | <code class="constant">GL_INVALID_OPERATION</code> is generated if a geometry shader is active and <em class="parameter"><code>mode</code></em> | |
105 | is incompatible with the input primitive type of the geometry shader in the currently installed program object. | |
106 | </p><p> | |
107 | <code class="constant">GL_INVALID_OPERATION</code> is generated if <em class="parameter"><code>mode</code></em> is <code class="constant">GL_PATCHES</code> | |
108 | and no tessellation control shader is active. | |
109 | </p></div><div class="refsect1" lang="en" xml:lang="en"><a id="seealso"></a><h2>See Also</h2><p> | |
110 | <a href="glDrawArrays.xml"><span class="citerefentry"><span class="refentrytitle">glDrawArrays</span></span></a>, | |
111 | <a href="glDrawArraysInstanced.xml"><span class="citerefentry"><span class="refentrytitle">glDrawArraysInstanced</span></span></a>, | |
112 | <a href="glDrawArraysIndirect.xml"><span class="citerefentry"><span class="refentrytitle">glDrawArraysIndirect</span></span></a>, | |
113 | <a href="glDrawElements.xml"><span class="citerefentry"><span class="refentrytitle">glDrawElements</span></span></a>, | |
114 | <a href="glDrawRangeElements.xml"><span class="citerefentry"><span class="refentrytitle">glDrawRangeElements</span></span></a>, | |
115 | <a href="glDrawElementsIndirect.xml"><span class="citerefentry"><span class="refentrytitle">glDrawElementsIndirect</span></span></a>, | |
116 | <a href="glMultiDrawArraysIndirect.xml"><span class="citerefentry"><span class="refentrytitle">glMultiDrawArraysIndirect</span></span></a> | |
117 | </p></div><div class="refsect1" lang="en" xml:lang="en"><a id="Copyright"></a><h2>Copyright</h2><p> | |
118 | Copyright <span class="trademark"></span>© 2010-2012 Khronos Group. | |
119 | This material may be distributed subject to the terms and conditions set forth in | |
120 | the Open Publication License, v 1.0, 8 June 1999. | |
121 | <a href="http://opencontent.org/openpub/" target="_top">http://opencontent.org/openpub/</a>. | |
122 | </p></div></div></body></html> |