Class: SimpleShader

SimpleShader

new SimpleShader(vertexShaderPath, fragmentShaderPath) → {SimpleShader}

constructor of SimpleShader object.
Parameters:
Name Type Description
vertexShaderPath string filepath of the Vertex Shader.
fragmentShaderPath string filepath of the Fragment Shader.
Source:
Returns:
An intsnace of SimpleShader.
Type
SimpleShader

Methods

_compileShader(filePath, shaderType) → {WebGLShader}

Returns a compiled shader from a shader in the dom.

The id is the id of the script in the html tag.

Parameters:
Name Type Description
filePath string Filepath of the shader.
shaderType Number Either gl.FRAGMENT_SHADER or gl.VERTEX_SHADER constants.
Source:
Returns:
Shader object of type fragment or vertex shader.
Type
WebGLShader

activateShader(pixelColor, aCamera) → {void}

Activate the shader for rendering.
Parameters:
Name Type Description
pixelColor Array.<float> [R, G, B, A] Sets the shader pixel color.
aCamera Camera Camera to draw to
Source:
Returns:
Type
void

cleanUp() → {void}

Detaches and removes the shader from the Shader Program
Source:
Returns:
Type
void

getShader() → {WebGLProgram}

Access to the compiled shader
Source:
Returns:
A reference to the SimpleShaders Shader Program.
Type
WebGLProgram

loadObjectTransform(modelTransform) → {void}

Loads per-object model transform to the vertex shader.
Parameters:
Name Type Description
modelTransform Array.<float> An array of float values representing one or more 4x4 matrices.
Source:
Returns:
Type
void