-
Notifications
You must be signed in to change notification settings - Fork 5
Guide to viaWebGL
John Hoffer edited this page Sep 8, 2016
·
34 revisions
Options | Type | About | Default |
---|---|---|---|
vShader |
String | path/to/*.glsl or shader code | 'vShader.glsl' |
fShader |
String | path/to/*.glsl or shader code | 'fShader.glsl' |
tile_size |
String | glsl uniform vec2 | 'u_tile_size' |
tile_pos |
String | glsl varying vec2 | 'a_tile_pos' |
pos |
String | glsl varying vec2 | 'a_pos' |
height |
Number | value of u_tile_size.y
|
128 |
width |
Number | value of u_tile_size.x
|
128 |
container |
HTMLDivElement | Draw here on viaGL.init
|
none |
gl-drawing |
Function | Set to custom gl-handler
|
(e) => e |
gl-loaded |
Function | Set to custom gl-handler
|
(e) => e |
onclick |
String | viaGL.onclick = 'toggle' |
none |
#viaGL = new viaWebGL(<options>)
Returns viaWebGL (chainable)
Pass <options>
keys for any viaWebGL attributes.
##viaGL.init(<source>)
Returns viaWebGL (chainable)
Parameters | Type | About |
---|---|---|
source |
HTMLImageElement | Draw source to container via shaders |
Call when all viaGL attributes have been set as needed. |
##viaGL.toCanvas(source)
Returns HTMLCanvasElement
Parameters | Type | About |
---|---|---|
source |
HTMLImageElement or HTMLCanvasElement | Return canvas via shaders |
Call after viaGL.init() to return a canvas of source via the shaders. |
###gl-handler(viaGL, event-object)
Returns None
Parameter | Type | About |
---|---|---|
viaGL |
viaWebGL | Get or set any viaGL attributes |
event-object |
Object | See event-object type chart below |
- Assign
viaGL['gl-loaded'] = gl-handler
to write webGL once with shaders - Assign
viaGL['gl-drawing'] = gl-handler
to write webGL per draw call
event-object type chart | called on 'tile-drawing' | called on 'tile-loaded' |
---|---|---|
event 'gl-loaded' | WebGLProgram | WebGLProgram |
event 'gl-drawing' | HTMLCanvasElement | HTMLImageElement |