Program Object

From OpenGL.org
Jump to: navigation, search

A Program Object represents the compiled executable code, in the OpenGL Shading Language, for one or more Shader stages. A program object is an object in OpenGL, but it does not use the standard OpenGL Object model.

Creation

Empty program objects are created with this function:

GLuint glCreateProgram()

This will return an empty program object. Programs are deleted with glDeleteProgram.

Once created, program objects must then be filled in with executable code. This is done by compiling shader objects and linking them into the program.

Pre-link setup

Before performing the linking steps for a shader, it is sometimes important to provide certain settings. OpenGL 3.3 or ARB_explicit_attrib_location has replaced the need for most of this, by allowing shaders to provide these settings itself.

Introspection

A successfully linked program object can be queries for its various interfaces, so that the user can set uniforms and perform other upkeep on the object.

State setting

Outside of the state used by the pre-link setup, program objects have the following mutable state:

Note that the last two pieces of state only need to be set if you did not set them directly in the shader.