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

Static Sub UseProgram ( Program As Integer )

Installs a program object as part of current rendering state

Parameters

  • Program Specifies the handle of the program object whose executables are to be used as part of current rendering state.

Description

Gl.UseProgram installs the program object specified by Program as part of current rendering state. One or more executables are created in a program object by successfully attaching shader objects to it with Gl.AttachShader, successfully compiling the shader objects with Gl.CompileShader, and successfully linking the program object with Gl.LinkProgram.

A program object will contain an executable that will run on the vertex processor if it contains one or more shader objects of type Gl.GL_VERTEX_SHADER that have been successfully compiled and linked. Similarly, a program object will contain an executable that will run on the fragment processor if it contains one or more shader objects of type Gl.GL_FRAGMENT_SHADER that have been successfully compiled and linked.

Successfully installing an executable on a programmable processor will cause the corresponding fixed functionality of OpenGL to be disabled. Specifically, if an executable is installed on the vertex processor, the OpenGL fixed functionality will be disabled as follows:
  • The modelview matrix is not applied to vertex coordinates.

  • The projection matrix is not applied to vertex coordinates.

  • The texture matrices are not applied to texture coordinates.

  • Normals are not transformed to eye coordinates.

  • Normals are not rescaled or normalized.

  • Normalization of Gl.GL_AUTO_NORMAL evaluated normals is not performed.

  • Texture coordinates are not generated automatically.

  • Per-vertex lighting is not performed.

  • Color material computations are not performed.

  • Color index lighting is not performed.

  • This list also applies when setting the current raster position.

    The executable that is installed on the vertex processor is expected to implement any or all of the desired functionality from the preceding list. Similarly, if an executable is installed on the fragment processor, the OpenGL fixed functionality will be disabled as follows:

  • Texture environment and texture functions are not applied.

  • Texture application is not applied.

  • Color sum is not applied.

  • Fog is not applied.

    Again, the fragment shader that is installed is expected to implement any or all of the desired functionality from the preceding list.

    While a program object is in use, applications are free to modify attached shader objects, compile attached shader objects, attach additional shader objects, and detach or delete shader objects. None of these operations will affect the executables that are part of the current state. However, relinking the program object that is currently in use will install the program object as part of the current rendering state if the link operation was successful (see Gl.LinkProgram). If the program object currently in use is relinked unsuccessfully, its link status will be set to FALSE, but the executables and associated state will remain part of the current state until a subsequent call to Gl.UseProgram 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.GL_VERTEX_SHADER but it does not contain shader objects of type Gl.GL_FRAGMENT_SHADER, an executable will be installed on the vertex processor, but fixed functionality will be used for fragment processing. Similarly, if program contains shader objects of type Gl.GL_FRAGMENT_SHADER but it does not contain shader objects of type Gl.GL_VERTEX_SHADER, an executable will be installed on the fragment processor, but fixed functionality will be used for vertex processing. If program is 0, the programmable processors will be disabled, and fixed functionality will be used for both vertex and fragment processing.

Gl.UseProgram is available only if the GL version is 2.0 or greater.

While a program object is in use, the state that controls the disabled fixed functionality may also be updated using the normal OpenGL calls.

Like display lists and texture objects, the name space for program objects may be shared across a set of contexts, as long as the server sides of the contexts share the same address space. If the name space is shared across contexts, any attached objects and the data associated with those attached objects are shared as well.

Applications are responsible for providing the synchronization across API calls when objects are accessed from different execution threads.

Errors

Associated Gets

  • Gl.Get with the argument Gl.GL_CURRENT_PROGRAM

  • Gl.GetActiveAttrib with a valid program object and the index of an active attribute variable

  • Gl.GetActiveUniform with a valid program object and the index of an active uniform

  • Gl.GetAttachedShaders with a valid program object

  • Gl.GetAttribLocation with a valid program object and the name of an attribute

  • Gl.GetProgramiv with a valid program object and the parameter to be queried

  • Gl.GetProgramInfoLog with a valid program object

  • Gl.GetUniform with a valid program object and the location of a uniform

  • Gl.GetUniformLocation with a valid program object and the name of a uniform

  • Gl.IsProgram

See also