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="glGetUniformLocation"> | |
5 | <refmeta> | |
6 | <refentrytitle>glGetUniformLocation</refentrytitle> | |
7 | <manvolnum>3G</manvolnum> | |
8 | </refmeta> | |
9 | <refnamediv> | |
10 | <refname>glGetUniformLocation</refname> | |
11 | <refpurpose>Returns the location of a uniform variable</refpurpose> | |
12 | </refnamediv> | |
13 | <refsynopsisdiv><title>C Specification</title> | |
14 | <funcsynopsis> | |
15 | <funcprototype> | |
16 | <funcdef>GLint <function>glGetUniformLocation</function></funcdef> | |
17 | <paramdef>GLuint <parameter>program</parameter></paramdef> | |
18 | <paramdef>const GLchar *<parameter>name</parameter></paramdef> | |
19 | </funcprototype> | |
20 | </funcsynopsis> | |
21 | </refsynopsisdiv> | |
22 | <refsect1 id="parameters"><title>Parameters</title> | |
23 | <variablelist> | |
24 | <varlistentry> | |
25 | <term><parameter>program</parameter></term> | |
26 | <listitem> | |
27 | <para>Specifies the program object to be | |
28 | queried.</para> | |
29 | </listitem> | |
30 | </varlistentry> | |
31 | <varlistentry> | |
32 | <term><parameter>name</parameter></term> | |
33 | <listitem> | |
34 | <para>Points to a null terminated string containing | |
35 | the name of the uniform variable whose location is | |
36 | to be queried.</para> | |
37 | </listitem> | |
38 | </varlistentry> | |
39 | </variablelist> | |
40 | </refsect1> | |
41 | <refsect1 id="description"><title>Description</title> | |
42 | <para><function>glGetUniformLocation </function> returns an | |
43 | integer that represents the location of a specific uniform | |
44 | variable within a program object. <parameter>name</parameter> | |
45 | must be a null terminated string that contains no white space. | |
46 | <parameter>name</parameter> must be an active uniform variable | |
47 | name in <parameter>program</parameter> that is not a structure, | |
48 | an array of structures, or a subcomponent of a vector or a | |
49 | matrix. This function returns -1 if <parameter>name</parameter> | |
50 | does not correspond to an active uniform variable in | |
51 | <parameter>program</parameter> or if <parameter>name</parameter> | |
52 | starts with the reserved prefix "gl_".</para> | |
53 | ||
54 | <para>Uniform variables that are structures or arrays of | |
55 | structures may be queried by calling | |
56 | <function>glGetUniformLocation</function> for each field within | |
57 | the structure. The array element operator "[]" and the | |
58 | structure field operator "." may be used in | |
59 | <parameter>name</parameter> in order to select elements within | |
60 | an array or fields within a structure. The result of using these | |
61 | operators is not allowed to be another structure, an array of | |
62 | structures, or a subcomponent of a vector or a matrix. Except if | |
63 | the last part of <parameter>name</parameter> indicates a uniform | |
64 | variable array, the location of the first element of an array | |
65 | can be retrieved by using the name of the array, or by using the | |
66 | name appended by "[0]".</para> | |
67 | ||
68 | <para>The actual locations assigned to uniform variables are not | |
69 | known until the program object is linked successfully. After | |
70 | linking has occurred, the command | |
71 | <function>glGetUniformLocation</function> can be used to obtain | |
72 | the location of a uniform variable. This location value can then | |
73 | be passed to | |
74 | <citerefentry><refentrytitle>glUniform</refentrytitle></citerefentry> | |
75 | to set the value of the uniform variable or to | |
76 | <citerefentry><refentrytitle>glGetUniform</refentrytitle></citerefentry> | |
77 | in order to query the current value of the uniform variable. | |
78 | After a program object has been linked successfully, the index | |
79 | values for uniform variables remain fixed until the next link | |
80 | command occurs. Uniform variable locations and values can only | |
81 | be queried after a link if the link was successful.</para> | |
82 | </refsect1> | |
83 | <refsect1 id="notes"><title>Notes</title> | |
84 | <para><function>glGetUniformLocation</function> is available | |
85 | only if the GL version is 2.0 or greater.</para> | |
86 | </refsect1> | |
87 | <refsect1 id="errors"><title>Errors</title> | |
88 | <para><constant>GL_INVALID_VALUE</constant> is generated if | |
89 | <parameter>program</parameter> is not a value generated by | |
90 | OpenGL.</para> | |
91 | ||
92 | <para><constant>GL_INVALID_OPERATION</constant> is generated if | |
93 | <parameter>program</parameter> is not a program object.</para> | |
94 | ||
95 | <para><constant>GL_INVALID_OPERATION</constant> is generated if | |
96 | <parameter>program</parameter> has not been successfully | |
97 | linked.</para> | |
98 | ||
99 | <para><constant>GL_INVALID_OPERATION</constant> is generated if | |
100 | <function>glGetUniformLocation</function> is executed between | |
101 | the execution of | |
102 | <citerefentry><refentrytitle>glBegin</refentrytitle></citerefentry> | |
103 | and the corresponding execution of | |
104 | <citerefentry><refentrytitle>glEnd</refentrytitle></citerefentry>.</para> | |
105 | </refsect1> | |
106 | <refsect1 id="associatedgets"><title>Associated Gets</title> | |
107 | <para><citerefentry><refentrytitle>glGetActiveUniform</refentrytitle></citerefentry> | |
108 | with arguments <parameter>program</parameter> and the index of | |
109 | an active uniform variable</para> | |
110 | ||
111 | <para><citerefentry><refentrytitle>glGetProgram</refentrytitle></citerefentry> | |
112 | with arguments <parameter>program</parameter> and | |
113 | <constant>GL_ACTIVE_UNIFORMS</constant> or | |
114 | <constant>GL_ACTIVE_UNIFORM_MAX_LENGTH</constant></para> | |
115 | ||
116 | <para><citerefentry><refentrytitle>glGetUniform</refentrytitle></citerefentry> | |
117 | with arguments <parameter>program</parameter> and the name of a | |
118 | uniform variable</para> | |
119 | <para><citerefentry><refentrytitle>glIsProgram</refentrytitle></citerefentry></para> | |
120 | </refsect1> | |
121 | <refsect1 id="seealso"><title>See Also</title> | |
122 | <para><citerefentry><refentrytitle>glLinkProgram</refentrytitle></citerefentry>, | |
123 | <citerefentry><refentrytitle>glUniform</refentrytitle></citerefentry></para> | |
124 | </refsect1> | |
125 | <refsect1 id="Copyright"><title>Copyright</title> | |
126 | <para> | |
127 | Copyright <trademark class="copyright"></trademark> 2003-2005 3Dlabs Inc. Ltd. | |
128 | This material may be distributed subject to the terms and conditions set forth in | |
129 | the Open Publication License, v 1.0, 8 June 1999. | |
130 | <ulink url="http://opencontent.org/openpub/">http://opencontent.org/openpub/</ulink>. | |
131 | </para> | |
132 | </refsect1> | |
133 | </refentry> |