Click or drag to resize

ProgramLink Method

Links the program.

Namespace:  Ooogles
Assembly:  Ooogles (in Ooogles.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public bool Link()

Return Value

Type: Boolean
In Release builds: True on success, False on failure. In Debug builds: True on success or an GLException will be thrown on failure.
Exceptions
ExceptionCondition
ShaderExceptionWhen the shaders cannot be linked.
Remarks
A shader object of type Vertex attached to the program is used to create an executable that will run on the programmable vertex processor. A shader object of type Fragment attached to the program is used to create an executable that will run on the programmable fragment processor.

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 can be accessed using Uniform. 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 ES Shading Language Specification. This will result in a ShaderException (in Debug builds). The following lists some of the conditions that will cause a link error.

  • A vertex shader and a fragment shader are not both present in the program object.
  • 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 shader or the 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.
  • 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 (via Compile).
  • Binding a generic attribute matrix caused some rows of the matrix to fall outside the allowed maximum number of vertex attributes.
  • Not enough contiguous vertex attribute slots could be found to bind attribute matrices.

When a program object has been successfully linked, the program object can be made part of current state by calling Use.

This method 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 Use. 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 Use removes it from use. After it is removed from use, it cannot be made part of current state until it has been successfully relinked.

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.

Note: 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.

OpenGL API: glLinkProgram, glGetProgramInfoLog, glGetProgramiv(GL_LINK_STATUS/GL_INFO_LOG_LENGTH)

See Also