Constructor
new L3D.GLShader()
Properties
The default precision to use for shaders that don't explicitely define it.
Is the shader currently the active bound shader?
Methods
static injectCode(injectCode, code) → String
Injects macro code into the shader, but only after the #version line, which must be first.
injectCode |
String | The code to inject. |
code |
String | The code to inject into. |
- String
The resulting code.
attributeLocation(name) → number
Get the location of an attribute with the given name.
name |
String | The name of the attribute. |
- number
An int number indicating the location of the attribute name if found. Returns -1 if the attribute wasn't found.
bind()
Bind the shader as active for the context.
drawBuffers(vertexBuffers, indexBuffer, mode, rangeStart, rangeLength) → GLShader
Draw the geometry defined by the given buffers using this shader.
vertexBuffers |
Object | The vertex buffers to draw. |
indexBuffer |
GLBuffer | Optional index buffer to draw with |
mode |
number | The GL element mode to draw with |
rangeStart |
number | |
rangeLength |
number |
- GLShader
Returns self.
drawMesh(mesh, mode, indexBufferName) → GLShader
Renders a mesh using this shader.
mesh |
GLMesh | The mesh to draw |
mode |
number | The GL draw mode, could be gl.LINES, gl.POINTS, gl.TRIANGLES, gl.TRIANGLE_STRIP, gl.TRIANGLE_FAN |
indexBufferName |
String | The name of the index buffer, if not provided "lines" will be assumed if mode is gl.LINES, otherwise "triangles". |
- GLShader
Returns self.
drawRange(mesh, mode, start, length, indexBufferName) → GLShader
Draw a given sub-range from the given mesh.
mesh |
GLMesh | The mesh to draw. |
mode |
number | |
start |
number | |
length |
number | |
indexBufferName |
String |
- GLShader
Returns self.
setUniform(name, value) → GLShader
Set a uniform value given it's name.
The uniform locations will already have been cached when the shader was loaded. Attempting to set a uniform value that doesn't exist in the shader will return without doing anything.
name |
String | The name of the uniform. |
value |
* | The value to set it as. |
- GLShader
Returns self.
setUniforms(uniformValues) → GLShader
Set multiple uniform values.
setUniforms({ color: [1,1,1,1] });
setUniforms([{ color: [1,1,1,1] }, { worldToCamera: new Matrix4() }]);
uniformValues |
* | Can be a map, or an array of maps. |
- GLShader
Returns self.
unbind()
Unbind the shader from the context.
uniformLocation(name) → WebGLUniformLocation
Get the location of a uniform with the given name.
name |
String | The name of the uniform. |
- WebGLUniformLocation
The location of the uniform.