EN
이 콘텐츠는 한국어로 제공되지 않아 영어 버전으로 표시됩니다.

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

 

 

표시:
© 2014 Microsoft