Package Exports
- webgl-context
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (webgl-context) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
webgl-context
Grabs a WebGLRenderingContext, returning null if it doesn't exist. Similar to 2d-context.
//get a webgl context, will be null if not found
var gl = require('webgl-context')()
if (gl) {
document.body.appendChild(gl.canvas)
//do something...
}Or, with options:
//or with optional settings...
var gl = require('webgl-context')({
canvas: canvas, //the canvas DOM element to use
width: 400, //resizes the canvas..
height: 200,
antialias: true //can specify custom attributes here
})Usage
ctx = require('webgl-context')([opt])
Gets a new canvas context with optional parameters:
canvasa canvas element to use, otherwise creates a new elementwidtha width to set, otherwise no changeheighta height to set, otherwise no change- other attributes are passed to the getContext call, like
alphaandantialias
You can then get a reference of the canvas element with ctx.canvas.
See Also
License
MIT, see LICENSE.md for details.
