此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

WebGLRenderingContext.getProgramInfoLog()

基线 广泛可用

自 2015年7月 起,此特性已在主流浏览器中得到支持,可在大多数设备和浏览器版本中正常使用。

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

js
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

规范
WebGL Specification
# 5.14.9

Browser compatibility

See also