Export (0) Print
Expand All
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

linkProgram method

Links an attached vertex shader and an attached fragment shader to a program so it can be used by the graphics processing unit (GPU).

IE11

 

Syntax

WebGLRenderingContext.linkProgram(program);

Parameters

program [in]

Type: WebGLProgram

The program object to link.

Return value

This method does not return a value.

Remarks

WebGL errorDescription
gl.INVALID_VALUE If program isn't a WebGL object type.
gl.INVALID_OPERATIONIf program isn't a program object.

 

If a link operation fails, any info associated with a previous link operation of program is lost.

Examples

The following example uses linkProgram. For more info on this example, see Get started with WebGL.


function loadProgram(gl, vertexShader, fragmentShader)
{
  // create a progam object
  var program = gl.createProgram();

  // attach the two shaders 
  gl.attachShader(program, vertexShader);
  gl.attachShader(program, fragmentShader);

  // link everything 
  gl.linkProgram(program);

  // Check the link status
  var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  if (!linked) {

    // An error occurred while linking
    var lastError = gl.getProgramInfoLog(program);
    console.warn("Error in program linking:" + lastError);

    gl.deleteProgram(program);
    return null;
  }

  // if all is well, return the program object
  return program;
};


See also

WebGLRenderingContext

 

 

Show:
© 2015 Microsoft