Class: Manager

Palette. Manager

The core part of the system - initialise this to begin using the shader manager.

new Manager(gl)

Parameters:
Name Type Description
gl WebGLRenderingContext The context all shaders and programs will belong to and be compiled by.
Author:
  • FelixMcFelix (Kyle S.)
Source:

Members

<protected, readonly> context :WebGLRenderingContext

A reference to the defining WebGLRenderingContext.
Type:
  • WebGLRenderingContext
Source:

<protected> fragShaders :Object

An object storing all processed Fragment Shaders.
Type:
  • Object
Source:

<protected> programs :Object

An object storing all processed Programs.
Type:
  • Object
Source:

<protected, readonly> shaderFactory :Palette.ShaderFactory

A Palette.ShaderFactory object utilised by the manager to generate valid shader objects from many sources for use.
Type:
Source:

<protected> vertShaders :Object

An object storing all processed Vertex Shaders.
Type:
  • Object
Source:

Methods

addShader(shaderRef)

Add a shader into the manager's storage for future access.
Parameters:
Name Type Description
shaderRef string | Palette.Shader URL, JSON or Palette.Shader.
Source:

draw(vs, fs, verts, conf1, conf2)

Send a draw call to a given vs-fs pair. The work is delegated down to the program's own draw method.
Parameters:
Name Type Argument Description
vs string | Palette.Shader The desired Vertex Shader.
fs string | Palette.Shader The desired Fragment Shader.
verts Float32Array Vertex list to pass to the GPU.
conf1 object <optional>
A set of attributes to pass down to the fragment shader.
conf2 object <optional>
A set of attributes to pass down to the vertex shader.
Source:

getProgram(vs, fs) → {Palette.Program}

Request a program object from a known vs-fs pair.
Parameters:
Name Type Description
vs string | Palette.Shader The desired Vertex Shader.
fs string | Palette.Shader The desired Fragment Shader.
Source:
Returns:
The Palette.Program either found or generated. If either shader was not found, NULL is returned.
Type
Palette.Program

getShader(type, name) → {Palette.Shader}

Request a shader object from storage using its type and name.
Parameters:
Name Type Description
type int Either Palette.Shader.VS or Palette.Shader.FS.
name string The shader's identifier.
Source:
Returns:
The requested Palette.Shader. If a shader was not found, NULL is returned.
Type
Palette.Shader

getShaderName(input) → {string}

Ensure that we have a shader's name, for lookup purposes in particular.
Parameters:
Name Type Description
input string | Palette.Shader The shader we need to sanity check the name of.
Source:
Returns:
- The definite name of the shader.
Type
string