- vertexShaderSource
Vertex Shader
- fragmentShaderSource
Fragment Shader
- Drawer(id, webglErrorFunction) ⇒
Object
Manages the drawing procedure
- getMaximumTextureUnits() ⇒
integer
- setActiveTextureUnit(value) ⇒
boolean
Get a texture unit and activate it
- setTexture(image, unit, internalFormat, format)
Set image to specific texture unit
- setUseTexture(unit)
Set fragment shader to read texture from specific texture unit.
- setColorEnable()
Set fragment shader to read from active texture unit
- setTextureEnable()
Set fragment shader to read from color uniform
- setColor(r, g, b, a)
Set color to fragment shader and submit in the history
- setColorVanilla(r, g, b, a)
Set color to fragment shader but don't submit in the history
- setPositions(positions)
Submit vertices to the Array Buffer and submited in the history
- setPositionsVanilla(positions)
Submit vertices to the Array Buffer
- justDraw(positions)
Draw triangles that are passed.
- draw(positions, r, g, b, a)
Draw triangles are passed with a specific color.
- drawFromBuffer(count)
Draw triangles in the Array Buffer
- clear(r, g, b, a)
Clear screen with passed color and reset the history.
- setScale(scale)
Change scale value.
- updateScale(scale)
Change scale value and redraw every shape
- setTranslation(tx, ty)
Change translation value.
- updateTextureScale(scale)
Update texture scale value and redraw every shape.
- setTextureScale(scale)
Update texture scale value and calculate required settings.
- updateTextureValues()
Reset some values calculated for texture by program. For example reset Base Translation of texture.
- setTextureResolution(w, h)
Updates shader uniform that keeps textures resolution and submit that in history.
- setTextureResolutionVanilla(w, h)
Updates shader uniform that keeps textures resolution and doesn't submit that in history.
- setShaderTextureResolution(w, h)
Updates shader uniform that keeps textures resolution.
- setTextureTranslationFromValuesToShader()
Set texture translation value from local variables to shader's uniform
- setBaseTextureTranslation(tx, ty)
Change texture's base translation and set it's value to shader's uniform.
- setTextureUserTranslation(tx, ty)
Set user-defined translation
- setTextureTranslation(tx, ty)
Change texture translation and set it's value to shader's uniform. Calls
Drawer.setTextureTranslationVanilla(tx, ty)
- setTextureTranslationVanilla(tx, ty)
Change texture translation and set it's value to shader's uniform.
- updateTranslation(tx, ty)
Update vertex translation value and redraw every shape.
- repeatTheHistory()
Redraw any shape in history.
- redraw()
Redraw any shape in history. (Call
Drawer.repeatTheHistory()
)- updateScaleIntoPoint(newScale, x, y)
Change scale centered on point P
- createShader(type, source) ⇒
WebGLShader
Create WebGL shader object from given data.
- createProgram(vertexShader, fragmentShader) ⇒
WebGLProgram
Create WebGL program object from given data.
- enableBlending(sfactor, dfactor, equationA)
Enable blending pixels
- disableTextureBlending()
Disable blending pixels
- refitWebglToCanvas()
Refit WebGL's clip space to new size of the canvas
- setup()
Initialize variables and uniforms
- constructor(id, webglErrorFunction)
Construction Function
Vertex Shader
Fragment Shader
Manages the drawing procedure
Kind: global function
Returns: Object
- Drawer object
Param | Type | Description |
---|---|---|
id | string |
id of canvas element |
webglErrorFunction | function |
callback function for when user cannot use webgl |
Kind: global function
Returns: integer
- Maximum Texture Units Number
Get a texture unit and activate it
Kind: global function
Returns: boolean
- if texture unit number is not in valid range return true otherwise return false
Param | Type | Description |
---|---|---|
value | integer |
texture unit |
Set image to specific texture unit
Kind: global function
Param | Type | Description |
---|---|---|
image | Image |
texture |
unit | integer |
texture unit |
internalFormat | GLenum |
a GLenum specifying the color components in the texture |
format | GLenum |
a GLenum specifying the format of the texel data |
Set fragment shader to read texture from specific texture unit.
Kind: global function
Param | Type | Description |
---|---|---|
unit | integer |
texture unit |
Set fragment shader to read from active texture unit
Set fragment shader to read from color uniform
Set color to fragment shader and submit in the history
Kind: global function
Param | Type | Description |
---|---|---|
r | integer |
red color in range 0-1 |
g | integer |
green color in range 0-1 |
b | integer |
blue color in range 0-1 |
a | integer |
alpha color in range 0-1 |
Set color to fragment shader but don't submit in the history
Kind: global function
Param | Type | Description |
---|---|---|
r | integer |
red color in range 0-1 |
g | integer |
green color in range 0-1 |
b | integer |
blue color in range 0-1 |
a | integer |
alpha color in range 0-1 |
Submit vertices to the Array Buffer and submited in the history
Kind: global function
Param | Type |
---|---|
positions | * |
Submit vertices to the Array Buffer
Kind: global function
Param | Type | Description |
---|---|---|
positions | Array.<number> |
array of vertices [x1, y1, x2, y2, ...] |
Draw triangles that are passed.
Kind: global function
Param | Type | Description |
---|---|---|
positions | Array.<number> |
array of vertices [x1, y1, x2, y2, ...] |
Draw triangles are passed with a specific color.
Kind: global function
Param | Type | Description |
---|---|---|
positions | * |
array of vertices [x1, y1, x2, y2, ...] |
r | integer |
red color in range 0-1 |
g | integer |
green color in range 0-1 |
b | integer |
blue color in range 0-1 |
a | integer |
alpha color in range 0-1 |
Draw triangles in the Array Buffer
Kind: global function
Param | Type | Description |
---|---|---|
count | integer |
number of vertices |
Clear screen with passed color and reset the history.
Kind: global function
Param | Type | Description |
---|---|---|
r | integer |
red color in range 0-1 |
g | integer |
green color in range 0-1 |
b | integer |
blue color in range 0-1 |
a | integer |
alpha color in range 0-1 |
Change scale value.
Kind: global function
Param | Type | Description |
---|---|---|
scale | number |
new scale |
Change scale value and redraw every shape
Kind: global function
Param | Type | Description |
---|---|---|
scale | number |
new scale |
Change translation value.
Kind: global function
Param | Type | Description |
---|---|---|
tx | number |
X value of translation |
ty | number |
Y value of translation |
Update texture scale value and redraw every shape.
Kind: global function
Param | Type | Description |
---|---|---|
scale | number |
new scale value |
Update texture scale value and calculate required settings.
Kind: global function
Param | Type | Description |
---|---|---|
scale | number |
new scale value |
Reset some values calculated for texture by program. For example reset Base Translation of texture.
Updates shader uniform that keeps textures resolution and submit that in history.
Kind: global function
Param | Type | Description |
---|---|---|
w | number |
width of texture |
h | number |
heigt of texture |
Updates shader uniform that keeps textures resolution and doesn't submit that in history.
Kind: global function
Param | Type | Description |
---|---|---|
w | number |
width of texture |
h | number |
heigt of texture |
Updates shader uniform that keeps textures resolution.
Kind: global function
Param | Type | Description |
---|---|---|
w | number |
width of texture |
h | number |
heigt of texture |
Set texture translation value from local variables to shader's uniform
Change texture's base translation and set it's value to shader's uniform.
Kind: global function
Param | Type | Description |
---|---|---|
tx | number |
X value of translation |
ty | number |
Y value of translation |
Set user-defined translation
Kind: global function
Param | Type | Description |
---|---|---|
tx | number |
X value of translation |
ty | number |
Y value of translation |
Change texture translation and set it's value to shader's uniform.
Calls Drawer.setTextureTranslationVanilla(tx, ty)
Kind: global function
Param | Type | Description |
---|---|---|
tx | number |
X value of translation |
ty | number |
Y value of translation |
Change texture translation and set it's value to shader's uniform.
Kind: global function
Param | Type | Description |
---|---|---|
tx | number |
X value of translation |
ty | number |
Y value of translation |
Update vertex translation value and redraw every shape.
Kind: global function
Param | Type | Description |
---|---|---|
tx | number |
X value of translation |
ty | number |
Y value of translation |
Redraw any shape in history.
Redraw any shape in history. (Call Drawer.repeatTheHistory()
)
Change scale centered on point P
Kind: global function
Param | Type | Description |
---|---|---|
newScale | number |
|
x | number |
x value of P |
y | number |
y value of P |
Create WebGL shader object from given data.
Kind: global function
Returns: WebGLShader
- webgl shader object
Param | Type | Description |
---|---|---|
type | number |
gl.VERTEX_SHADER or gl.FRAGMENT_SHADER |
source | string |
GLSL source code of shader |
Create WebGL program object from given data.
Kind: global function
Returns: WebGLProgram
- webgl program object
Param | Type | Description |
---|---|---|
vertexShader | WebGLShader |
vertex shader |
fragmentShader | WebGLShader |
fragment shader |
Enable blending pixels
Kind: global function
Param | Type | Description |
---|---|---|
sfactor | GLenum |
a GLenum specifying a multiplier for the source blending factors |
dfactor | GLenum |
a GLenum specifying a multiplier for the destination blending factors |
equationA | GLenum |
a GLenum specifying how source and destination colors are combined |
Disable blending pixels
Refit WebGL's clip space to new size of the canvas
Initialize variables and uniforms
Construction Function
Kind: global function
Param | Type | Description |
---|---|---|
id | string |
id of canvas element |
webglErrorFunction | function |
callback function for when user cannot use webgl |