_ProgramManager
Extends:
Manages WebGL Programs so that they only need to be created once across the engine allowing multiple objects to still share the same reference.
Elliminates the need for the programmer to compile shaders and create programs, and eases on-the-fly Shader compiling.
Constructor Summary
Public Constructor | ||
public |
|
Member Summary
Public Members | ||
public |
|
|
public |
programs: {} |
Method Summary
Public Methods | ||
public |
addProgram(programName: string, vertexShaderSource: string, fragmentShaderSource: string, uniforms: Object) Creates a Program JSON Object and initializes the program and metadata. |
|
public |
getProgram(programKey: string): Program Object Returns a Program JSON Object containing the program, name and id. |
|
public |
start() Creates default programs for easy reference later on. |
Private Methods | ||
private |
_createProgram(vertexShaderSource: string, fragmentShaderSource: string): Program Compiles the vertex shader and fragment shader and returns a WebGL program. |
|
private |
_createProgramLocationSetters(program: *, uniforms: *): * |
|
private |
_createShader(type: GLShaderType, source: string): CompiledShader Creates a shader of either Vertex or Fragment type and returns the compiled version. |
|
private |
_createShadersProgram(vertexShader: CompiledVertexShader, fragmentShader: CompiledFragmentShader): Program Creates a WebGL program from a compiled vertex and fragment shader. |
|
private |
_getUniformSetterFromString(location: *, type: *): * |
Inherited Summary
From class Manager | ||
public |
end() |
|
public |
pause() |
|
public |
start() |
|
public |
unpause() |
|
public |
update() |
Public Constructors
Public Methods
public addProgram(programName: string, vertexShaderSource: string, fragmentShaderSource: string, uniforms: Object) source
Creates a Program JSON Object and initializes the program and metadata. The program is added to the programs array.
Params:
Name | Type | Attribute | Description |
programName | string | Name of the program. |
|
vertexShaderSource | string | Source code of the vertex shader. |
|
fragmentShaderSource | string | Source code of the fragment shader. |
|
uniforms | Object | An object of 'string': 'number' values indicating the uniform variable name & data type enum value. |
public getProgram(programKey: string): Program Object source
Returns a Program JSON Object containing the program, name and id.
Params:
Name | Type | Attribute | Description |
programKey | string | Name of the program. |
Return:
Program Object | Returns a JSON object with Program data. |
Private Methods
private _createProgram(vertexShaderSource: string, fragmentShaderSource: string): Program source
Compiles the vertex shader and fragment shader and returns a WebGL program.
Return:
Program | A program compiled from the two shader sources. |
private _createProgramLocationSetters(program: *, uniforms: *): * source
Params:
Name | Type | Attribute | Description |
program | * | ||
uniforms | * |
Return:
* |
private _createShader(type: GLShaderType, source: string): CompiledShader source
Creates a shader of either Vertex or Fragment type and returns the compiled version.
Params:
Name | Type | Attribute | Description |
type | GLShaderType | A GL shader type of either VERTEX_SHADER or FRAGMENT_SHADER. |
|
source | string | Source code for the shader type. |
Return:
CompiledShader | A compiled shader. Null if unsuccessful. |
private _createShadersProgram(vertexShader: CompiledVertexShader, fragmentShader: CompiledFragmentShader): Program source
Creates a WebGL program from a compiled vertex and fragment shader. The program is returned.
Params:
Name | Type | Attribute | Description |
vertexShader | CompiledVertexShader | A compiled vertex shader. |
|
fragmentShader | CompiledFragmentShader | A compiled fragment shader. |
Return:
Program | A WebGL program. Null if unsuccessful. |
private _getUniformSetterFromString(location: *, type: *): * source
Params:
Name | Type | Attribute | Description |
location | * | ||
type | * |
Return:
* |