WebGLRenderingContext.compileShader()

WebGL API下的方法 WebGLRenderingContext.compileShader()  用于编译一个GLSL着色器,使其成为为二进制数据,然后就可以被WebGLProgram对象所使用.

语法

void gl.compileShader(shader);

参数

shader
一个片元或顶点着色器 (WebGLShader).

示例

var shader = gl.createShader(gl.VERTEX_SHADER);
gl.shaderSource(shader, shaderSource);
gl.compileShader(shader);

规范

Specification Status Comment
WebGL 1.0
compileShader
Recommendation Initial definition.
OpenGL ES 2.0
glCompileShader
Standard OpenGL man page.

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
compileShaderChrome 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

更多: