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="glUseProgram"> | |
5 | <refmeta> | |
6 | <refentrytitle>glUseProgram</refentrytitle> | |
7 | <manvolnum>3G</manvolnum> | |
8 | </refmeta> | |
9 | <refnamediv> | |
10 | <refname>glUseProgram</refname> | |
11 | <refpurpose>Installs a program object as part of current rendering state</refpurpose> | |
12 | </refnamediv> | |
13 | <refsynopsisdiv><title>C Specification</title> | |
14 | <funcsynopsis> | |
15 | <funcprototype> | |
16 | <funcdef>void <function>glUseProgram</function></funcdef> | |
17 | <paramdef>GLuint <parameter>program</parameter></paramdef> | |
18 | </funcprototype> | |
19 | </funcsynopsis> | |
20 | </refsynopsisdiv> | |
21 | <refsect1 id="parameters"><title>Parameters</title> | |
22 | <variablelist> | |
23 | <varlistentry> | |
24 | <term><parameter>program</parameter></term> | |
25 | <listitem> | |
26 | <para>Specifies the handle of the program object | |
27 | whose executables are to be used as part of current | |
28 | rendering state.</para> | |
29 | </listitem> | |
30 | </varlistentry> | |
31 | </variablelist> | |
32 | </refsect1> | |
33 | <refsect1 id="description"><title>Description</title> | |
34 | <para><function>glUseProgram</function> installs the program | |
35 | object specified by <parameter>program</parameter> as part of | |
36 | current rendering state. One or more executables are created in | |
37 | a program object by successfully attaching shader objects to it | |
38 | with | |
39 | <citerefentry><refentrytitle>glAttachShader</refentrytitle></citerefentry>, | |
40 | successfully compiling the shader objects with | |
41 | <citerefentry><refentrytitle>glCompileShader</refentrytitle></citerefentry>, | |
42 | and successfully linking the program object with | |
43 | <citerefentry><refentrytitle>glLinkProgram</refentrytitle></citerefentry>. | |
44 | </para> | |
45 | ||
46 | <para>A program object will contain an executable that will run | |
47 | on the vertex processor if it contains one or more shader | |
48 | objects of type <constant>GL_VERTEX_SHADER</constant> that have | |
49 | been successfully compiled and linked. A program object will contain an | |
50 | executable that will run on the geometry processor if it contains one or | |
51 | more shader objects of type <constant>GL_GEOMETRY_SHADER</constant> that | |
52 | have been successfully compiled and linked. | |
53 | Similarly, a program object will contain an executable that will run on the | |
54 | fragment processor if it contains one or more shader objects of type | |
55 | <constant>GL_FRAGMENT_SHADER</constant> that have been | |
56 | successfully compiled and linked.</para> | |
57 | ||
58 | <para>While a program object is in use, applications are free to | |
59 | modify attached shader objects, compile attached shader objects, | |
60 | attach additional shader objects, and detach or delete shader | |
61 | objects. None of these operations will affect the executables | |
62 | that are part of the current state. However, relinking the | |
63 | program object that is currently in use will install the program | |
64 | object as part of the current rendering state if the link | |
65 | operation was successful (see | |
66 | <citerefentry><refentrytitle>glLinkProgram</refentrytitle></citerefentry> | |
67 | ). If the program object currently in use is relinked | |
68 | unsuccessfully, its link status will be set to | |
69 | <constant>GL_FALSE</constant>, but the executables and | |
70 | associated state will remain part of the current state until a | |
71 | subsequent call to <function>glUseProgram</function> removes it | |
72 | from use. After it is removed from use, it cannot be made part | |
73 | of current state until it has been successfully relinked.</para> | |
74 | ||
75 | <para>If <parameter>program</parameter> is zero, then the current rendering | |
76 | state refers to an <emphasis>invalid</emphasis> program object and the | |
77 | results of shader execution are undefined. However, this is not an error.</para> | |
78 | ||
79 | <para>If <parameter>program</parameter> does not | |
80 | contain shader objects of type <constant>GL_FRAGMENT_SHADER</constant>, an | |
81 | executable will be installed on the vertex, and possibly geometry processors, | |
82 | but the results of fragment shader execution will be undefined.</para> | |
83 | </refsect1> | |
84 | <refsect1 id="notes"><title>Notes</title> | |
85 | <para>Like buffer and texture objects, the name space for | |
86 | program objects may be shared across a set of contexts, as long | |
87 | as the server sides of the contexts share the same address | |
88 | space. If the name space is shared across contexts, any attached | |
89 | objects and the data associated with those attached objects are | |
90 | shared as well.</para> | |
91 | ||
92 | <para>Applications are responsible for providing the | |
93 | synchronization across API calls when objects are accessed from | |
94 | different execution threads.</para> | |
95 | ||
96 | </refsect1> | |
97 | <refsect1 id="errors"><title>Errors</title> | |
98 | <para><constant>GL_INVALID_VALUE</constant> is generated if | |
99 | <parameter>program</parameter> is neither 0 nor a value | |
100 | generated by OpenGL.</para> | |
101 | ||
102 | <para><constant>GL_INVALID_OPERATION</constant> is generated if | |
103 | <parameter>program</parameter> is not a program object.</para> | |
104 | ||
105 | <para><constant>GL_INVALID_OPERATION</constant> is generated if | |
106 | <parameter>program</parameter> could not be made part of current | |
107 | state.</para> | |
108 | ||
109 | <para><constant>GL_INVALID_OPERATION</constant> is generated if | |
110 | transform feedback mode is active.</para> | |
111 | ||
112 | </refsect1> | |
113 | <refsect1 id="associatedgets"><title>Associated Gets</title> | |
114 | <para><citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> | |
115 | with the argument <constant>GL_CURRENT_PROGRAM</constant></para> | |
116 | ||
117 | <para><citerefentry><refentrytitle>glGetActiveAttrib</refentrytitle></citerefentry> | |
118 | with a valid program object and the index of an active attribute | |
119 | variable</para> | |
120 | ||
121 | <para><citerefentry><refentrytitle>glGetActiveUniform</refentrytitle></citerefentry> | |
122 | with a valid program object and the index of an active uniform | |
123 | variable</para> | |
124 | ||
125 | <para><citerefentry><refentrytitle>glGetAttachedShaders</refentrytitle></citerefentry> | |
126 | with a valid program object</para> | |
127 | ||
128 | <para><citerefentry><refentrytitle>glGetAttribLocation</refentrytitle></citerefentry> | |
129 | with a valid program object and the name of an attribute | |
130 | variable</para> | |
131 | ||
132 | <para><citerefentry><refentrytitle>glGetProgram</refentrytitle></citerefentry> | |
133 | with a valid program object and the parameter to be queried</para> | |
134 | ||
135 | <para><citerefentry><refentrytitle>glGetProgramInfoLog</refentrytitle></citerefentry> | |
136 | with a valid program object</para> | |
137 | ||
138 | <para><citerefentry><refentrytitle>glGetUniform</refentrytitle></citerefentry> | |
139 | with a valid program object and the location of a uniform | |
140 | variable</para> | |
141 | ||
142 | <para><citerefentry><refentrytitle>glGetUniformLocation</refentrytitle></citerefentry> | |
143 | with a valid program object and the name of a uniform | |
144 | variable</para> | |
145 | ||
146 | <para><citerefentry><refentrytitle>glIsProgram</refentrytitle></citerefentry></para> | |
147 | </refsect1> | |
148 | <refsect1 id="seealso"><title>See Also</title> | |
149 | <para><citerefentry><refentrytitle>glAttachShader</refentrytitle></citerefentry>, | |
150 | <citerefentry><refentrytitle>glBindAttribLocation</refentrytitle></citerefentry>, | |
151 | <citerefentry><refentrytitle>glCompileShader</refentrytitle></citerefentry>, | |
152 | <citerefentry><refentrytitle>glCreateProgram</refentrytitle></citerefentry>, | |
153 | <citerefentry><refentrytitle>glDeleteProgram</refentrytitle></citerefentry>, | |
154 | <citerefentry><refentrytitle>glDetachShader</refentrytitle></citerefentry>, | |
155 | <citerefentry><refentrytitle>glLinkProgram</refentrytitle></citerefentry>, | |
156 | <citerefentry><refentrytitle>glUniform</refentrytitle></citerefentry>, | |
157 | <citerefentry><refentrytitle>glValidateProgram</refentrytitle></citerefentry>, | |
158 | <citerefentry><refentrytitle>glVertexAttrib</refentrytitle></citerefentry></para> | |
159 | </refsect1> | |
160 | <refsect1 id="Copyright"><title>Copyright</title> | |
161 | <para> | |
162 | Copyright <trademark class="copyright"></trademark> 2003-2005 3Dlabs Inc. Ltd. | |
163 | This material may be distributed subject to the terms and conditions set forth in | |
164 | the Open Publication License, v 1.0, 8 June 1999. | |
165 | <ulink url="http://opencontent.org/openpub/">http://opencontent.org/openpub/</ulink>. | |
166 | </para> | |
167 | </refsect1> | |
168 | </refentry> |