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 July 2015.

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

浏览器兼容性

BCD tables only load in the browser

See also