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

View in English Always switch to English

WebGLRenderingContext.validateProgram()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2015年7月⁩.

WebGLRenderingContext.validateProgram() 是一种 WebGL API ,主要是用来验证 WebGLProgram。它在检查 WebGLProgram 程序是否链接成功的同时还会检查其是否能在当前的 WebGL 中使用。

语法

void gl.validateProgram(program);

参数

program

待验证的 WebGLProgram

返回值

None.

Examples

js
var program = gl.createProgram();

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

gl.linkProgram(program);
gl.validateProgram(program);

if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
  var info = gl.getProgramInfoLog(program);
  throw "不能编译 WebGL 程序。\n\n" + info;
}

gl.useProgram(program);

规范

Specification
WebGL Specification
# 5.14.9

浏览器兼容性

See also