Home Reference Source Test
import {_ProgramManager} from 'seed-engine/src/manager/ProgramManager.js'
private class | source

_ProgramManager

You can directly use an instance of this class. ProgramManager

Extends:

Manager → _ProgramManager

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
public

update()

Public Constructors

public constructor() source

Override:

Manager#constructor

Public Members

public programIDCounter: number source

public programs: {} source

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:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
programKey string

Name of the program.

Return:

Program Object

Returns a JSON object with Program data.

public start() source

Creates default programs for easy reference later on.

Override:

Manager#start

Private Methods

private _createProgram(vertexShaderSource: string, fragmentShaderSource: string): Program source

Compiles the vertex shader and fragment shader and returns a WebGL program.

Params:

NameTypeAttributeDescription
vertexShaderSource string

Source code for a vertex shader.

fragmentShaderSource string

Source code for a fragment shader.

Return:

Program

A program compiled from the two shader sources.

private _createProgramLocationSetters(program: *, uniforms: *): * source

Params:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
location *
type *

Return:

*