| 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="glGetActiveAttrib"> |
| 5 | <refmeta> |
| 6 | <refentrytitle>glGetActiveAttrib</refentrytitle> |
| 7 | <manvolnum>3G</manvolnum> |
| 8 | </refmeta> |
| 9 | <refnamediv> |
| 10 | <refname>glGetActiveAttrib</refname> |
| 11 | <refpurpose>Returns information about an active attribute variable for the specified program object</refpurpose> |
| 12 | </refnamediv> |
| 13 | <refsynopsisdiv><title>C Specification</title> |
| 14 | <funcsynopsis> |
| 15 | <funcprototype> |
| 16 | <funcdef>void <function>glGetActiveAttrib</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> |
| 24 | </funcprototype> |
| 25 | </funcsynopsis> |
| 26 | </refsynopsisdiv> |
| 27 | <refsect1 id="parameters"><title>Parameters</title> |
| 28 | <variablelist> |
| 29 | <varlistentry> |
| 30 | <term><parameter>program</parameter></term> |
| 31 | <listitem> |
| 32 | <para>Specifies the program object to be |
| 33 | queried.</para> |
| 34 | </listitem> |
| 35 | </varlistentry> |
| 36 | <varlistentry> |
| 37 | <term><parameter>index</parameter></term> |
| 38 | <listitem> |
| 39 | <para>Specifies the index of the attribute variable |
| 40 | to be queried.</para> |
| 41 | </listitem> |
| 42 | </varlistentry> |
| 43 | <varlistentry> |
| 44 | <term><parameter>bufSize</parameter></term> |
| 45 | <listitem> |
| 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> |
| 49 | </listitem> |
| 50 | </varlistentry> |
| 51 | <varlistentry> |
| 52 | <term><parameter>length</parameter></term> |
| 53 | <listitem> |
| 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> |
| 59 | </listitem> |
| 60 | </varlistentry> |
| 61 | <varlistentry> |
| 62 | <term><parameter>size</parameter></term> |
| 63 | <listitem> |
| 64 | <para>Returns the size of the attribute |
| 65 | variable.</para> |
| 66 | </listitem> |
| 67 | </varlistentry> |
| 68 | <varlistentry> |
| 69 | <term><parameter>type</parameter></term> |
| 70 | <listitem> |
| 71 | <para>Returns the data type of the attribute |
| 72 | variable.</para> |
| 73 | </listitem> |
| 74 | </varlistentry> |
| 75 | <varlistentry> |
| 76 | <term><parameter>name</parameter></term> |
| 77 | <listitem> |
| 78 | <para>Returns a null terminated string containing |
| 79 | the name of the attribute variable.</para> |
| 80 | </listitem> |
| 81 | </varlistentry> |
| 82 | </variablelist> |
| 83 | </refsect1> |
| 84 | <refsect1 id="description"><title>Description</title> |
| 85 | <para><function>glGetActiveAttrib</function> returns information |
| 86 | about an active attribute variable in the program object |
| 87 | specified by <parameter>program</parameter>. The number of |
| 88 | active attributes can be obtained by calling |
| 89 | <citerefentry><refentrytitle>glGetProgram</refentrytitle></citerefentry> |
| 90 | with the value <constant>GL_ACTIVE_ATTRIBUTES</constant>. A |
| 91 | value of 0 for <parameter>index</parameter> selects the first |
| 92 | active attribute variable. Permissible values for |
| 93 | <parameter>index</parameter> range from 0 to the number of |
| 94 | active attribute variables minus 1.</para> |
| 95 | |
| 96 | <para>A vertex shader may use either built-in attribute |
| 97 | variables, user-defined attribute variables, or both. Built-in |
| 98 | attribute variables have a prefix of "gl_" and |
| 99 | reference conventional OpenGL vertex attribtes (e.g., |
| 100 | <parameter>gl_Vertex</parameter>, |
| 101 | <parameter>gl_Normal</parameter>, etc., see the OpenGL Shading |
| 102 | Language specification for a complete list.) User-defined |
| 103 | attribute variables have arbitrary names and obtain their values |
| 104 | through numbered generic vertex attributes. An attribute |
| 105 | variable (either built-in or user-defined) is considered active |
| 106 | if it is determined during the link operation that it may be |
| 107 | accessed during program execution. Therefore, |
| 108 | <parameter>program</parameter> should have previously been the |
| 109 | target of a call to |
| 110 | <citerefentry><refentrytitle>glLinkProgram</refentrytitle></citerefentry>, |
| 111 | but it is not necessary for it to have been linked |
| 112 | successfully.</para> |
| 113 | |
| 114 | <para>The size of the character buffer required to store the |
| 115 | longest attribute variable name in |
| 116 | <parameter>program</parameter> can be obtained by calling |
| 117 | <citerefentry><refentrytitle>glGetProgram</refentrytitle></citerefentry> |
| 118 | with the value |
| 119 | <constant>GL_ACTIVE_ATTRIBUTE_MAX_LENGTH</constant>. This value |
| 120 | should be used to allocate a buffer of sufficient size to store |
| 121 | the returned attribute name. The size of this character buffer |
| 122 | is passed in <parameter>bufSize</parameter>, and a pointer to |
| 123 | this character buffer is passed in |
| 124 | <parameter>name</parameter>.</para> |
| 125 | |
| 126 | <para><function>glGetActiveAttrib</function> returns the name of |
| 127 | the attribute 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> |
| 136 | |
| 137 | <para>The <parameter>type</parameter> argument will return a |
| 138 | pointer to the attribute variable's data type. The symbolic |
| 139 | constants <constant>GL_FLOAT</constant>, |
| 140 | <constant>GL_FLOAT_VEC2</constant>, |
| 141 | <constant>GL_FLOAT_VEC3</constant>, |
| 142 | <constant>GL_FLOAT_VEC4</constant>, |
| 143 | <constant>GL_FLOAT_MAT2</constant>, |
| 144 | <constant>GL_FLOAT_MAT3</constant>, |
| 145 | <constant>GL_FLOAT_MAT4</constant>, |
| 146 | <constant>GL_FLOAT_MAT2x3</constant>, |
| 147 | <constant>GL_FLOAT_MAT2x4</constant>, |
| 148 | <constant>GL_FLOAT_MAT3x2</constant>, |
| 149 | <constant>GL_FLOAT_MAT3x4</constant>, |
| 150 | <constant>GL_FLOAT_MAT4x2</constant>, or |
| 151 | <constant>GL_FLOAT_MAT4x3</constant> may be returned. The |
| 152 | <parameter>size</parameter> argument will return the size of the |
| 153 | attribute, in units of the type returned in |
| 154 | <parameter>type</parameter>.</para> |
| 155 | |
| 156 | <para>The list of active attribute variables may include both |
| 157 | built-in attribute variables (which begin with the prefix |
| 158 | "gl_") as well as user-defined attribute variable |
| 159 | names.</para> |
| 160 | |
| 161 | <para>This function will return as much information as it can |
| 162 | about the specified active attribute variable. If no information |
| 163 | is available, <parameter>length</parameter> will be 0, and |
| 164 | <parameter>name</parameter> will be an empty string. This |
| 165 | situation could occur if this function is called after a link |
| 166 | operation that failed. If an error occurs, the return values |
| 167 | <parameter>length</parameter>, <parameter>size</parameter>, |
| 168 | <parameter>type</parameter>, and <parameter>name</parameter> |
| 169 | will be unmodified.</para> |
| 170 | </refsect1> |
| 171 | <refsect1 id="notes"><title>Notes</title> |
| 172 | <para><function>glGetActiveAttrib</function> |
| 173 | is available only if the GL version is 2.0 or greater.</para> |
| 174 | |
| 175 | <para><constant>GL_FLOAT_MAT2x3</constant>, |
| 176 | <constant>GL_FLOAT_MAT2x4</constant>, |
| 177 | <constant>GL_FLOAT_MAT3x2</constant>, |
| 178 | <constant>GL_FLOAT_MAT3x4</constant>, |
| 179 | <constant>GL_FLOAT_MAT4x2</constant>, and |
| 180 | <constant>GL_FLOAT_MAT4x3</constant> |
| 181 | will only be returned as a <parameter>type</parameter> |
| 182 | if the GL version is 2.1 or greater.</para> |
| 183 | </refsect1> |
| 184 | <refsect1 id="errors"><title>Errors</title> |
| 185 | <para><constant>GL_INVALID_VALUE</constant> is generated if |
| 186 | <parameter>program</parameter> is not a value generated by |
| 187 | OpenGL.</para> |
| 188 | |
| 189 | <para><constant>GL_INVALID_OPERATION</constant> is generated if |
| 190 | <parameter>program</parameter> is not a program object.</para> |
| 191 | |
| 192 | <para><constant>GL_INVALID_VALUE</constant> is generated if |
| 193 | <parameter>index</parameter> is greater than or equal to the |
| 194 | number of active attribute variables in |
| 195 | <parameter>program</parameter>.</para> |
| 196 | |
| 197 | <para><constant>GL_INVALID_OPERATION</constant> is generated if |
| 198 | <function>glGetActiveAttrib</function> is executed between the |
| 199 | execution of |
| 200 | <citerefentry><refentrytitle>glBegin</refentrytitle></citerefentry> |
| 201 | and the corresponding execution of |
| 202 | <citerefentry><refentrytitle>glEnd</refentrytitle></citerefentry>.</para> |
| 203 | |
| 204 | <para><constant>GL_INVALID_VALUE</constant> is generated if |
| 205 | <parameter>bufSize</parameter> is less than 0.</para> |
| 206 | </refsect1> |
| 207 | <refsect1 id="associatedgets"><title>Associated Gets</title> |
| 208 | <para><citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> |
| 209 | with argument <constant>GL_MAX_VERTEX_ATTRIBS</constant>.</para> |
| 210 | |
| 211 | <para><citerefentry><refentrytitle>glGetProgram</refentrytitle></citerefentry> |
| 212 | with argument <constant>GL_ACTIVE_ATTRIBUTES</constant> or |
| 213 | <constant>GL_ACTIVE_ATTRIBUTE_MAX_LENGTH</constant>.</para> |
| 214 | |
| 215 | <para><citerefentry><refentrytitle>glIsProgram</refentrytitle></citerefentry></para> |
| 216 | </refsect1> |
| 217 | <refsect1 id="seealso"><title>See Also</title> |
| 218 | <para><citerefentry><refentrytitle>glBindAttribLocation</refentrytitle></citerefentry>, |
| 219 | <citerefentry><refentrytitle>glLinkProgram</refentrytitle></citerefentry>, |
| 220 | <citerefentry><refentrytitle>glVertexAttrib</refentrytitle></citerefentry>, |
| 221 | <citerefentry><refentrytitle>glVertexAttribPointer</refentrytitle></citerefentry></para> |
| 222 | </refsect1> |
| 223 | <refsect1 id="Copyright"><title>Copyright</title> |
| 224 | <para> |
| 225 | Copyright <trademark class="copyright"></trademark> 2003-2005 3Dlabs Inc. Ltd. |
| 226 | This material may be distributed subject to the terms and conditions set forth in |
| 227 | the Open Publication License, v 1.0, 8 June 1999. |
| 228 | <ulink url="http://opencontent.org/openpub/">http://opencontent.org/openpub/</ulink>. |
| 229 | </para> |
| 230 | </refsect1> |
| 231 | </refentry> |