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="glUniform"> | |
5 | <refmeta> | |
6 | <refentrytitle>glUniform</refentrytitle> | |
7 | <manvolnum>3G</manvolnum> | |
8 | </refmeta> | |
9 | <refnamediv> | |
10 | <refdescriptor>glUniform</refdescriptor> | |
11 | <refname>glUniform1f</refname> | |
12 | <refname>glUniform2f</refname> | |
13 | <refname>glUniform3f</refname> | |
14 | <refname>glUniform4f</refname> | |
15 | <refname>glUniform1i</refname> | |
16 | <refname>glUniform2i</refname> | |
17 | <refname>glUniform3i</refname> | |
18 | <refname>glUniform4i</refname> | |
19 | <refname>glUniform1ui</refname> | |
20 | <refname>glUniform2ui</refname> | |
21 | <refname>glUniform3ui</refname> | |
22 | <refname>glUniform4ui</refname> | |
23 | <refname>glUniform1fv</refname> | |
24 | <refname>glUniform2fv</refname> | |
25 | <refname>glUniform3fv</refname> | |
26 | <refname>glUniform4fv</refname> | |
27 | <refname>glUniform1iv</refname> | |
28 | <refname>glUniform2iv</refname> | |
29 | <refname>glUniform3iv</refname> | |
30 | <refname>glUniform4iv</refname> | |
31 | <refname>glUniform1uiv</refname> | |
32 | <refname>glUniform2uiv</refname> | |
33 | <refname>glUniform3uiv</refname> | |
34 | <refname>glUniform4uiv</refname> | |
35 | <refname>glUniformMatrix2fv</refname> | |
36 | <refname>glUniformMatrix3fv</refname> | |
37 | <refname>glUniformMatrix4fv</refname> | |
38 | <refname>glUniformMatrix2x3fv</refname> | |
39 | <refname>glUniformMatrix3x2fv</refname> | |
40 | <refname>glUniformMatrix2x4fv</refname> | |
41 | <refname>glUniformMatrix4x2fv</refname> | |
42 | <refname>glUniformMatrix3x4fv</refname> | |
43 | <refname>glUniformMatrix4x3fv</refname> | |
44 | <refpurpose>Specify the value of a uniform variable for the current program object</refpurpose> | |
45 | </refnamediv> | |
46 | <refsynopsisdiv><title>C Specification</title> | |
47 | <funcsynopsis> | |
48 | <funcprototype> | |
49 | <funcdef>void <function>glUniform1f</function></funcdef> | |
50 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
51 | <paramdef>GLfloat <parameter>v0</parameter></paramdef> | |
52 | </funcprototype> | |
53 | <funcprototype> | |
54 | <funcdef>void <function>glUniform2f</function></funcdef> | |
55 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
56 | <paramdef>GLfloat <parameter>v0</parameter></paramdef> | |
57 | <paramdef>GLfloat <parameter>v1</parameter></paramdef> | |
58 | </funcprototype> | |
59 | <funcprototype> | |
60 | <funcdef>void <function>glUniform3f</function></funcdef> | |
61 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
62 | <paramdef>GLfloat <parameter>v0</parameter></paramdef> | |
63 | <paramdef>GLfloat <parameter>v1</parameter></paramdef> | |
64 | <paramdef>GLfloat <parameter>v2</parameter></paramdef> | |
65 | </funcprototype> | |
66 | <funcprototype> | |
67 | <funcdef>void <function>glUniform4f</function></funcdef> | |
68 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
69 | <paramdef>GLfloat <parameter>v0</parameter></paramdef> | |
70 | <paramdef>GLfloat <parameter>v1</parameter></paramdef> | |
71 | <paramdef>GLfloat <parameter>v2</parameter></paramdef> | |
72 | <paramdef>GLfloat <parameter>v3</parameter></paramdef> | |
73 | </funcprototype> | |
74 | <funcprototype> | |
75 | <funcdef>void <function>glUniform1i</function></funcdef> | |
76 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
77 | <paramdef>GLint <parameter>v0</parameter></paramdef> | |
78 | </funcprototype> | |
79 | <funcprototype> | |
80 | <funcdef>void <function>glUniform2i</function></funcdef> | |
81 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
82 | <paramdef>GLint <parameter>v0</parameter></paramdef> | |
83 | <paramdef>GLint <parameter>v1</parameter></paramdef> | |
84 | </funcprototype> | |
85 | <funcprototype> | |
86 | <funcdef>void <function>glUniform3i</function></funcdef> | |
87 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
88 | <paramdef>GLint <parameter>v0</parameter></paramdef> | |
89 | <paramdef>GLint <parameter>v1</parameter></paramdef> | |
90 | <paramdef>GLint <parameter>v2</parameter></paramdef> | |
91 | </funcprototype> | |
92 | <funcprototype> | |
93 | <funcdef>void <function>glUniform4i</function></funcdef> | |
94 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
95 | <paramdef>GLint <parameter>v0</parameter></paramdef> | |
96 | <paramdef>GLint <parameter>v1</parameter></paramdef> | |
97 | <paramdef>GLint <parameter>v2</parameter></paramdef> | |
98 | <paramdef>GLint <parameter>v3</parameter></paramdef> | |
99 | </funcprototype> | |
100 | <funcprototype> | |
101 | <funcdef>void <function>glUniform1ui</function></funcdef> | |
102 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
103 | <paramdef>GLuint <parameter>v0</parameter></paramdef> | |
104 | </funcprototype> | |
105 | <funcprototype> | |
106 | <funcdef>void <function>glUniform2ui</function></funcdef> | |
107 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
108 | <paramdef>GLuint <parameter>v0</parameter></paramdef> | |
109 | <paramdef>GLuint <parameter>v1</parameter></paramdef> | |
110 | </funcprototype> | |
111 | <funcprototype> | |
112 | <funcdef>void <function>glUniform3ui</function></funcdef> | |
113 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
114 | <paramdef>GLuint <parameter>v0</parameter></paramdef> | |
115 | <paramdef>GLuint <parameter>v1</parameter></paramdef> | |
116 | <paramdef>GLuint <parameter>v2</parameter></paramdef> | |
117 | </funcprototype> | |
118 | <funcprototype> | |
119 | <funcdef>void <function>glUniform4ui</function></funcdef> | |
120 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
121 | <paramdef>GLuint <parameter>v0</parameter></paramdef> | |
122 | <paramdef>GLuint <parameter>v1</parameter></paramdef> | |
123 | <paramdef>GLuint <parameter>v2</parameter></paramdef> | |
124 | <paramdef>GLuint <parameter>v3</parameter></paramdef> | |
125 | </funcprototype> | |
126 | </funcsynopsis> | |
127 | </refsynopsisdiv> | |
128 | <refsect1 id="parameters"><title>Parameters</title> | |
129 | <variablelist> | |
130 | <varlistentry> | |
131 | <term><parameter>location</parameter></term> | |
132 | <listitem> | |
133 | <para>Specifies the location of the uniform variable | |
134 | to be modified.</para> | |
135 | </listitem> | |
136 | </varlistentry> | |
137 | <varlistentry> | |
138 | <term> | |
139 | <parameter>v0</parameter>, | |
140 | <parameter>v1</parameter>, | |
141 | <parameter>v2</parameter>, | |
142 | <parameter>v3</parameter> | |
143 | </term> | |
144 | <listitem> | |
145 | <para>Specifies the new values to be used for the | |
146 | specified uniform variable.</para> | |
147 | </listitem> | |
148 | </varlistentry> | |
149 | </variablelist> | |
150 | </refsect1> | |
151 | <refsynopsisdiv><title>C Specification</title> | |
152 | <funcsynopsis> | |
153 | <funcprototype> | |
154 | <funcdef>void <function>glUniform1fv</function></funcdef> | |
155 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
156 | <paramdef>GLsizei <parameter>count</parameter></paramdef> | |
157 | <paramdef>const GLfloat *<parameter>value</parameter></paramdef> | |
158 | </funcprototype> | |
159 | <funcprototype> | |
160 | <funcdef>void <function>glUniform2fv</function></funcdef> | |
161 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
162 | <paramdef>GLsizei <parameter>count</parameter></paramdef> | |
163 | <paramdef>const GLfloat *<parameter>value</parameter></paramdef> | |
164 | </funcprototype> | |
165 | <funcprototype> | |
166 | <funcdef>void <function>glUniform3fv</function></funcdef> | |
167 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
168 | <paramdef>GLsizei <parameter>count</parameter></paramdef> | |
169 | <paramdef>const GLfloat *<parameter>value</parameter></paramdef> | |
170 | </funcprototype> | |
171 | <funcprototype> | |
172 | <funcdef>void <function>glUniform4fv</function></funcdef> | |
173 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
174 | <paramdef>GLsizei <parameter>count</parameter></paramdef> | |
175 | <paramdef>const GLfloat *<parameter>value</parameter></paramdef> | |
176 | </funcprototype> | |
177 | <funcprototype> | |
178 | <funcdef>void <function>glUniform1iv</function></funcdef> | |
179 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
180 | <paramdef>GLsizei <parameter>count</parameter></paramdef> | |
181 | <paramdef>const GLint *<parameter>value</parameter></paramdef> | |
182 | </funcprototype> | |
183 | <funcprototype> | |
184 | <funcdef>void <function>glUniform2iv</function></funcdef> | |
185 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
186 | <paramdef>GLsizei <parameter>count</parameter></paramdef> | |
187 | <paramdef>const GLint *<parameter>value</parameter></paramdef> | |
188 | </funcprototype> | |
189 | <funcprototype> | |
190 | <funcdef>void <function>glUniform3iv</function></funcdef> | |
191 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
192 | <paramdef>GLsizei <parameter>count</parameter></paramdef> | |
193 | <paramdef>const GLint *<parameter>value</parameter></paramdef> | |
194 | </funcprototype> | |
195 | <funcprototype> | |
196 | <funcdef>void <function>glUniform4iv</function></funcdef> | |
197 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
198 | <paramdef>GLsizei <parameter>count</parameter></paramdef> | |
199 | <paramdef>const GLint *<parameter>value</parameter></paramdef> | |
200 | </funcprototype> | |
201 | <funcprototype> | |
202 | <funcdef>void <function>glUniform1uiv</function></funcdef> | |
203 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
204 | <paramdef>GLsizei <parameter>count</parameter></paramdef> | |
205 | <paramdef>const GLuint *<parameter>value</parameter></paramdef> | |
206 | </funcprototype> | |
207 | <funcprototype> | |
208 | <funcdef>void <function>glUniform2uiv</function></funcdef> | |
209 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
210 | <paramdef>GLsizei <parameter>count</parameter></paramdef> | |
211 | <paramdef>const GLuint *<parameter>value</parameter></paramdef> | |
212 | </funcprototype> | |
213 | <funcprototype> | |
214 | <funcdef>void <function>glUniform3uiv</function></funcdef> | |
215 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
216 | <paramdef>GLsizei <parameter>count</parameter></paramdef> | |
217 | <paramdef>const GLuint *<parameter>value</parameter></paramdef> | |
218 | </funcprototype> | |
219 | <funcprototype> | |
220 | <funcdef>void <function>glUniform4uiv</function></funcdef> | |
221 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
222 | <paramdef>GLsizei <parameter>count</parameter></paramdef> | |
223 | <paramdef>const GLuint *<parameter>value</parameter></paramdef> | |
224 | </funcprototype> | |
225 | </funcsynopsis> | |
226 | </refsynopsisdiv> | |
227 | <refsect1 id="parameters2"><title>Parameters</title> | |
228 | <variablelist> | |
229 | <varlistentry> | |
230 | <term><parameter>location</parameter></term> | |
231 | <listitem> | |
232 | <para>Specifies the location of the uniform value to | |
233 | be modified.</para> | |
234 | </listitem> | |
235 | </varlistentry> | |
236 | <varlistentry> | |
237 | <term><parameter>count</parameter></term> | |
238 | <listitem> | |
239 | <para>Specifies the number of elements that are to | |
240 | be modified. This should be 1 if the targeted | |
241 | uniform variable is not an array, and 1 or more if it is | |
242 | an array.</para> | |
243 | </listitem> | |
244 | </varlistentry> | |
245 | <varlistentry> | |
246 | <term><parameter>value</parameter></term> | |
247 | <listitem> | |
248 | <para>Specifies a pointer to an array of | |
249 | <parameter>count</parameter> values that will be | |
250 | used to update the specified uniform | |
251 | variable.</para> | |
252 | </listitem> | |
253 | </varlistentry> | |
254 | </variablelist> | |
255 | </refsect1> | |
256 | <refsynopsisdiv><title>C Specification</title> | |
257 | <funcsynopsis> | |
258 | <funcprototype> | |
259 | <funcdef>void <function>glUniformMatrix2fv</function></funcdef> | |
260 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
261 | <paramdef>GLsizei <parameter>count</parameter></paramdef> | |
262 | <paramdef>GLboolean <parameter>transpose</parameter></paramdef> | |
263 | <paramdef>const GLfloat *<parameter>value</parameter></paramdef> | |
264 | </funcprototype> | |
265 | <funcprototype> | |
266 | <funcdef>void <function>glUniformMatrix3fv</function></funcdef> | |
267 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
268 | <paramdef>GLsizei <parameter>count</parameter></paramdef> | |
269 | <paramdef>GLboolean <parameter>transpose</parameter></paramdef> | |
270 | <paramdef>const GLfloat *<parameter>value</parameter></paramdef> | |
271 | </funcprototype> | |
272 | <funcprototype> | |
273 | <funcdef>void <function>glUniformMatrix4fv</function></funcdef> | |
274 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
275 | <paramdef>GLsizei <parameter>count</parameter></paramdef> | |
276 | <paramdef>GLboolean <parameter>transpose</parameter></paramdef> | |
277 | <paramdef>const GLfloat *<parameter>value</parameter></paramdef> | |
278 | </funcprototype> | |
279 | <funcprototype> | |
280 | <funcdef>void <function>glUniformMatrix2x3fv</function></funcdef> | |
281 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
282 | <paramdef>GLsizei <parameter>count</parameter></paramdef> | |
283 | <paramdef>GLboolean <parameter>transpose</parameter></paramdef> | |
284 | <paramdef>const GLfloat *<parameter>value</parameter></paramdef> | |
285 | </funcprototype> | |
286 | <funcprototype> | |
287 | <funcdef>void <function>glUniformMatrix3x2fv</function></funcdef> | |
288 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
289 | <paramdef>GLsizei <parameter>count</parameter></paramdef> | |
290 | <paramdef>GLboolean <parameter>transpose</parameter></paramdef> | |
291 | <paramdef>const GLfloat *<parameter>value</parameter></paramdef> | |
292 | </funcprototype> | |
293 | <funcprototype> | |
294 | <funcdef>void <function>glUniformMatrix2x4fv</function></funcdef> | |
295 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
296 | <paramdef>GLsizei <parameter>count</parameter></paramdef> | |
297 | <paramdef>GLboolean <parameter>transpose</parameter></paramdef> | |
298 | <paramdef>const GLfloat *<parameter>value</parameter></paramdef> | |
299 | </funcprototype> | |
300 | <funcprototype> | |
301 | <funcdef>void <function>glUniformMatrix4x2fv</function></funcdef> | |
302 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
303 | <paramdef>GLsizei <parameter>count</parameter></paramdef> | |
304 | <paramdef>GLboolean <parameter>transpose</parameter></paramdef> | |
305 | <paramdef>const GLfloat *<parameter>value</parameter></paramdef> | |
306 | </funcprototype> | |
307 | <funcprototype> | |
308 | <funcdef>void <function>glUniformMatrix3x4fv</function></funcdef> | |
309 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
310 | <paramdef>GLsizei <parameter>count</parameter></paramdef> | |
311 | <paramdef>GLboolean <parameter>transpose</parameter></paramdef> | |
312 | <paramdef>const GLfloat *<parameter>value</parameter></paramdef> | |
313 | </funcprototype> | |
314 | <funcprototype> | |
315 | <funcdef>void <function>glUniformMatrix4x3fv</function></funcdef> | |
316 | <paramdef>GLint <parameter>location</parameter></paramdef> | |
317 | <paramdef>GLsizei <parameter>count</parameter></paramdef> | |
318 | <paramdef>GLboolean <parameter>transpose</parameter></paramdef> | |
319 | <paramdef>const GLfloat *<parameter>value</parameter></paramdef> | |
320 | </funcprototype> | |
321 | </funcsynopsis> | |
322 | </refsynopsisdiv> | |
323 | <refsect1 id="parameters3"><title>Parameters</title> | |
324 | <variablelist> | |
325 | <varlistentry> | |
326 | <term><parameter>location</parameter></term> | |
327 | <listitem> | |
328 | <para>Specifies the location of the uniform value to | |
329 | be modified.</para> | |
330 | </listitem> | |
331 | </varlistentry> | |
332 | <varlistentry> | |
333 | <term><parameter>count</parameter></term> | |
334 | <listitem> | |
335 | <para>Specifies the number of matrices that are to | |
336 | be modified. This should be 1 if the targeted | |
337 | uniform variable is not an array of matrices, and 1 or more if it is | |
338 | an array of matrices.</para> | |
339 | </listitem> | |
340 | </varlistentry> | |
341 | <varlistentry> | |
342 | <term><parameter>transpose</parameter></term> | |
343 | <listitem> | |
344 | <para>Specifies whether to transpose the matrix as | |
345 | the values are loaded into the uniform | |
346 | variable.</para> | |
347 | </listitem> | |
348 | </varlistentry> | |
349 | <varlistentry> | |
350 | <term><parameter>value</parameter></term> | |
351 | <listitem> | |
352 | <para>Specifies a pointer to an array of | |
353 | <parameter>count</parameter> values that will be | |
354 | used to update the specified uniform | |
355 | variable.</para> | |
356 | </listitem> | |
357 | </varlistentry> | |
358 | </variablelist> | |
359 | </refsect1> | |
360 | <refsect1 id="description"><title>Description</title> | |
361 | <para><function>glUniform</function> modifies the value of a | |
362 | uniform variable or a uniform variable array. The location of | |
363 | the uniform variable to be modified is specified by | |
364 | <parameter>location</parameter>, which should be a value | |
365 | returned by | |
366 | <citerefentry><refentrytitle>glGetUniformLocation</refentrytitle></citerefentry>. | |
367 | <function>glUniform</function> operates on the program object | |
368 | that was made part of current state by calling | |
369 | <citerefentry><refentrytitle>glUseProgram</refentrytitle></citerefentry>.</para> | |
370 | ||
371 | <para>The commands <function>glUniform{1|2|3|4}{f|i|ui}</function> | |
372 | are used to change the value of the uniform variable specified | |
373 | by <parameter>location</parameter> using the values passed as | |
374 | arguments. The number specified in the command should match the | |
375 | number of components in the data type of the specified uniform | |
376 | variable (e.g., <function>1</function> for <code>float</code>, <code>int</code>, <code>unsigned int</code>, <code>bool</code>; | |
377 | <function>2</function> for <code>vec2</code>, <code>ivec2</code>, <code>uvec2</code>, <code>bvec2</code>, etc.). The suffix | |
378 | <function>f</function> indicates that floating-point values are | |
379 | being passed; the suffix <function>i</function> indicates that | |
380 | integer values are being passed; the suffix <function>ui</function> indicates that | |
381 | unsigned integer values are being passed, and this type should also match | |
382 | the data type of the specified uniform variable. The | |
383 | <function>i</function> variants of this function should be used | |
384 | to provide values for uniform variables defined as <code>int</code>, <code>ivec2</code>, | |
385 | <code>ivec3</code>, <code>ivec4</code>, or arrays of these. The | |
386 | <function>ui</function> variants of this function should be used | |
387 | to provide values for uniform variables defined as <code>unsigned int</code>, <code>uvec2</code>, | |
388 | <code>uvec3</code>, <code>uvec4</code>, or arrays of these. The <function>f</function> | |
389 | variants should be used to provide values for uniform variables | |
390 | of type <code>float</code>, <code>vec2</code>, <code>vec3</code>, <code>vec4</code>, or arrays of these. Either the | |
391 | <function>i</function>, <function>ui</function> or <function>f</function> variants | |
392 | may be used to provide values for uniform variables of type | |
393 | <code>bool</code>, <code>bvec2</code>, <code>bvec3</code>, <code>bvec4</code>, or arrays of these. The uniform | |
394 | variable will be set to <code>false</code> if the input value is 0 or 0.0f, | |
395 | and it will be set to <code>true</code> otherwise.</para> | |
396 | ||
397 | <para>All active uniform variables defined in a program object | |
398 | are initialized to 0 when the program object is linked | |
399 | successfully. They retain the values assigned to them by a call | |
400 | to <function>glUniform </function> until the next successful | |
401 | link operation occurs on the program object, when they are once | |
402 | again initialized to 0.</para> | |
403 | ||
404 | <para>The commands <function>glUniform{1|2|3|4}{f|i|ui}v</function> | |
405 | can be used to modify a single uniform variable or a uniform | |
406 | variable array. These commands pass a count and a pointer to the | |
407 | values to be loaded into a uniform variable or a uniform | |
408 | variable array. A count of 1 should be used if modifying the | |
409 | value of a single uniform variable, and a count of 1 or greater | |
410 | can be used to modify an entire array or part of an array. When | |
411 | loading <emphasis>n</emphasis> elements starting at an arbitrary | |
412 | position <emphasis>m</emphasis> in a uniform variable array, | |
413 | elements <emphasis>m</emphasis> + <emphasis>n</emphasis> - 1 in | |
414 | the array will be replaced with the new values. If | |
415 | <parameter>m</parameter> + <parameter>n</parameter> - 1 is | |
416 | larger than the size of the uniform variable array, values for | |
417 | all array elements beyond the end of the array will be ignored. | |
418 | The number specified in the name of the command indicates the | |
419 | number of components for each element in | |
420 | <parameter>value</parameter>, and it should match the number of | |
421 | components in the data type of the specified uniform variable | |
422 | (e.g., <function>1</function> for float, int, bool; | |
423 | <function>2</function> for vec2, ivec2, bvec2, etc.). The data | |
424 | type specified in the name of the command must match the data | |
425 | type for the specified uniform variable as described previously | |
426 | for <function>glUniform{1|2|3|4}{f|i|ui}</function>.</para> | |
427 | ||
428 | <para>For uniform variable arrays, each element of the array is | |
429 | considered to be of the type indicated in the name of the | |
430 | command (e.g., <function>glUniform3f</function> or | |
431 | <function>glUniform3fv</function> can be used to load a uniform | |
432 | variable array of type vec3). The number of elements of the | |
433 | uniform variable array to be modified is specified by | |
434 | <parameter>count</parameter></para> | |
435 | ||
436 | <para>The commands | |
437 | <function>glUniformMatrix{2|3|4|2x3|3x2|2x4|4x2|3x4|4x3}fv</function> | |
438 | are used to modify a matrix or an array of matrices. The numbers in the | |
439 | command name are interpreted as the dimensionality of the matrix. | |
440 | The number <function>2</function> indicates a 2 × 2 matrix | |
441 | (i.e., 4 values), the number <function>3</function> indicates a | |
442 | 3 × 3 matrix (i.e., 9 values), and the number | |
443 | <function>4</function> indicates a 4 × 4 matrix (i.e., 16 | |
444 | values). Non-square matrix dimensionality is explicit, with the first | |
445 | number representing the number of columns and the second number | |
446 | representing the number of rows. For example, | |
447 | <function>2x4</function> indicates a 2 × 4 matrix with 2 columns | |
448 | and 4 rows (i.e., 8 values). | |
449 | If <parameter>transpose</parameter> is | |
450 | <constant>GL_FALSE</constant>, each matrix is assumed to be | |
451 | supplied in column major order. If | |
452 | <parameter>transpose</parameter> is | |
453 | <constant>GL_TRUE</constant>, each matrix is assumed to be | |
454 | supplied in row major order. The <parameter>count</parameter> | |
455 | argument indicates the number of matrices to be passed. A count | |
456 | of 1 should be used if modifying the value of a single matrix, | |
457 | and a count greater than 1 can be used to modify an array of | |
458 | matrices.</para> | |
459 | </refsect1> | |
460 | <refsect1 id="notes"><title>Notes</title> | |
461 | <para><function>glUniform1i</function> and | |
462 | <function>glUniform1iv</function> are the only two functions | |
463 | that may be used to load uniform variables defined as sampler | |
464 | types. Loading samplers with any other function will result in a | |
465 | <constant>GL_INVALID_OPERATION</constant> error.</para> | |
466 | ||
467 | <para>If <parameter>count</parameter> is greater than 1 and the | |
468 | indicated uniform variable is not an array, a | |
469 | <constant>GL_INVALID_OPERATION</constant> error is generated and the | |
470 | specified uniform variable will remain unchanged.</para> | |
471 | ||
472 | <para>Other than the preceding exceptions, if the type and size | |
473 | of the uniform variable as defined in the shader do not match | |
474 | the type and size specified in the name of the command used to | |
475 | load its value, a <constant>GL_INVALID_OPERATION</constant> error will | |
476 | be generated and the specified uniform variable will remain | |
477 | unchanged.</para> | |
478 | ||
479 | <para>If <parameter>location</parameter> is a value other than | |
480 | -1 and it does not represent a valid uniform variable location | |
481 | in the current program object, an error will be generated, and | |
482 | no changes will be made to the uniform variable storage of the | |
483 | current program object. If <parameter>location</parameter> is | |
484 | equal to -1, the data passed in will be silently ignored and the | |
485 | specified uniform variable will not be changed.</para> | |
486 | </refsect1> | |
487 | <refsect1 id="errors"><title>Errors</title> | |
488 | <para><constant>GL_INVALID_OPERATION</constant> is generated if there | |
489 | is no current program object.</para> | |
490 | ||
491 | <para><constant>GL_INVALID_OPERATION</constant> is generated if the | |
492 | size of the uniform variable declared in the shader does not | |
493 | match the size indicated by the <function>glUniform</function> | |
494 | command.</para> | |
495 | ||
496 | <para><constant>GL_INVALID_OPERATION</constant> is generated if one of | |
497 | the signed or unsigned integer variants of this function is used to load a uniform | |
498 | variable of type <code>float</code>, <code>vec2</code>, <code>vec3</code>, <code>vec4</code>, or an array of these, | |
499 | or if one of the floating-point variants of this function is | |
500 | used to load a uniform variable of type <code>int</code>, <code>ivec2</code>, <code>ivec3</code>, | |
501 | <code>ivec4</code>, <code>unsigned int</code>, <code>uvec2</code>, <code>uvec3</code>, | |
502 | <code>uvec4</code>, or an array of these.</para> | |
503 | ||
504 | <para><constant>GL_INVALID_OPERATION</constant> is generated if one of | |
505 | the signed integer variants of this function is used to load a uniform | |
506 | variable of type <code>unsigned int</code>, <code>uvec2</code>, <code>uvec3</code>, | |
507 | <code>uvec4</code>, or an array of these.</para> | |
508 | ||
509 | <para><constant>GL_INVALID_OPERATION</constant> is generated if one of | |
510 | the unsigned integer variants of this function is used to load a uniform | |
511 | variable of type <code>int</code>, <code>ivec2</code>, <code>ivec3</code>, | |
512 | <code>ivec4</code>, or an array of these.</para> | |
513 | ||
514 | <para><constant>GL_INVALID_OPERATION</constant> is generated if | |
515 | <parameter>location</parameter> is an invalid uniform location | |
516 | for the current program object and | |
517 | <parameter>location</parameter> is not equal to -1.</para> | |
518 | ||
519 | <para><constant>GL_INVALID_VALUE</constant> is generated if | |
520 | <parameter>count</parameter> is less than 0.</para> | |
521 | ||
522 | <para><constant>GL_INVALID_OPERATION</constant> is generated if | |
523 | <parameter>count</parameter> is greater than 1 and the indicated | |
524 | uniform variable is not an array variable.</para> | |
525 | ||
526 | <para><constant>GL_INVALID_OPERATION</constant> is generated if a | |
527 | sampler is loaded using a command other than | |
528 | <function>glUniform1i</function> and | |
529 | <function>glUniform1iv</function>.</para> | |
530 | ||
531 | </refsect1> | |
532 | <refsect1 id="associatedgets"><title>Associated Gets</title> | |
533 | <para><citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> | |
534 | with the argument <constant>GL_CURRENT_PROGRAM</constant></para> | |
535 | ||
536 | <para><citerefentry><refentrytitle>glGetActiveUniform</refentrytitle></citerefentry> | |
537 | with the handle of a program object and the index of an active uniform variable</para> | |
538 | ||
539 | <para><citerefentry><refentrytitle>glGetUniform</refentrytitle></citerefentry> | |
540 | with the handle of a program object and the location of a | |
541 | uniform variable</para> | |
542 | ||
543 | <para><citerefentry><refentrytitle>glGetUniformLocation</refentrytitle></citerefentry> | |
544 | with the handle of a program object and the name of a uniform | |
545 | variable</para> | |
546 | </refsect1> | |
547 | <refsect1 id="seealso"><title>See Also</title> | |
548 | <para><citerefentry><refentrytitle>glLinkProgram</refentrytitle></citerefentry>, | |
549 | <citerefentry><refentrytitle>glUseProgram</refentrytitle></citerefentry></para> | |
550 | </refsect1> | |
551 | <refsect1 id="Copyright"><title>Copyright</title> | |
552 | <para> | |
553 | Copyright <trademark class="copyright"></trademark> 2003-2005 3Dlabs Inc. Ltd. | |
554 | Copyright <trademark class="copyright"></trademark> 2010 Khronos Group. | |
555 | This material may be distributed subject to the terms and conditions set forth in | |
556 | the Open Publication License, v 1.0, 8 June 1999. | |
557 | <ulink url="http://opencontent.org/openpub/">http://opencontent.org/openpub/</ulink>. | |
558 | </para> | |
559 | </refsect1> | |
560 | </refentry> |