Class: Context

SQR. Context

Constructor

new Context()

When creating the Context object, a canvas element or a selector (ex. #gl-canvas) can be passed to this function. If omitted a new canvas element will be created and it will be available as the canvas property of the object returned by the SQR.Context functiom. See quick example below or read more in basic-setup.
Source:
Example
// the `new` keyword is optional, all methods are chainable
var w = window.innerWidth, h = window.innerHeight;
var c = SQR.Context('#canvas').create().size(w, h).clearColor(0, 0, 0, 1);

Members

canvas :HTMLCanvasElement

Represents the canvas used to get the webgl context from.
Type:
  • HTMLCanvasElement
Source:

Methods

create(options, onError)

Creates the webgl context.
Parameters:
Name Type Description
options Options as defined in Specs, section 5.2. Passing the options is not mandatory, if uses default values otherwise.
onError callback in case WebGL is not supported if ommited, this function will throw (see below) a error if there are problems.
Source:
Throws:
error is webgl context cannot be created (ex. webgl is not supported)
Returns:
SQR.Context