Class: Handler

og.webgl.Handler

new og.webgl.Handler(id, params)

A WebGL handler for accessing low-level WebGL capabilities.
Name Type Description
id string Canvas element id that WebGL handler assing with. If it's null or undefined creates hidden canvas and handler bacomes hidden.
params Object optional Handler options:
Name Type Description
anisotropy number optional Anisitropy filter degree. 8 is default.
width number optional Hidden handler width. 256 is default.
height number optional Hidden handler height. 256 is default.
param.scontext Object optional Native WebGL context attributes. See https://www.khronos.org/registry/webgl/specs/latest/1.0/#WEBGLCONTEXTATTRIBUTES
params.extensions Array.<string> optional Additional WebGL extension list. Available by default: OES_standard_derivatives, EXT_texture_filter_anisotropic.

Members

static,constantog.webgl.Handler.MAX_SIZEnumber

Maximum texture image size.

protected_clocks

Custom timers.

activeShaderProgramog.webgl.ShaderController

Current active shader program controller.

canvasObject

WebGL rendering canvas element.

createTexture

Creates DEFAULT filter texture, ANISOTROPY is default.

defaultClockog.Clock

Application default timer.

readonlydeltaTimenumber

Draw frame time in milliseconds.

extensionsObject

Current WebGL extensions. Becomes here after context initialization.

glObject

WebGL context.
Shader program controller list.

Methods

activateBlending()

Activate blending.

activateDepthTest()

Activate depth test.

activateFaceCulling()

Activate face culling.

addShaderProgram(program, notActivate)

Adds shader program to the handler.
Name Type Description
program og.shaderProgram.ShaderProgram Shader program.
notActivate boolean optional If it's true program will not compile.

addShaderPrograms(programsArr)

Adds shader programs to the handler.
Name Type Description
programsArr Array.<og.shaderProgram.ShaderProgram> Shader program array.
Clearing gl frame.

createArrayBuffer(array, itemSize, numItems){Object}

Creates ARRAY buffer.
Name Type Description
array Array.<number> Input array.
itemSize number Array item size.
numItems number Items quantity.
Returns:
Type Description
Object

createDefaultTexture(params)

Name Type Description
params

createElementArrayBuffer(array, itemSize, numItems){Object}

Creates ELEMENT ARRAY buffer.
Name Type Description
array Array.<number> Input array.
itemSize number Array item size.
numItems number Items quantity.
Returns:
Type Description
Object

createEmptyTexture_l(width, height){Object}

Creates empty LINEAR filtered texture.
Name Type Description
width number Empty texture width.
height number Empty texture height.
Returns:
Type Description
Object - WebGL texture object.

createEmptyTexture_n(width, height){Object}

Creates Empty NEAREST filtered texture.
Name Type Description
width number Empty texture width.
height number Empty texture height.
Returns:
Type Description
Object - WebGL texture object.

createTexture_a(image){Object}

Creates ANISOTROPY filter texture.
Name Type Description
image Object Image or Canvas object.
Returns:
Type Description
Object - WebGL texture object.

createTexture_l(image){Object}

Creates LINEAR filter texture.
Name Type Description
image Object Image or Canvas object.
Returns:
Type Description
Object - WebGL texture object.

createTexture_mm(image){Object}

Creates MIPMAP filter texture.
Name Type Description
image Object Image or Canvas object.
Returns:
Type Description
Object - WebGL texture object.

createTexture_n(image){Object}

Creates NEAREST filter texture.
Name Type Description
image Object Image or Canvas object.
Returns:
Type Description
Object - WebGL texture object.

deactivateBlending()

Deactivate blending.

deactivateDepthTest()

Deactivate depth test.

deactivateFaceCulling()

Deactivate face cullting.

drawFrame(now)

Draw single frame.
Name Type Description
now number Frame current time milliseconds.

getCenter(){number}

Returns screen center coordinates.
Returns:
Type Description
number

getClientAspect(){number}

Returns canvas aspect ratio.
Returns:
Type Description
number

getHeight(){number}

Returns context screen height.
Returns:
Type Description
number

getWidth(){number}

Returns context screen width.
Returns:
Type Description
number
Main function that initialize handler.

initializeExtension(extensionStr)

Initialize additional WebGL extensions.
Name Type Description
extensionStr string Extension name.

loadCubeMapTexture(params){Object}

Creates cube texture.
Name Type Description
params Object.<string> Face image urls:
Name Type Description
px string Positive X or right image url.
nx string Negative X or left image url.
py string Positive Y or up image url.
ny string Negative Y or bottom image url.
pz string Positive Z or face image url.
nz string Negative Z or back image url.
Returns:
Type Description
Object - WebGL texture object.

removeShaderProgram(program)

Removes shader program from handler.
Name Type Description
program String Shader program name.

setFrameCallback(callback)

Sets animation frame function.
Name Type Description
callback callback Frame callback.

setSize(width, height)

Sets handler canvas size.
Name Type Description
width number Canvas width.
height number Canvas height.
Starts animation loop.