Gambas Documentation
Application Repository
Code Snippets
Compilation & Installation
Components
gb
gb.args
gb.cairo
gb.chart
gb.clipper
gb.complex
gb.compress
gb.crypt
gb.data
gb.db
gb.db.form
gb.db.mysql
gb.db.odbc
gb.db.postgresql
gb.db.sqlite2
gb.db.sqlite3
gb.dbus
gb.dbus.trayicon
gb.debug
gb.desktop
gb.desktop.gnome.keyring
gb.desktop.x11
gb.eval
gb.eval.highlight
gb.form
gb.form.dialog
gb.form.editor
gb.form.htmlview
gb.form.mdi
gb.form.print
gb.form.stock
gb.form.terminal
gb.gmp
gb.gsl
gb.gtk
gb.gtk.opengl
gb.gtk3
gb.gtk3.opengl
gb.gtk3.webview
gb.gui
gb.gui.opengl
gb.gui.qt
gb.gui.qt.ext
gb.gui.qt.opengl
gb.gui.qt.webkit
gb.gui.trayicon
gb.gui.webview
gb.hash
gb.highlight
gb.image
gb.image.effect
gb.image.imlib
gb.image.io
gb.inotify
gb.jit
gb.libxml
gb.logging
gb.map
gb.markdown
gb.media
gb.media.form
gb.memcached
gb.mime
gb.mongodb
gb.mysql
gb.ncurses
gb.net
gb.net.curl
gb.net.pop3
gb.net.smtp
gb.openal
gb.opengl
gb.opengl.glsl
Gl
ACTIVE_ATTRIBUTE_MAX_LENGTH
ACTIVE_ATTRIBUTES
ACTIVE_UNIFORM_MAX_LENGTH
ACTIVE_UNIFORMS
ATTACHED_SHADERS
AttachShader
BindAttribLocation
COMPILE_STATUS
CompileShader
CreateProgram
CreateShader
CURRENT_PROGRAM
DELETE_STATUS
DeleteProgram
DeleteShader
DetachShader
FRAGMENT_SHADER
GetAttachedShaders
GetProgramInfoLog
GetProgramiv
GetShaderInfoLog
GetShaderiv
GetShaderSource
GetUniformLocation
INFO_LOG_LENGTH
IsProgram
IsShader
LINK_STATUS
LinkProgram
SHADER_SOURCE_LENGTH
SHADER_TYPE
ShaderSource
Uniform1f
Uniform1fv
Uniform1i
Uniform1iv
Uniform2f
Uniform2fv
Uniform2i
Uniform2iv
Uniform3f
Uniform3fv
Uniform3i
Uniform3iv
Uniform4f
Uniform4fv
Uniform4i
Uniform4iv
UniformMatrix2fv
UniformMatrix2x3fv
UniformMatrix2x4fv
UniformMatrix3fv
UniformMatrix3x2fv
UniformMatrix3x4fv
UniformMatrix4fv
UniformMatrix4x2fv
UniformMatrix4x3fv
UseProgram
VALIDATE_STATUS
ValidateProgram
VERTEX_SHADER
VertexAttrib1f
VertexAttrib1fv
VertexAttrib2f
VertexAttrib2fv
VertexAttrib3f
VertexAttrib3fv
VertexAttrib4f
VertexAttrib4fv
gb.opengl.glu
gb.opengl.sge
gb.openssl
gb.option
gb.pcre
gb.pdf
gb.poppler
gb.qt4
gb.qt4.ext
gb.qt4.opengl
gb.qt4.webkit
gb.qt4.webview
gb.qt5
gb.qt5.ext
gb.qt5.opengl
gb.qt5.webkit
gb.qt5.webview
gb.qt6
gb.qt6.ext
gb.qt6.opengl
gb.qt6.webview
gb.report
gb.report2
gb.scanner
gb.sdl
gb.sdl.sound
gb.sdl2
gb.sdl2.audio
gb.settings
gb.signal
gb.term
gb.test
gb.util
gb.util.web
gb.v4l
gb.vb
gb.web
gb.web.feed
gb.web.form
gb.web.gui
gb.xml
gb.xml.html
gb.xml.rpc
gb.xml.xslt
Controls pictures
Deprecated components
Developer Documentation
Development Environment Documentation
Documents
Error Messages
Gambas Playground
How To's
Language Index
Language Overviews
Last Changes
Lexicon
README
Search the wiki
To Do
Topics
Tutorials
Wiki License
Wiki Manual

Gl.BindAttribLocation (gb.opengl.glsl)

Static Sub BindAttribLocation ( Program As Integer, Index As Integer, Name As String )

Associates a generic vertex attribute index with a named attribute variable.

Parameters

program

Specifies the handle of the program object in which the association is to be made.
index

Specifies the index of the generic vertex attribute to be bound.
name

Specifies a null terminated string containing the name of the vertex shader attribute variable to which index is to be bound.

Description

Gl.BindAttribLocation is used to associate a user-defined attribute variable in the program object specified by program with a generic vertex attribute index. The name of the user-defined attribute variable is passed as a null terminated string in name. The generic vertex attribute index to be bound to this variable is specified by index. When program is made part of current state, values provided via the generic vertex attribute index will modify the value of the user-defined attribute variable specified by name.

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

This command makes it possible for vertex shaders to use descriptive names for attribute variables rather than generic variables that are numbered from 0 to Gl.MAX_VERTEX_ATTRIBS -1. The values sent to each generic attribute index are part of current state. If a different program object is made current by calling Glu.seProgram, 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 index.

Attribute variable name-to-generic attribute index bindings for a program object can be explicitly assigned at any time by calling Gl.BindAttribLocation. Attribute bindings do not go into effect until Gl.LinkProgram 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.

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.

Notes

Gl.BindAttribLocation 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.

If name 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.

Applications are allowed to bind more than one user-defined attribute variable to the same generic vertex attribute index. This is called aliasing, 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.

Active attributes that are not explicitly bound will be bound by the linker when Gl.LinkProgram is called. The locations assigned can be queried by calling Gl.GetAttribLocation.

OpenGL copies the name string when Gl.BindAttribLocation is called, so an application may free its copy of the name string immediately after the function returns.

Generic attribute locations may be specified in the shader source text using a location layout qualifier. In this case, the location of the attribute specified in the shader's source takes precedence and may be queried by calling Gl.GetAttribLocation.

Errors

Gl.INVALID_VALUE is generated if index is greater than or equal to Gl.MAX_VERTEX_ATTRIBS.

Gl.INVALID_OPERATION is generated if name starts with the reserved prefix "gl_".

Gl.INVALID_VALUE is generated if program is not a value generated by OpenGL.

Gl.INVALID_OPERATION is generated if program is not a program object.

Associated Gets

Gl.Get with argument Gl.MAX_VERTEX_ATTRIBS

Gl.GetActiveAttrib with argument program

Gl.GetAttribLocation with arguments program and name

Gl.IsProgram

See also

Gl.DisableVertexAttribArray, Gl.EnableVertexAttribArray, Glu.seProgram, Gl.VertexAttrib, Gl.VertexAttribPointer

See original documentation on OpenGL website