API Docs for: 1.4.0
Show:

Kiwi.Shaders.ShaderManager Class

Extends IRenderer
Module: Shaders
Parent Module: Kiwi

Manages all WebGL Shaders. Maintains a list of ShaderPairs

Provides an interface for using a specific ShaderPair, adding new ShaderPairs, and requesting a reference to a ShaderPair instance. Renderes use shaderPairs to draw. Multiple renderers may use the same compiled shader program. This Manager ensures only one compiled instance of each program is created

Constructor

Methods

_addShader

(
  • gl
  • shaderID
)
Kiwi.Shaders.ShaderPair private

Creates a new instance of a ShaderPair and adds a reference to the _shaderPairs object

Parameters:

  • gl WebGLRenderingContext
  • shaderID String

_loadShader

(
  • gl
  • shader
)
private

Tells a ShaderPair to load (compile and link)

Parameters:

_useShader

(
  • gl
  • shader
)
private

Changes gl state so that the shaderProgram contined in a ShaderPir is bound for use

Parameters:

init

(
  • gl
  • defaultShaderID
)
public

Sets up a default shaderPair.

Parameters:

  • gl WebGLRenderingContext
  • defaultShaderID String

requestShader

(
  • gl
  • shaderID
  • use
)
Kiwi.Shaders.ShaderPair public

Provides a reference to a ShaderPair. If the requested ShaderPair exists as a property on the _shaderPairs object it will be returned if already loaded, otherwise it will be loaded, then returned.

If the request is not on the list, the Kiwi.Shaders object will be checked for a property name that matches shaderID and a new ShaderPair will be instantiated, loaded, and set for use.

Parameters:

  • gl WebGLRenderingContext
  • shaderID String
  • use Boolean

Returns:

Kiwi.Shaders.ShaderPair:

a ShaderPair instance - null on fail

shaderExists

(
  • gl
  • shaderID
)
Boolean public

Tests to see if a ShaderPair property named ShaderID exists on Kiwi.Shaders. Can be used to test for the availability of specific shaders (for fallback)

Parameters:

  • gl WebGLRenderingContext
  • shaderID String

Returns:

Boolean:

success

Properties

_shaderPairs

Object private

An object containing a set of properties each of which references a ShaderPair.

currentShader

Array private

The shader program that is currently set to be used useing gl.useProgram.