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:150

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:494

Tells the system to capture gamepad events on the canvas.

captureKeys

(
  • prevent_default
  • only_canvas
)

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

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:252

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:205

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:720

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:136

executes callback inside this webgl context

Parameters:

  • callback Function

fullscreen

()

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

launches de canvas in fullscreen mode

getGamepads

(
  • skip_mapping
)

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

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:782

use it to reset the the initial gl state

loadTexture

(
  • url
  • options
  • callback
)
Texture

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

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:127

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:650

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