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="glDrawArraysInstancedBaseInstance"> | |
5 | <refmeta> | |
6 | <refmetainfo> | |
7 | <copyright> | |
8 | <year>2010</year> | |
9 | <holder>Khronos Group</holder> | |
10 | </copyright> | |
11 | </refmetainfo> | |
12 | <refentrytitle>glDrawArraysInstancedBaseInstance</refentrytitle> | |
13 | <manvolnum>3G</manvolnum> | |
14 | </refmeta> | |
15 | <refnamediv> | |
16 | <refname>glDrawArraysInstancedBaseInstance</refname> | |
17 | <refpurpose>draw multiple instances of a range 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>glDrawArraysInstancedBaseInstance</function></funcdef> | |
23 | <paramdef>GLenum <parameter>mode</parameter></paramdef> | |
24 | <paramdef>GLint <parameter>first</parameter></paramdef> | |
25 | <paramdef>GLsizei <parameter>count</parameter></paramdef> | |
26 | <paramdef>GLsizei <parameter>primcount</parameter></paramdef> | |
27 | <paramdef>GLuint <parameter>baseinstance</parameter></paramdef> | |
28 | </funcprototype> | |
29 | </funcsynopsis> | |
30 | </refsynopsisdiv> | |
31 | <refsect1 id="parameters"><title>Parameters</title> | |
32 | <variablelist> | |
33 | <varlistentry> | |
34 | <term><parameter>mode</parameter></term> | |
35 | <listitem> | |
36 | <para> | |
37 | Specifies what kind of primitives to render. Symbolic constants <constant>GL_POINTS</constant>, | |
38 | <constant>GL_LINE_STRIP</constant>, <constant>GL_LINE_LOOP</constant>, <constant>GL_LINES</constant>, | |
39 | <constant>GL_TRIANGLE_STRIP</constant>, <constant>GL_TRIANGLE_FAN</constant>, <constant>GL_TRIANGLES</constant> | |
40 | <constant>GL_LINES_ADJACENCY</constant>, <constant>GL_LINE_STRIP_ADJACENCY</constant>, | |
41 | <constant>GL_TRIANGLES_ADJACENCY</constant>, <constant>GL_TRIANGLE_STRIP_ADJACENCY</constant> and <constant>GL_PATCHES</constant> | |
42 | are accepted. | |
43 | </para> | |
44 | </listitem> | |
45 | </varlistentry> | |
46 | <varlistentry> | |
47 | <term><parameter>first</parameter></term> | |
48 | <listitem> | |
49 | <para> | |
50 | Specifies the starting index in the enabled arrays. | |
51 | </para> | |
52 | </listitem> | |
53 | </varlistentry> | |
54 | <varlistentry> | |
55 | <term><parameter>count</parameter></term> | |
56 | <listitem> | |
57 | <para> | |
58 | Specifies the number of indices to be rendered. | |
59 | </para> | |
60 | </listitem> | |
61 | </varlistentry> | |
62 | <varlistentry> | |
63 | <term><parameter>primcount</parameter></term> | |
64 | <listitem> | |
65 | <para> | |
66 | Specifies the number of instances of the specified range of indices to be rendered. | |
67 | </para> | |
68 | </listitem> | |
69 | </varlistentry> | |
70 | <varlistentry> | |
71 | <term><parameter>baseinstance</parameter></term> | |
72 | <listitem> | |
73 | <para> | |
74 | Specifies the base instance for use in fetching instanced vertex attributes. | |
75 | </para> | |
76 | </listitem> | |
77 | </varlistentry> | |
78 | </variablelist> | |
79 | </refsect1> | |
80 | <refsect1 id="description"><title>Description</title> | |
81 | <para> | |
82 | <function>glDrawArraysInstancedBaseInstance</function> behaves identically to <citerefentry><refentrytitle>glDrawArrays</refentrytitle></citerefentry> | |
83 | except that <parameter>primcount</parameter> instances of the range of elements are executed and the value of the internal counter | |
84 | <parameter>instanceID</parameter> advances for each iteration. <parameter>instanceID</parameter> is an internal 32-bit integer counter | |
85 | that may be read by a vertex shader as <constant>gl_InstanceID</constant>. | |
86 | </para> | |
87 | <para> | |
88 | <function>glDrawArraysInstancedBaseInstance</function> has the same effect as: | |
89 | <programlisting><![CDATA[ if ( mode or count is invalid ) | |
90 | generate appropriate error | |
91 | else { | |
92 | for (int i = 0; i < primcount ; i++) { | |
93 | instanceID = i; | |
94 | glDrawArrays(mode, first, count); | |
95 | } | |
96 | instanceID = 0; | |
97 | }]]></programlisting> | |
98 | </para> | |
99 | <para> | |
100 | Specific vertex attributes may be classified as <emphasis>instanced</emphasis> through the use of | |
101 | <citerefentry><refentrytitle>glVertexAttribDivisor</refentrytitle></citerefentry>. Instanced vertex attributes | |
102 | supply per-instance vertex data to the vertex shader. The index of the vertex fetched from the enabled instanced vertex | |
103 | attribute arrays is calculated as: | |
104 | <mml:math> | |
105 | <mml:mrow> | |
106 | <mml:mfenced open = '⌊' close = '⌋'> | |
107 | <mml:mfrac> | |
108 | <mml:mrow> | |
109 | <mml:mi>gl</mml:mi> | |
110 | <mml:mo>_</mml:mo> | |
111 | <mml:mi>InstanceID</mml:mi> | |
112 | </mml:mrow> | |
113 | <mml:mi>divisor</mml:mi> | |
114 | </mml:mfrac> | |
115 | </mml:mfenced> | |
116 | <mml:mo lspace='2px' rspace='2px'>+</mml:mo> | |
117 | <mml:mi>baseInstance</mml:mi> | |
118 | </mml:mrow> | |
119 | </mml:math>. Note that <parameter>baseinstance</parameter> does not affect the shader-visible value of <constant>gl_InstanceID</constant>. | |
120 | </para> | |
121 | </refsect1> | |
122 | <refsect1 id="errors"><title>Errors</title> | |
123 | <para> | |
124 | <constant>GL_INVALID_ENUM</constant> is generated if <parameter>mode</parameter> is not one of | |
125 | the accepted values. | |
126 | </para> | |
127 | <para> | |
128 | <constant>GL_INVALID_OPERATION</constant> is generated if a geometry shader is active and <parameter>mode</parameter> | |
129 | is incompatible with the input primitive type of the geometry shader in the currently installed program object. | |
130 | </para> | |
131 | <para> | |
132 | <constant>GL_INVALID_VALUE</constant> is generated if <parameter>count</parameter> or <parameter>primcount</parameter> are negative. | |
133 | </para> | |
134 | <para> | |
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. | |
137 | </para> | |
138 | </refsect1> | |
139 | <refsect1 id="seealso"><title>See Also</title> | |
140 | <para> | |
141 | <citerefentry><refentrytitle>glDrawArrays</refentrytitle></citerefentry>, | |
142 | <citerefentry><refentrytitle>glDrawElementsInstanced</refentrytitle></citerefentry> | |
143 | </para> | |
144 | </refsect1> | |
145 | <refsect1 id="Copyright"><title>Copyright</title> | |
146 | <para> | |
147 | Copyright <trademark class="copyright"></trademark> 2011 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>. | |
151 | </para> | |
152 | </refsect1> | |
153 | </refentry> |