Expand Minimize

getProgramInfoLog method

Returns information about the last error that occurred during the failed linking or validation of a WebGL program object.

IE11

 

Syntax

var infoLog = WebGLRenderingContext.getProgramInfoLog(program);

Parameters

program [in]

Type: WebGLProgram

The program object to get the information for.

Return value

Type: String

The information (error, warning, or informational messages), or an empty string if none. Returns null if an error occurs.

Remarks

This method returns the last error that occurred during program linking or validation. WebGL reports one error at a time, and won't return another error until the reported error has been corrected.

WebGL ErrorDescription
gl.INVALID_VALUEIf program isn't a WebGL object.
gl.INVALID_OPERATIONIf program isn't a program object.

 

Examples

This example creates a WebGL program and attaches a vertex and a fragment shader. It checks the link status with getProgramParameter and uses getProgramInfoLog to retrieve the last error if program validation or linking fails. 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:
© 2014 Microsoft