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