File: glBindAttribLocation.xml

package info (click to toggle)
khronos-opengl-man4 1.0~svn27841-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 24,888 kB
  • ctags: 377
  • sloc: xml: 188,408; makefile: 1,153; python: 736; sh: 49; php: 7; sed: 2
file content (197 lines) | stat: -rw-r--r-- 9,643 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook MathML Module V1.1b1//EN"
          "http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd">
<refentry id="glBindAttribLocation">
    <refentryinfo>
        <copyright>
            <year>2003-2005</year>
            <holder>3Dlabs Inc. Ltd.</holder>
        </copyright>
        <copyright>
            <year>2010-2013</year>
            <holder>Khronos Group</holder>
        </copyright>
    </refentryinfo>
    <refmeta>
        <refentrytitle>glBindAttribLocation</refentrytitle>
        <manvolnum>3G</manvolnum>
    </refmeta>
    <refnamediv>
        <refname>glBindAttribLocation</refname>
        <refpurpose>Associates a generic vertex attribute index with a named attribute variable</refpurpose>
    </refnamediv>
    <refsynopsisdiv><title>C Specification</title>
    <funcsynopsis>
        <funcprototype>
        <funcdef>void <function>glBindAttribLocation</function></funcdef>
        <paramdef>GLuint <parameter>program</parameter></paramdef>
        <paramdef>GLuint <parameter>index</parameter></paramdef>
        <paramdef>const GLchar *<parameter>name</parameter></paramdef>
        </funcprototype>
    </funcsynopsis>
    </refsynopsisdiv>
    <refsect1 id="parameters"><title>Parameters</title>
    <variablelist>
        <varlistentry>
        <term><parameter>program</parameter></term>
        <listitem>
            <para>Specifies the handle of the program object in
            which the association is to be made.</para>
        </listitem>
        </varlistentry>
        <varlistentry>
        <term><parameter>index</parameter></term>
        <listitem>
            <para>Specifies the index of the generic vertex
            attribute to be bound.</para>
        </listitem>
        </varlistentry>
        <varlistentry>
        <term><parameter>name</parameter></term>
        <listitem>
            <para>Specifies a null terminated string containing
            the name of the vertex shader attribute variable to
            which <parameter>index</parameter> is to be
            bound.</para>
        </listitem>
        </varlistentry>
    </variablelist>
    </refsect1>
    <refsect1 id="description"><title>Description</title>
    <para><function>glBindAttribLocation</function> is used to
    associate a user-defined attribute variable in the program
    object specified by <parameter>program</parameter> with a
    generic vertex attribute index. The name of the user-defined
    attribute variable is passed as a null terminated string in
    <parameter>name</parameter>. The generic vertex attribute index
    to be bound to this variable is specified by
    <parameter>index</parameter>. When
    <parameter>program</parameter> is made part of current state,
    values provided via the generic vertex attribute
    <parameter>index</parameter> will modify the value of the
    user-defined attribute variable specified by
    <parameter>name</parameter>.</para>

    <para>If <parameter>name</parameter> refers to a matrix
    attribute variable, <parameter>index</parameter> refers to the
    first column of the matrix. Other matrix columns are then
    automatically bound to locations <parameter>index+1</parameter>
    for a matrix of type <function>mat2</function>; <parameter>index+1</parameter> and
    <parameter>index+2</parameter> for a matrix of type <function>mat3</function>; and
    <parameter>index+1</parameter>, <parameter>index+2</parameter>,
    and <parameter>index+3</parameter> for a matrix of type
    <function>mat4</function>.</para>

    <para>This command makes it possible for vertex shaders to use
    descriptive names for attribute variables rather than generic
    variables that are numbered from zero to the value of
    <constant>GL_MAX_VERTEX_ATTRIBS</constant> minus one. The values sent
    to each generic attribute index are part of current state.
    If a different program object is made current by calling
    <citerefentry><refentrytitle>glUseProgram</refentrytitle></citerefentry>,
    the generic vertex attributes are tracked in such a way that the
    same values will be observed by attributes in the new program
    object that are also bound to
    <parameter>index</parameter>.</para> <para>Attribute variable
    name-to-generic attribute index bindings for a program object
    can be explicitly assigned at any time by calling
    <function>glBindAttribLocation</function>. Attribute bindings do
    not go into effect until
    <citerefentry><refentrytitle>glLinkProgram</refentrytitle></citerefentry>
    is called. After a program object has been linked successfully,
    the index values for generic attributes remain fixed (and their
    values can be queried) until the next link command
    occurs.</para>

    <para>Any attribute binding that occurs after the program object has been linked will not take effect
    until the next time the program object is linked.</para>
    </refsect1>
    <refsect1 id="notes"><title>Notes</title>
    <para><function>glBindAttribLocation</function> can be called
    before any vertex shader objects are bound to the specified
    program object. It is also permissible to bind a generic
    attribute index to an attribute variable name that is never used
    in a vertex shader.</para>

    <para>If <parameter>name</parameter> was bound previously, that
    information is lost. Thus you cannot bind one user-defined
    attribute variable to multiple indices, but you can bind
    multiple user-defined attribute variables to the same
    index.</para>

    <para>Applications are allowed to bind more than one
    user-defined attribute variable to the same generic vertex
    attribute index. This is called <emphasis>aliasing</emphasis>,
    and it is allowed only if just one of the aliased attributes is
    active in the executable program, or if no path through the
    shader consumes more than one attribute of a set of attributes
    aliased to the same location. The compiler and linker are
    allowed to assume that no aliasing is done and are free to
    employ optimizations that work only in the absence of aliasing.
    OpenGL implementations are not required to do error checking to
    detect aliasing.</para>

    <para>Active attributes that are not explicitly bound will be
    bound by the linker when
    <citerefentry><refentrytitle>glLinkProgram</refentrytitle></citerefentry>
    is called. The locations assigned can be queried by calling
    <citerefentry><refentrytitle>glGetAttribLocation</refentrytitle></citerefentry>.</para>

    <para>OpenGL copies the <parameter>name</parameter> string when
    <function>glBindAttribLocation</function> is called, so an
    application may free its copy of the <parameter>name</parameter>
    string immediately after the function returns.</para>

    <para>Generic attribute locations may be specified in the shader source
    text using a <function>location</function> layout qualifier. In this case,
    the location of the attribute specified in the shader's source takes precedence
    and may be queried by calling <citerefentry><refentrytitle>glGetAttribLocation</refentrytitle></citerefentry>.
    </para>
    </refsect1>
    <refsect1 id="errors"><title>Errors</title>
    <para><constant>GL_INVALID_VALUE</constant> is generated if
    <parameter>index</parameter> is greater than or equal to
    <constant>GL_MAX_VERTEX_ATTRIBS</constant>.</para>

    <para><constant>GL_INVALID_OPERATION</constant> is generated if
    <parameter>name</parameter> starts with the reserved prefix
    &quot;gl_&quot;.</para>

    <para><constant>GL_INVALID_VALUE</constant> is generated if
    <parameter>program</parameter> is not a value generated by
    OpenGL.</para>

    <para><constant>GL_INVALID_OPERATION</constant> is generated if
    <parameter>program</parameter> is not a program object.</para>

    </refsect1>
    <refsect1 id="associatedgets"><title>Associated Gets</title>
    <para><citerefentry><refentrytitle>glGet</refentrytitle></citerefentry>
    with argument <constant>GL_MAX_VERTEX_ATTRIBS</constant></para>

    <para><citerefentry><refentrytitle>glGetActiveAttrib</refentrytitle></citerefentry>
    with argument <parameter>program</parameter></para>

    <para><citerefentry><refentrytitle>glGetAttribLocation</refentrytitle></citerefentry>
    with arguments <parameter>program</parameter> and
    <parameter>name</parameter></para>

    <para><citerefentry><refentrytitle>glIsProgram</refentrytitle></citerefentry></para>
    </refsect1>
    <refsect1 id="seealso"><title>See Also</title>
    <para><citerefentry><refentrytitle>glDisableVertexAttribArray</refentrytitle></citerefentry>,
    <citerefentry><refentrytitle>glEnableVertexAttribArray</refentrytitle></citerefentry>,
    <citerefentry><refentrytitle>glUseProgram</refentrytitle></citerefentry>,
    <citerefentry><refentrytitle>glVertexAttrib</refentrytitle></citerefentry>,
    <citerefentry><refentrytitle>glVertexAttribPointer</refentrytitle></citerefentry></para>
    </refsect1>
    <refsect1 id="Copyright"><title>Copyright</title>
        <para>
            Copyright <trademark class="copyright"></trademark> 2003-2005 3Dlabs Inc. Ltd.
            Copyright <trademark class="copyright"></trademark> 2010-2013 Khronos Group.
            This material may be distributed subject to the terms and conditions set forth in
            the Open Publication License, v 1.0, 8 June 1999.
            <ulink url="http://opencontent.org/openpub/">http://opencontent.org/openpub/</ulink>.
        </para>
    </refsect1>
</refentry>