LS.ShadersManager Class
ShadersManager is the static class in charge of loading, compiling and storing shaders for reuse.
Constructor
LS.ShadersManager
()
Item Index
Methods
clearCache
()
Clears all the compiled shaders
compileShader
-
vs_code -
fs_code -
name
Compiles a shader, the vertex and fragment shader are cached indepently to speed up compilations but a unique name must be provided
Parameters:
-
vs_codeStringthe final source code for the vertex shader
-
fs_codeStringthe final source code for the fragment shader
-
nameStringan unique name that should be associated with this shader
Returns:
shader
createDefaultShaders
-
id
Create some default shaders useful for generic situations (flat, texture and screenspace quad)
Parameters:
-
idString
Returns:
code
get
-
id -
macros
Returns a compiled shader with this id and this macros
Parameters:
-
idString -
macrosString
Returns:
the shader, if not found the default shader is returned
getGlobalShaderInfo
-
id
Returns the info of a global shader
Parameters:
-
idString
Returns:
shader info (code, macros supported, flags)
getSnippet
-
id
Returns the code of a snipper
Parameters:
-
idString
Returns:
code
init
-
url
Initializes the shader manager
Parameters:
-
urlStringa url to a shaders.xml can be specified to load the shaders
loadFromXML
-
url -
reset_old -
ignore_cache -
on_complete
Loads shaders code from an XML file
Parameters:
-
urlStringto the shaders file
-
reset_oldBooleanto reset all the existing shaders once loaded
-
ignore_cacheBooleanforce to ignore web cache
-
on_completeFunctioncallback once the file has been loaded and processed
processShadersXML
-
xml
extracts all the shaders from the XML doc
Parameters:
-
xmlXMLDocument
registerCompiledShader
-
shader -
key -
id
Stores a compiled shader program, so it can be reused
Parameters:
-
shaderGL.Shaderthe compiled shader
-
keyStringunique id
-
idStringthe shader name
Returns:
shader
registerGlobalShader
-
vs_code -
fs_code
extracts all the shaders from the XML doc
Parameters:
-
vs_codeString -
fs_codeString
registerSnippet
-
id -
code
Register a code snippet ready to be used by the #import clause in the shader
Parameters:
-
idString -
codeString
reloadShaders
-
on_complete
Reloads the XML file with the shaders, useful when editing the file
Parameters:
-
on_completeFunctioncall when the shaders have been reloaded
resolve
-
query
Resolves a shader query, returns the shader
Parameters:
-
queryShaderQuery
Returns:
the shader, if not found the default shader is returned
