Kiwi.Shaders.ShaderManager Class
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
Item Index
Properties
Methods
_addShader
-
gl
-
shaderID
Creates a new instance of a ShaderPair and adds a reference to the _shaderPairs object
Parameters:
-
gl
WebGLRenderingContext -
shaderID
String
Returns:
_loadShader
-
gl
-
shader
Tells a ShaderPair to load (compile and link)
Parameters:
-
gl
WebGLRenderingContext -
shader
Kiwi.Shaders.ShaderPair
_useShader
-
gl
-
shader
Changes gl state so that the shaderProgram contined in a ShaderPir is bound for use
Parameters:
-
gl
WebGLRenderingContext -
shader
Kiwi.Shaders.ShaderPair
init
-
gl
-
defaultShaderID
Sets up a default shaderPair.
Parameters:
-
gl
WebGLRenderingContext -
defaultShaderID
String
requestShader
-
gl
-
shaderID
-
use
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:
a ShaderPair instance - null on fail
shaderExists
-
gl
-
shaderID
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:
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.