Constructor
new Handler(canvasTarget, paramsopt)
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
canvasTarget | string | | Canvas element target. or undefined creates hidden canvas and handler becomes hidden. | |||||||||||||||||||||
params | Object | <optional> | Handler options: Properties
|
- Source
Methods
(protected) _animationFrameCallback()
Make animation.
- Source
(protected) _initProgramController(sc)
Used in addProgram
Name | Type | Description |
---|---|---|
sc | ProgramController | Program controller |
- Source
(protected) _setDefaults()
Sets default gl render parameters. Used in init function.
- Source
addProgram(program, notActivateopt) → {Program}
Adds shader program to the handler.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
program | Program | Shader program. | ||
notActivate | boolean | <optional> | false | If it's true program will not compile. |
- Source
- Type:
- Program
addPrograms(programsArr)
Adds shader programs to the handler.
Name | Type | Description |
---|---|---|
programsArr | Array.<Program> | Shader program array. |
- Source
clearFrame()
Clearing gl frame.
- Source
createArrayBuffer(array, itemSize, numItems, usageopt) → {WebGLBufferExt}
Creates ARRAY buffer.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
array | TypedArray | Input array. | ||
itemSize | number | Array item size. | ||
numItems | number | Items quantity. | ||
usage | number | <optional> | STATIC_DRAW | Parameter of the bufferData call can be one of STATIC_DRAW, DYNAMIC_DRAW, or STREAM_DRAW. |
- Source
- Type:
- WebGLBufferExt
createArrayBufferLength(size, usageopt) → {WebGLBufferExt}
Creates ARRAY buffer specific length.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
size | number | |||
usage | number | <optional> | STATIC_DRAW | Parameter of the bufferData call can be one of STATIC_DRAW, DYNAMIC_DRAW, or STREAM_DRAW. |
- Source
- Type:
- WebGLBufferExt
createDefaultTexture(params, successopt)
Creates default texture object.
Name | Type | Attributes | Description |
---|---|---|---|
params | IDefaultTextureParams | | Texture parameters. | |
success | function | <optional> | Creation callback. |
- Source
createElementArrayBuffer(array, itemSize, numItems, usageopt) → {Object}
Creates ELEMENT ARRAY buffer.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
array | TypedArray | Input array. | ||
itemSize | number | Array item size. | ||
numItems | number | Items quantity. | ||
usage | number | <optional> | STATIC_DRAW | Parameter of the bufferData call can be one of STATIC_DRAW, DYNAMIC_DRAW, or STREAM_DRAW. |
- Source
- Type:
- Object
createEmptyTexture2DExt(widthopt, heightopt, filteropt, internalFormatopt, formatopt, typeopt, levelopt) → {WebGLTexture|null}
Creates empty texture.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
width | number | <optional> | 1 | Specifies the width of the texture image. |
height | number | <optional> | 1 | Specifies the width of the texture image. |
filter | string | <optional> | "NEAREST" | Specifies GL_TEXTURE_MIN(MAX)_FILTER texture value. |
internalFormat | string | <optional> | "RGBA" | Specifies the color components in the texture. |
format | string | <optional> | "RGBA" | Specifies the format of the texel data. |
type | string | <optional> | "UNSIGNED_BYTE" | Specifies the data type of the texel data. |
level | number | <optional> | 0 | Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image. |
- Source
- WebGL texture object.
- Type:
- WebGLTexture |
null
createEmptyTexture_l(width, height, internalFormatopt, texParamiopt) → {WebGLTexture|null}
Creates empty LINEAR filtered texture.
Name | Type | Attributes | Description |
---|---|---|---|
width | number | Empty texture width. | |
height | number | Empty texture height. | |
internalFormat | number | <optional> | |
texParami | number | <optional> |
- Source
- WebGL texture object.
- Type:
- WebGLTexture |
null
createEmptyTexture_n(width, height, internalFormatopt) → {WebGLTexture|null}
Creates Empty NEAREST filtered texture.
Name | Type | Attributes | Description |
---|---|---|---|
width | number | Empty texture width. | |
height | number | Empty texture height. | |
internalFormat | number | <optional> |
- Source
- WebGL texture object.
- Type:
- WebGLTexture |
null
createStreamArrayBuffer(itemSize, numItems, usageopt, bytesopt) → {WebGLBufferExt}
Creates STREAM_DRAW ARRAY buffer.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
itemSize | number | Array item size. | ||
numItems | number | Items quantity. | ||
usage | number | <optional> | STATIC_DRAW | Parameter of the bufferData call can be one of STATIC_DRAW, DYNAMIC_DRAW, or STREAM_DRAW. |
bytes | number | <optional> | 4 |
- Source
- Type:
- WebGLBufferExt
createTexture_a_webgl1(image, internalFormatopt, texParamiopt, textureopt) → {WebGLTexture|null}
Creates ANISOTROPY filter texture.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
image | ImageSource | Image or Canvas object. | ||
internalFormat | number | <optional> | ||
texParami | number | <optional> | ||
texture | WebGLTexture | | <optional> | null |
- Source
- WebGL texture object.
- Type:
- WebGLTexture |
null
createTexture_a_webgl2(image, internalFormatopt, texParamiopt, textureopt) → {WebGLTexture|null}
Creates ANISOTROPY filter texture.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
image | ImageSource | Image or Canvas object. | ||
internalFormat | number | <optional> | ||
texParami | number | <optional> | ||
texture | WebGLTexture | | <optional> | null |
- Source
- WebGL texture object.
- Type:
- WebGLTexture |
null
createTexture_l_webgl1(image, internalFormatopt, texParamiopt, textureopt) → {WebGLTexture|null}
Creates LINEAR filter texture.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
image | ImageSource | Image or Canvas object. | ||
internalFormat | number | <optional> | ||
texParami | number | <optional> | ||
texture | WebGLTexture | | <optional> | null |
- Source
- WebGL texture object.
- Type:
- WebGLTexture |
null
createTexture_l_webgl2(image, internalFormatopt, texParamiopt, textureopt) → {WebGLTexture|null}
Creates LINEAR filter texture.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
image | ImageSource | Image or Canvas object. | ||
internalFormat | number | <optional> | ||
texParami | number | <optional> | ||
texture | WebGLTexture | | <optional> | null |
- Source
- WebGL texture object.
- Type:
- WebGLTexture |
null
createTexture_mm_webgl1(image, internalFormatopt, texParamiopt, textureopt) → {WebGLTexture|null}
Creates MIPMAP filter texture.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
image | ImageSource | Image or Canvas object. | ||
internalFormat | number | <optional> | ||
texParami | number | <optional> | ||
texture | WebGLTexture | | <optional> | null |
- Source
- WebGL texture object.
- Type:
- WebGLTexture |
null
createTexture_mm_webgl2(image, internalFormatopt, texParamiopt, textureopt) → {WebGLTexture|null}
Creates MIPMAP filter texture.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
image | ImageSource | Image or Canvas object. | ||
internalFormat | number | <optional> | ||
texParami | number | <optional> | ||
texture | WebGLTexture | | <optional> | null |
- Source
- WebGL texture object.
- Type:
- WebGLTexture |
null
createTexture_n_webgl1(image, internalFormatopt, texParamiopt, textureopt) → {WebGLTexture|null}
Creates NEAREST filter texture.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
image | HTMLCanvasElement | | Image or Canvas object. | ||
internalFormat | number | <optional> | ||
texParami | number | <optional> | ||
texture | WebGLTexture | | <optional> | null |
- Source
- WebGL texture object.
- Type:
- WebGLTexture |
null
createTexture_n_webgl2(image, internalFormatopt, texParamiopt, textureopt) → {WebGLTexture|null}
Creates NEAREST filter texture.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
image | ImageSource | Image or Canvas object. | ||
internalFormat | number | <optional> | ||
texParami | number | <optional> | ||
texture | WebGLTexture | | <optional> | null |
- Source
- WebGL texture object.
- Type:
- WebGLTexture |
null
destroy()
- Source
getCenter() → {number}
Returns canvas center coordinates.
- Source
- Type:
- number
getClientAspect() → {number}
Returns canvas aspect ratio.
- Source
- Type:
- number
getHeight() → {number}
Returns context screen height.
- Source
- Type:
- number
getWidth() → {number}
Returns context screen width.
- Source
- Type:
- number
initialize()
Main function that initialize handler.
- Source
initializeExtension(extensionStr, showLog) → {any}
Initialize additional WebGL extensions.
Name | Type | Default | Description |
---|---|---|---|
extensionStr | string | Extension name. | |
showLog | boolean | false | Show logging. |
- Source
- Type:
- any
isWebGl2()
Check is gl context type equals webgl2
- Source
loadCubeMapTexture(params) → {WebGLTexture|null}
Creates cube texture.
Name | Type | Description | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params | Texture3DParams | Face image urls: Properties
|
- Source
- WebGL texture object.
- Type:
- WebGLTexture |
null
removeProgram(name)
Removes shader program from handler.
Name | Type | Description |
---|---|---|
name | string | Shader program name. |
- Source
setFrameCallback(callback)
Sets animation frame function.
Name | Type | Description |
---|---|---|
callback | function | Frame callback. |
- Source
setSize(w, h)
Sets handler canvas size.
Name | Type | Description |
---|---|---|
w | number | Canvas width. |
h | number | Canvas height. |
- Source
setStreamArrayBuffer(buffer, array, offsetopt) → {WebGLBufferExt}
Sets stream buffer.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
buffer | WebGLBufferExt | |||
array | TypedArray | |||
offset | number | <optional> | 0 |
- Source
- Type:
- WebGLBufferExt
start()
Starts animation loop.
- Source
(static) getContext(canvas, contextAttributesopt) → {WebGLContextExt|null}
Returns a drawing context on the canvas, or null if the context identifier is not supported.
Name | Type | Attributes | Description |
---|---|---|---|
canvas | HTMLCanvasElement | HTML canvas object. | |
contextAttributes | any | <optional> | See canvas.getContext contextAttributes. |
- Source
- Type:
- WebGLContextExt |
null
(static) getExtension(gl, name) → {any}
The return value is null if the extension is not supported, or an extension object otherwise.
Name | Type | Description |
---|---|---|
gl | WebGLRenderingContext | | WebGl context pointer. |
name | string | Extension name. |
- Source
- Type:
- any