WebGLRenderingContext.linkProgram()

翻译不完整。 请帮助我们翻译这篇文章!


WebGLRenderingContext 接口的linkProgram()方法链接给定的WebGLProgram,从而完成为程序的片元和顶点着色器准备GPU代码的过程。

语法

void gl.linkProgram(program);

参数

program
一个用于链接的 WebGLProgram

返回值

None.

例子

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 Status Comment
WebGL 1.0
linkProgram
Recommendation Initial definition.
OpenGL ES 2.0
glLinkProgram
Standard Man page of the OpenGL API.

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
linkProgramChrome 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 8Samsung Internet Android Full support 1.5

Legend

Full support  
Full support

参考