EN
本內容沒有您的語言版本,但有英文版本。

getProgramParameter method

Returns the value of the program parameter that corresponds to a supplied pname for a given program, or null if an error occurs.

IE11

 

Syntax

var retVal = WebGLRenderingContext.getProgramParameter(program, pname);

Parameters

program [in]

Type: WebGLProgram

The program object to query for pname.

pname [in]

Type: Number

The parameter constant.

pnamereturned type
gl.DELETE_STATUSBoolean
gl.LINK_STATUSBoolean
gl.VALIDATE_STATUSBoolean
gl.ATTACHED_SHADERSNumber
gl.ACTIVE_ATTRIBUTESNumber
gl.ACTIVE_UNIFORMSNumber

 

Return value

Type: any

The value for a parameter associated with pname, or null if an error occurs.

Remarks

WebGL ErrorDescription
gl.INVALID_ENUMIf pname isn't in the table above.
gl.INVALID_OPERATIONIf program isn't a program object.

 

Examples

This example creates a program and attaches a vertex and a fragment shader. It uses getProgramParameter to retrieve the link status. 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