Function Namespace Glsl
- Defined in: glsl.js
Constructor Attributes | Constructor Name and Description |
---|---|
Glsl(options)
Creates a new Glsl.
|
Method Summary
Function Namespace Detail
Glsl(options)
Creates a new Glsl.
init(), update() and render() are called When GL is ready.
- Parameters:
- options
- {HTMLCanvasElement} options.canvas
- The Canvas to render.
- {String} options.fragment
- The fragment shader source code.
- {Object} options.variables
- The variables map (initial values).
- {Function} options.update Optional
- The update function to call each frame. (the relative time from the start() and the time since the last update) in milliseconds is given to the function.
- {Function} options.init Optional
- Call once when GL is initialized.
- {Function} options.ready Optional
- Call after the first render has been achieved.
- {Object} options.contextArgs Optional
- Specify WebGLContextAttributes. See http://www.khronos.org/registry/webgl/specs/latest/#5.2
Field Detail
defines
A map containing all the #define declarations of the GLSL.
You can use it to synchronize some constants between GLSL and Javascript (like an array capacity).
Method Detail
-
<static> Glsl.Program(vertex, fragment)A WebGL program with shaders and variables.
- Parameters:
- {String} vertex
- The vertex shader source code.
- {String} fragment
- The fragment shader source code.
-
set(vname, vvalue)Set and synchronize a variable to a value.
- Parameters:
- {String} vname
- the variable name to set and synchronize.
- {Any} vvalue
- the value to set.
- Returns:
- the Glsl instance.
-
setSize(width, height)Resize the canvas with a new width and height.
- Parameters:
- width
- height
-
start()Starts/Continues the render and update loop. The call is not mandatory if you need a one time rendering, but don't need to update things through time (rendering is performed once at Glsl instanciation).
- Returns:
- the Glsl instance.
-
stop()Pauses the render and update loop.
- Returns:
- the Glsl instance.
-
<static> {boolean} Glsl.supported()Checks if WebGL is supported by the browser.
-
sync(variableNames*)Synchronizes variables from the Javascript into the GLSL.
- Parameters:
- {String} variableNames*
- all variables to synchronize.
- Returns:
- the Glsl instance.
-
syncAll()Synchronizes all variables. Prefer using sync for a deeper optimization.
- Returns:
- the Glsl instance.