WebGLRenderingContext.validateProgram()

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

语法

void gl.validateProgram(program);

参数

program
待验证的 WebGLProgram

返回值

None.

Examples

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 Status Comment
WebGL 1.0
validateProgram
Recommendation 初次定义.
OpenGL ES 2.0
glValidateProgram
Standard OpenGL API 的帮助页中.

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
validateProgramChrome Full support 9Edge Full support 12Firefox Full support 4IE Full support 11Opera Full support 12Safari Full support 5.1WebView Android Full support YesChrome Android Full support 25Firefox Android Full support YesOpera Android Full support 12Safari iOS Full support 8.1Samsung Internet Android Full support Yes

Legend

Full support  
Full support

See also