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.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.LinkProgram (gb.opengl.glsl)

Static Sub LinkProgram ( Program As Integer )

Links a program object.

Parameters

program

Specifies the handle of the program object to be linked.

Description

Gl.LinkProgram links the program object specified by program. If any shader objects of type Gl.VERTEX_SHADER are attached to program, they will be used to create an executable that will run on the programmable vertex processor. If any shader objects of type Gl.GEOMETRY_SHADER are attached to program, they will be used to create an executable that will run on the programmable geometry processor. If any shader objects of type Gl.FRAGMENT_SHADER are attached to program, they will be used to create an executable that will run on the programmable fragment processor.

The status of the link operation will be stored as part of the program object's state. This value will be set to Gl.TRUE if the program object was linked without errors and is ready for use, and Gl.FALSE otherwise. It can be queried by calling Gl.GetProgram with arguments program and Gl.LINK_STATUS.

As a result of a successful link operation, all active user-defined uniform variables belonging to program will be initialized to 0, and each of the program object's active uniform variables will be assigned a location that can be queried by calling Gl.GetUniformLocation. Also, any active user-defined attribute variables that have not been bound to a generic vertex attribute index will be bound to one at this time.

Linking of a program object can fail for a number of reasons as specified in the OpenGL Shading Language Specification. The following lists some of the conditions that will cause a link error.
  • The number of active attribute variables supported by the implementation has been exceeded.
  • The storage limit for uniform variables has been exceeded.
  • The number of active uniform variables supported by the implementation has been exceeded.
  • The main function is missing for the vertex, geometry or fragment shader.
  • A varying variable actually used in the fragment shader is not declared in the same way (or is not declared at all) in the vertex shader, or geometry shader shader if present.
  • A reference to a function or variable name is unresolved.
  • A shared global is declared with two different types or two different initial values.
  • One or more of the attached shader objects has not been successfully compiled.
  • Binding a generic attribute matrix caused some rows of the matrix to fall outside the allowed maximum of Gl.MAX_VERTEX_ATTRIBS.
  • Not enough contiguous vertex attribute slots could be found to bind attribute matrices.
  • The program object contains objects to form a fragment shader but does not contain objects to form a vertex shader.
  • The program object contains objects to form a geometry shader but does not contain objects to form a vertex shader.
  • The program object contains objects to form a geometry shader and the input primitive type, output primitive type, or maximum output vertex count is not specified in any compiled geometry shader object.
  • The program object contains objects to form a geometry shader and the input primitive type, output primitive type, or maximum output vertex count is specified differently in multiple geometry shader objects.
  • The number of active outputs in the fragment shader is greater than the value of Gl.MAX_DRAW_BUFFERS.
  • The program has an active output assigned to a location greater than or equal to the value of Gl.MAX_DUAL_SOURCE_DRAW_BUFFERS and has an active output assigned an index greater than or equal to one.
  • More than one varying out variable is bound to the same number and index.
  • The explicit binding assigments do not leave enough space for the linker to automatically assign a location for a varying out array, which requires multiple contiguous locations.
  • The count specified by Gl.TransformFeedbackVaryings is non-zero, but the program object has no vertex or geometry shader.
  • Any variable name specified to Gl.TransformFeedbackVaryings in the varyings array is not declared as an output in the vertex shader (or the geometry shader, if active).
  • Any two entries in the varyings array given Gl.TransformFeedbackVaryings specify the same varying variable.
  • The total number of components to capture in any transform feedback varying variable is greater than the constant Gl.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS and the buffer mode is SEPARATE_ATTRIBS.

When a program object has been successfully linked, the program object can be made part of current state by calling Glu.seProgram. Whether or not the link operation was successful, the program object's information log will be overwritten. The information log can be retrieved by calling Gl.GetProgramInfoLog.

Gl.LinkProgram will also install the generated executables as part of the current rendering state if the link operation was successful and the specified program object is already currently in use as a result of a previous call to Glu.seProgram. If the program object currently in use is relinked unsuccessfully, its link status will be set to Gl.FALSE , but the executables and associated state will remain part of the current state until a subsequent call to Glu.seProgram removes it from use. After it is removed from use, it cannot be made part of current state until it has been successfully relinked.

If program contains shader objects of type Gl.VERTEX_SHADER, and optionally of type Gl.GEOMETRY_SHADER, but does not contain shader objects of type Gl.FRAGMENT_SHADER, the vertex shader executable will be installed on the programmable vertex processor, the geometry shader executable, if present, will be installed on the programmable geometry processor, but no executable will be installed on the fragment processor. The results of rasterizing primitives with such a program will be undefined.

The program object's information log is updated and the program is generated at the time of the link operation. After the link operation, applications are free to modify attached shader objects, compile attached shader objects, detach shader objects, delete shader objects, and attach additional shader objects. None of these operations affects the information log or the program that is part of the program object.

Notes

If the link operation is unsuccessful, any information about a previous link operation on program is lost (i.e., a failed link does not restore the old state of program ). Certain information can still be retrieved from program even after an unsuccessful link operation. See for instance Gl.GetActiveAttrib and Gl.GetActiveUniform.

Errors

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.

Gl.INVALID_OPERATION is generated if program is the currently active program object and transform feedback mode is active.

Associated Gets

Gl.Get with the argument Gl.CURRENT_PROGRAM

Gl.GetActiveAttrib with argument program and the index of an active attribute variable

Gl.GetActiveUniform with argument program and the index of an active uniform variable_

Gl.GetAttachedShaders with argument program

Gl.GetAttribLocation with argument program and an attribute variable name

Gl.GetProgram with arguments program and Gl.LINK_STATUS

Gl.GetProgramInfoLog with argument program

Gl.GetUniform with argument program and a uniform variable location

Gl.GetUniformLocation with argument program and a uniform variable name

Gl.IsProgram

See also

See original documentation on OpenGL website