WebGLRenderingContext.getProgramInfoLog()

WebGLRenderingContext.getProgramInfoLog  返回参数中指定的WebGLProgram object 的信息. 这些信息包括在linking过程中的错误以及 WebGLProgram objects 合法性检查的错误.

Syntax

gl.getProgramInfoLog(program);

Parameters

program
A WebGLProgram to query.

Return value

返回 DOMString 包含 diagnostic , warning ...等等关于上一次linking和valiadation操作的信息. 对于刚刚创建的WebGLProgram object , 返回一个空字符串.

Examples

Checking program errors

var canvas = document.getElementsById('canvas');
var gl = canvas.getContext('webgl');
var program = gl.createProgram();

//vsSource is the source-code-string of vertex-shader
//fsSource is the source-code-string of fragment-shader
var vertexShader = loadShader(gl, gl.VERTEX_SHADER, vsSource);
var fragmentShader = loadShader(gl, gl.FRAGMENT_SHADER, fsSource);

// Attach pre-existing shaders
gl.attachShader(program, vertexShader);
gl.attachShader(program, fragmentShader);

gl.linkProgram(program);

gl.getProgramInfoLog(program);

Specifications

Specification Status Comment
WebGL 1.0
getProgramInfoLog
Recommendation Initial definition.
OpenGL ES 2.0
glGetProgramInfoLog
Standard Man page of the OpenGL API.

Browser compatibility

BCD tables only load in the browser

See also