Class: GpuShader

GpuShader(gl, shaderType, shaderSource)

Represents an OpenGL shading language (GLSL) shader and provides methods for compiling and disposing of them.

Constructor

new GpuShader(gl, shaderType, shaderSource)

Constructs a GPU shader of a specified type with specified GLSL source code.
Parameters:
Name Type Description
gl WebGLRenderingContext The current WebGL context.
shaderType Number The type of shader, either WebGLRenderingContext.VERTEX_SHADER or WebGLRenderingContext.FRAGMENT_SHADER.
shaderSource String The shader's source code.
Source:
Throws:
If the shader type is unrecognized, the shader source is null or undefined or shader compilation fails. If the compilation fails the error thrown contains any compilation messages.
Type
ArgumentError

Methods

compile(gl, shaderId, shaderType, shaderSource) → {boolean}

Compiles the source code for this shader. This method is not meant to be invoked by applications. It is invoked internally as needed.
Parameters:
Name Type Description
gl WebGLRenderingContext The current WebGL rendering context.
shaderId WebGLShader The shader ID.
shaderType Number The type of shader, either WebGLRenderingContext.VERTEX_SHADER or WebGLRenderingContext.FRAGMENT_SHADER.
shaderSource String The shader's source code.
Source:
Returns:
true if the shader compiled successfully, otherwise false.
Type
boolean

dispose(gl)

Releases this shader's WebGL shader.
Parameters:
Name Type Description
gl WebGLRenderingContext The current WebGL rendering context.
Source: