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=
"glGetActiveUniform">
6 <refentrytitle>glGetActiveUniform
</refentrytitle>
7 <manvolnum>3G
</manvolnum>
10 <refname>glGetActiveUniform
</refname>
11 <refpurpose>Returns information about an active uniform variable for the specified program object
</refpurpose>
13 <refsynopsisdiv><title>C Specification
</title>
16 <funcdef>void
<function>glGetActiveUniform
</function></funcdef>
17 <paramdef>GLuint
<parameter>program
</parameter></paramdef>
18 <paramdef>GLuint
<parameter>index
</parameter></paramdef>
19 <paramdef>GLsizei
<parameter>bufSize
</parameter></paramdef>
20 <paramdef>GLsizei *
<parameter>length
</parameter></paramdef>
21 <paramdef>GLint *
<parameter>size
</parameter></paramdef>
22 <paramdef>GLenum *
<parameter>type
</parameter></paramdef>
23 <paramdef>GLchar *
<parameter>name
</parameter></paramdef>
27 <refsect1 id=
"parameters"><title>Parameters
</title>
30 <term><parameter>program
</parameter></term>
32 <para>Specifies the program object to be
37 <term><parameter>index
</parameter></term>
39 <para>Specifies the index of the uniform variable to
44 <term><parameter>bufSize
</parameter></term>
46 <para>Specifies the maximum number of characters
47 OpenGL is allowed to write in the character buffer
48 indicated by
<parameter>name
</parameter>.
</para>
52 <term><parameter>length
</parameter></term>
54 <para>Returns the number of characters actually
55 written by OpenGL in the string indicated by
56 <parameter>name
</parameter> (excluding the null
57 terminator) if a value other than
58 <constant>NULL
</constant> is passed.
</para>
62 <term><parameter>size
</parameter></term>
64 <para>Returns the size of the uniform
69 <term><parameter>type
</parameter></term>
71 <para>Returns the data type of the uniform
76 <term><parameter>name
</parameter></term>
78 <para>Returns a null terminated string containing
79 the name of the uniform variable.
</para>
84 <refsect1 id=
"description"><title>Description
</title>
85 <para><function>glGetActiveUniform
</function> returns
86 information about an active uniform variable in the program
87 object specified by
<parameter>program
</parameter>. The number
88 of active uniform variables can be obtained by calling
89 <citerefentry><refentrytitle>glGetProgram
</refentrytitle></citerefentry>
90 with the value
<constant>GL_ACTIVE_UNIFORMS
</constant>. A value
91 of
0 for
<parameter>index
</parameter> selects the first active
92 uniform variable. Permissible values for
93 <parameter>index
</parameter> range from
0 to the number of
94 active uniform variables minus
1.
</para>
96 <para>Shaders may use either built-in uniform variables,
97 user-defined uniform variables, or both. Built-in uniform
98 variables have a prefix of
"gl_
" and reference
99 existing OpenGL state or values derived from such state (e.g.,
100 <parameter>gl_DepthRangeParameters
</parameter>, see the OpenGL
101 Shading Language specification for a complete list.)
102 User-defined uniform variables have arbitrary names and obtain
103 their values from the application through calls to
104 <citerefentry><refentrytitle>glUniform
</refentrytitle></citerefentry>.
105 A uniform variable (either built-in or user-defined) is
106 considered active if it is determined during the link operation
107 that it may be accessed during program execution. Therefore,
108 <parameter>program
</parameter> should have previously been the
110 <citerefentry><refentrytitle>glLinkProgram
</refentrytitle></citerefentry>,
111 but it is not necessary for it to have been linked
114 <para>The size of the character buffer required to store the
115 longest uniform variable name in
<parameter>program
</parameter>
116 can be obtained by calling
117 <citerefentry><refentrytitle>glGetProgram
</refentrytitle></citerefentry>
119 <constant>GL_ACTIVE_UNIFORM_MAX_LENGTH
</constant>. This value
120 should be used to allocate a buffer of sufficient size to store
121 the returned uniform variable name. The size of this character
122 buffer is passed in
<parameter>bufSize
</parameter>, and a
123 pointer to this character buffer is passed in
124 <parameter>name.
</parameter></para>
126 <para><function>glGetActiveUniform
</function> returns the name
127 of the uniform variable indicated by
128 <parameter>index
</parameter>, storing it in the character buffer
129 specified by
<parameter>name
</parameter>. The string returned
130 will be null terminated. The actual number of characters written
131 into this buffer is returned in
<parameter>length
</parameter>,
132 and this count does not include the null termination character.
133 If the length of the returned string is not required, a value of
134 <constant>NULL
</constant> can be passed in the
135 <parameter>length
</parameter> argument.
</para>
137 <para>The
<parameter>type
</parameter>
138 argument will return a pointer to the uniform variable's data
139 type. The symbolic constants returned for uniform types are shown in the
141 <informaltable frame=
"topbot">
142 <tgroup cols=
"2" align=
"left">
143 <colspec colwidth=
"1.1*" />
144 <colspec colwidth=
"1*" />
147 <entry rowsep=
"1" align=
"left"><emphasis role=
"bold">
148 Returned Symbolic Contant
150 <entry rowsep=
"1" align=
"left"><emphasis role=
"bold">
158 <constant>GL_FLOAT
</constant>
161 <constant>float
</constant>
166 <constant>GL_FLOAT_VEC2
</constant>
169 <constant>vec2
</constant>
174 <constant>GL_FLOAT_VEC3
</constant>
177 <constant>vec3
</constant>
182 <constant>GL_FLOAT_VEC4
</constant>
185 <constant>vec4
</constant>
190 <constant>GL_INT
</constant>
193 <constant>int
</constant>
198 <constant>GL_INT_VEC2
</constant>
201 <constant>ivec2
</constant>
206 <constant>GL_INT_VEC3
</constant>
209 <constant>ivec3
</constant>
214 <constant>GL_INT_VEC4
</constant>
217 <constant>ivec4
</constant>
222 <constant>GL_UNSIGNED_INT
</constant>
225 <constant>unsigned int
</constant>
230 <constant>GL_UNSIGNED_INT_VEC2
</constant>
233 <constant>uvec2
</constant>
238 <constant>GL_UNSIGNED_INT_VEC3
</constant>
241 <constant>uvec3
</constant>
246 <constant>GL_UNSIGNED_INT_VEC4
</constant>
249 <constant>uvec4
</constant>
254 <constant>GL_BOOL
</constant>
257 <constant>bool
</constant>
262 <constant>GL_BOOL_VEC2
</constant>
265 <constant>bvec2
</constant>
270 <constant>GL_BOOL_VEC3
</constant>
273 <constant>bvec3
</constant>
278 <constant>GL_BOOL_VEC4
</constant>
281 <constant>bvec4
</constant>
286 <constant>GL_FLOAT_MAT2
</constant>
289 <constant>mat2
</constant>
294 <constant>GL_FLOAT_MAT3
</constant>
297 <constant>mat3
</constant>
302 <constant>GL_FLOAT_MAT4
</constant>
305 <constant>mat4
</constant>
310 <constant>GL_FLOAT_MAT2x3
</constant>
313 <constant>mat2x3
</constant>
318 <constant>GL_FLOAT_MAT2x4
</constant>
321 <constant>mat2x4
</constant>
326 <constant>GL_FLOAT_MAT3x2
</constant>
329 <constant>mat3x2
</constant>
334 <constant>GL_FLOAT_MAT3x4
</constant>
337 <constant>mat3x4
</constant>
342 <constant>GL_FLOAT_MAT4x2
</constant>
345 <constant>mat4x2
</constant>
350 <constant>GL_FLOAT_MAT4x3
</constant>
353 <constant>mat4x3
</constant>
358 <constant>GL_SAMPLER_1D
</constant>
361 <constant>sampler1D
</constant>
366 <constant>GL_SAMPLER_2D
</constant>
369 <constant>sampler2D
</constant>
374 <constant>GL_SAMPLER_3D
</constant>
377 <constant>sampler3D
</constant>
382 <constant>GL_SAMPLER_CUBE
</constant>
385 <constant>samplerCube
</constant>
390 <constant>GL_SAMPLER_1D_SHADOW
</constant>
393 <constant>sampler1DShadow
</constant>
398 <constant>GL_SAMPLER_2D_SHADOW
</constant>
401 <constant>sampler2DShadow
</constant>
406 <constant>GL_SAMPLER_1D_ARRAY
</constant>
409 <constant>sampler1DArray
</constant>
414 <constant>GL_SAMPLER_2D_ARRAY
</constant>
417 <constant>sampler2DArray
</constant>
422 <constant>GL_SAMPLER_1D_ARRAY_SHADOW
</constant>
425 <constant>sampler1DArrayShadow
</constant>
430 <constant>GL_SAMPLER_2D_ARRAY_SHADOW
</constant>
433 <constant>sampler2DArrayShadow
</constant>
438 <constant>GL_SAMPLER_2D_MULTISAMPLE
</constant>
441 <constant>sampler2DMS
</constant>
446 <constant>GL_SAMPLER_2D_MULTISAMPLE_ARRAY
</constant>
449 <constant>sampler2DMSArray
</constant>
454 <constant>GL_SAMPLER_CUBE_SHADOW
</constant>
457 <constant>samplerCubeShadow
</constant>
462 <constant>GL_SAMPLER_BUFFER
</constant>
465 <constant>samplerBuffer
</constant>
470 <constant>GL_SAMPLER_2D_RECT
</constant>
473 <constant>sampler2DRect
</constant>
478 <constant>GL_SAMPLER_2D_RECT_SHADOW
</constant>
481 <constant>sampler2DRectShadow
</constant>
486 <constant>GL_INT_SAMPLER_1D
</constant>
489 <constant>isampler1D
</constant>
494 <constant>GL_INT_SAMPLER_2D
</constant>
497 <constant>isampler2D
</constant>
502 <constant>GL_INT_SAMPLER_3D
</constant>
505 <constant>isampler3D
</constant>
510 <constant>GL_INT_SAMPLER_CUBE
</constant>
513 <constant>isamplerCube
</constant>
518 <constant>GL_INT_SAMPLER_1D_ARRAY
</constant>
521 <constant>isampler1DArray
</constant>
526 <constant>GL_INT_SAMPLER_2D_ARRAY
</constant>
529 <constant>isampler2DArray
</constant>
534 <constant>GL_INT_SAMPLER_2D_MULTISAMPLE
</constant>
537 <constant>isampler2DMS
</constant>
542 <constant>GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY
</constant>
545 <constant>isampler2DMSArray
</constant>
550 <constant>GL_INT_SAMPLER_BUFFER
</constant>
553 <constant>isamplerBuffer
</constant>
558 <constant>GL_INT_SAMPLER_2D_RECT
</constant>
561 <constant>isampler2DRect
</constant>
566 <constant>GL_UNSIGNED_INT_SAMPLER_1D
</constant>
569 <constant>usampler1D
</constant>
574 <constant>GL_UNSIGNED_INT_SAMPLER_2D
</constant>
577 <constant>usampler2D
</constant>
582 <constant>GL_UNSIGNED_INT_SAMPLER_3D
</constant>
585 <constant>usampler3D
</constant>
590 <constant>GL_UNSIGNED_INT_SAMPLER_CUBE
</constant>
593 <constant>usamplerCube
</constant>
598 <constant>GL_UNSIGNED_INT_SAMPLER_1D_ARRAY
</constant>
601 <constant>usampler2DArray
</constant>
606 <constant>GL_UNSIGNED_INT_SAMPLER_2D_ARRAY
</constant>
609 <constant>usampler2DArray
</constant>
614 <constant>GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE
</constant>
617 <constant>usampler2DMS
</constant>
622 <constant>GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY
</constant>
625 <constant>usampler2DMSArray
</constant>
630 <constant>GL_UNSIGNED_INT_SAMPLER_BUFFER
</constant>
633 <constant>usamplerBuffer
</constant>
638 <constant>GL_UNSIGNED_INT_SAMPLER_2D_RECT
</constant>
641 <constant>usampler2DRect
</constant>
649 <para>If one or more elements of an array are active, the name
650 of the array is returned in
<parameter>name
</parameter>, the
651 type is returned in
<parameter>type
</parameter>, and the
652 <parameter>size
</parameter> parameter returns the highest array
653 element index used, plus one, as determined by the compiler
654 and/or linker. Only one active uniform variable will be reported
655 for a uniform array.
</para>
657 <para>Uniform variables that are declared as structures or
658 arrays of structures will not be returned directly by this
659 function. Instead, each of these uniform variables will be
660 reduced to its fundamental components containing the
661 ".
" and
"[]
" operators such that each of the
662 names is valid as an argument to
663 <citerefentry><refentrytitle>glGetUniformLocation
</refentrytitle></citerefentry>.
664 Each of these reduced uniform variables is counted as one active
665 uniform variable and is assigned an index. A valid name cannot
666 be a structure, an array of structures, or a subcomponent of a
667 vector or matrix.
</para>
669 <para>The size of the uniform variable will be returned in
670 <parameter>size
</parameter>. Uniform variables other than arrays
671 will have a size of
1. Structures and arrays of structures will
672 be reduced as described earlier, such that each of the names
673 returned will be a data type in the earlier list. If this
674 reduction results in an array, the size returned will be as
675 described for uniform arrays; otherwise, the size returned will
678 <para>The list of active uniform variables may include both
679 built-in uniform variables (which begin with the prefix
680 "gl_
") as well as user-defined uniform variable
683 <para>This function will return as much information as it can
684 about the specified active uniform variable. If no information
685 is available,
<parameter>length
</parameter> will be
0, and
686 <parameter>name
</parameter> will be an empty string. This
687 situation could occur if this function is called after a link
688 operation that failed. If an error occurs, the return values
689 <parameter>length
</parameter>,
<parameter>size
</parameter>,
690 <parameter>type
</parameter>, and
<parameter>name
</parameter>
691 will be unmodified.
</para>
693 <refsect1 id=
"errors"><title>Errors
</title>
694 <para><constant>GL_INVALID_VALUE
</constant> is generated if
695 <parameter>program
</parameter> is not a value generated by
698 <para><constant>GL_INVALID_OPERATION
</constant> is generated if
699 <parameter>program
</parameter> is not a program object.
</para>
701 <para><constant>GL_INVALID_VALUE
</constant> is generated if
702 <parameter>index
</parameter> is greater than or equal to the
703 number of active uniform variables in
704 <parameter>program
</parameter>.
</para>
706 <para><constant>GL_INVALID_VALUE
</constant> is generated if
707 <parameter>bufSize
</parameter> is less than
0.
</para>
709 <refsect1 id=
"associatedgets"><title>Associated Gets
</title>
710 <para><citerefentry><refentrytitle>glGet
</refentrytitle></citerefentry>
712 <constant>GL_MAX_VERTEX_UNIFORM_COMPONENTS
</constant>,
713 <constant>GL_MAX_GEOMETRY_UNIFORM_COMPONENTS
</constant>,
714 <constant>GL_MAX_FRAGMENT_UNIFORM_COMPONENTS
</constant>,
715 <constant>GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS
</constant>,
716 <constant>GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS
</constant>,
717 <constant>GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS
</constant>.
</para>
719 <para><citerefentry><refentrytitle>glGetProgram
</refentrytitle></citerefentry>
720 with argument
<constant>GL_ACTIVE_UNIFORMS
</constant> or
721 <constant>GL_ACTIVE_UNIFORM_MAX_LENGTH
</constant>.
</para>
723 <para><citerefentry><refentrytitle>glIsProgram
</refentrytitle></citerefentry></para>
725 <refsect1 id=
"seealso"><title>See Also
</title>
726 <para><citerefentry><refentrytitle>glGetUniform
</refentrytitle></citerefentry>,
727 <citerefentry><refentrytitle>glGetUniformLocation
</refentrytitle></citerefentry>,
728 <citerefentry><refentrytitle>glLinkProgram
</refentrytitle></citerefentry>,
729 <citerefentry><refentrytitle>glUniform
</refentrytitle></citerefentry>,
730 <citerefentry><refentrytitle>glUseProgram
</refentrytitle></citerefentry></para>
732 <refsect1 id=
"Copyright"><title>Copyright
</title>
734 Copyright
<trademark class=
"copyright"></trademark> 2003-
2005 3Dlabs Inc. Ltd.
735 Copyright
<trademark class=
"copyright"></trademark> 2010 Khronos Group
736 This material may be distributed subject to the terms and conditions set forth in
737 the Open Publication License, v
1.0,
8 June
1999.
738 <ulink url=
"http://opencontent.org/openpub/">http://opencontent.org/openpub/
</ulink>.