API Docs for:
Show:

gl Class

Defined in: ../src/core.js:50

the webgl context returned by GL.create, its a WebGLRenderingContext with some extra methods added

Methods

animate

()

Defined in ../src/core.js:182

Launch animation loop (calls gl.onupdate and gl.ondraw every frame) example: gl.ondraw = function(){ ... } or gl.onupdate = function(dt) { ... }

captureGamepads

()

Defined in ../src/core.js:548

Tells the system to capture gamepad events on the canvas.

captureKeys

(
  • prevent_default
  • only_canvas
)

Defined in ../src/core.js:464

Tells the system to capture key events on the canvas. This will trigger onkey

Parameters:

  • prevent_default Boolean

    prevent default behaviour (like scroll on the web, etc)

  • only_canvas Boolean

    only caches keyboard events if they happen when the canvas is in focus

captureMouse

(
  • capture_wheel
)

Defined in ../src/core.js:284

Tells the system to capture mouse events on the canvas. This will trigger onmousedown, onmousemove, onmouseup, onmousewheel callbacks assigned in the gl context example: gl.onmousedown = function(e){ ... } The event is a regular MouseEvent with some extra parameters

Parameters:

  • capture_wheel Boolean

    capture also the mouse wheel

destroy

()

Defined in ../src/core.js:237

Destroy this WebGL context (removes also the Canvas from the DOM)

drawTexture

(
  • texture
  • x
  • y
  • w
  • h
  • tx
  • ty
  • tw
  • th
)

Defined in ../src/core.js:798

draws a texture to the viewport

Parameters:

  • texture Texture
  • x Number

    in viewport coordinates

  • y Number

    in viewport coordinates

  • w Number

    in viewport coordinates

  • h Number

    in viewport coordinates

  • tx Number

    texture x in texture coordinates

  • ty Number

    texture y in texture coordinates

  • tw Number

    texture width in texture coordinates

  • th Number

    texture height in texture coordinates

execute

(
  • callback
)

Defined in ../src/core.js:168

executes callback inside this webgl context

Parameters:

  • callback Function

fullscreen

()

Defined in ../src/core.js:687

launches de canvas in fullscreen mode

getGamepads

(
  • skip_mapping
)

Defined in ../src/core.js:572

returns the detected gamepads on the system

Parameters:

  • skip_mapping Bool

    if set to true it returns the basic gamepad, otherwise it returns a class with mapping info to XBOX controller

gl.reset

()

Defined in ../src/core.js:861

use it to reset the the initial gl state

isMobile

() Boolean

Defined in ../src/core.js:979

Tells you if the app is running on a mobile device (iOS or Android)

Returns:

Boolean:

true if is running on a iOS or Android device

loadTexture

(
  • url
  • options
  • callback
)
Texture

Defined in ../src/core.js:766

returns a texture and caches it inside gl.textures[]

Parameters:

  • url String
  • options Object

    (same options as when creating a texture)

  • callback Function

    function called once the texture is loaded

Returns:

Texture:

texture

makeCurrent

()

Defined in ../src/core.js:159

sets this context as the current global gl context (in case you have more than one)

snapshot

(
  • startx
  • starty
  • areax
  • areay
)
Canvas

Defined in ../src/core.js:704

returns a canvas with a snapshot of an area this is safer than using the canvas itself due to internals of webgl

Parameters:

  • startx Number

    viewport x coordinate

  • starty Number

    viewport y coordinate from bottom

  • areax Number

    viewport area width

  • areay Number

    viewport area height

Returns:

Canvas:

canvas