The WebGLRenderingContext
interface's linkProgram()
method links a given WebGLProgram
, completing the process of preparing the GPU code for the program's fragment and vertex shaders.
Syntax
void gl.linkProgram(program);
Parameters
program
- The
WebGLProgram
to link.
Return value
None.
Examples
var program = gl.createProgram();
// Attach pre-existing shaders
gl.attachShader(program, vertexShader);
gl.attachShader(program, fragmentShader);
gl.linkProgram(program);
if ( !gl.getProgramParameter( program, gl.LINK_STATUS) ) {
var info = gl.getProgramInfoLog(program);
throw new Error('Could not compile WebGL program. \n\n' + info);
}
Specifications
Specification | Status | Comment |
---|---|---|
WebGL 1.0 The definition of 'linkProgram' in that specification. |
Recommendation | Initial definition. |
OpenGL ES 2.0 The definition of 'glLinkProgram' in that specification. |
Standard | Man page of the OpenGL API. |
Browser compatibility
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
linkProgram | Chrome Full support 9 | Edge Full support 12 | Firefox Full support 4 | IE Full support 11 | Opera Full support 12 | Safari Full support 5.1 | WebView Android Full support Yes | Chrome Android Full support 25 | Firefox Android Full support Yes | Opera Android Full support 12 | Safari iOS Full support 8 | Samsung Internet Android Full support 1.5 |
Legend
- Full support
- Full support