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_code
Stringthe final source code for the vertex shader
-
fs_code
Stringthe final source code for the fragment shader
-
name
Stringan 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:
-
id
String
Returns:
code
get
-
id
-
macros
Returns a compiled shader with this id and this macros
Parameters:
-
id
String -
macros
String
Returns:
the shader, if not found the default shader is returned
getGlobalShaderInfo
-
id
Returns the info of a global shader
Parameters:
-
id
String
Returns:
shader info (code, macros supported, flags)
getSnippet
-
id
Returns the code of a snipper
Parameters:
-
id
String
Returns:
code
init
-
url
Initializes the shader manager
Parameters:
-
url
Stringa 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:
-
url
Stringto the shaders file
-
reset_old
Booleanto reset all the existing shaders once loaded
-
ignore_cache
Booleanforce to ignore web cache
-
on_complete
Functioncallback once the file has been loaded and processed
processShadersXML
-
xml
extracts all the shaders from the XML doc
Parameters:
-
xml
XMLDocument
registerCompiledShader
-
shader
-
key
-
id
Stores a compiled shader program, so it can be reused
Parameters:
-
shader
GL.Shaderthe compiled shader
-
key
Stringunique id
-
id
Stringthe shader name
Returns:
shader
registerGlobalShader
-
vs_code
-
fs_code
extracts all the shaders from the XML doc
Parameters:
-
vs_code
String -
fs_code
String
registerSnippet
-
id
-
code
Register a code snippet ready to be used by the #import clause in the shader
Parameters:
-
id
String -
code
String
reloadShaders
-
on_complete
Reloads the XML file with the shaders, useful when editing the file
Parameters:
-
on_complete
Functioncall when the shaders have been reloaded
resolve
-
query
Resolves a shader query, returns the shader
Parameters:
-
query
ShaderQuery
Returns:
the shader, if not found the default shader is returned