web api instance method
WebGLRenderingContext: compileShader() method
Available in workers
The WebGLRenderingContext.compileShader() method of the WebGL API compiles a GLSL shader into binary
data so that it can be used by a WebGLProgram.
Syntax
compileShader(shader)
Parameters
shader- : A fragment or vertex
WebGLShader.
- : A fragment or vertex
Return value
None (undefined).
Exceptions
TypeError- : Thrown if the specified
shaderis not of typeWebGLShader.
- : Thrown if the specified
Examples
const shader = gl.createShader(gl.VERTEX_SHADER);
gl.shaderSource(shader, shaderSource);
gl.compileShader(shader);
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.
See also
WebGLProgramWebGLShaderattachShader()createProgram()createShader()deleteProgram()deleteShader()detachShader()getAttachedShaders()getProgramParameter()getProgramInfoLog()getShaderParameter()getShaderPrecisionFormat()getShaderInfoLog()getShaderSource()isProgram()isShader()linkProgram()shaderSource()useProgram()validateProgram()