WebGLRenderingContext.linkProgram()
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
接口的**linkProgram()**方法链接给定的WebGLProgram
,从而完成为程序的片元和顶点着色器准备 GPU 代码的过程。
语法
void gl.linkProgram(program);
参数
- program
-
一个用于链接的
WebGLProgram
。
返回值
None.
例子
js
var program = gl.createProgram();
// Attach pre-existing shaders
gl.attachShader(program, vertexShader);
gl.attachShader(program, fragmentShader);
gl.linkProgram(program);
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
var info = gl.getProgramInfoLog(program);
throw new Error("Could not compile WebGL program. \n\n" + info);
}
规范
Specification |
---|
WebGL Specification # 5.14.9 |
浏览器兼容性
BCD tables only load in the browser