$ cnpm install 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
})
ctx = require('webgl-context')([opt])Gets a new canvas context with optional parameters:
canvas a canvas element to use, otherwise creates a new elementwidth a width to set, otherwise no changeheight a height to set, otherwise no changealpha and antialiasYou can then get a reference of the canvas element with ctx.canvas.
MIT, see LICENSE.md for details.
Copyright 2013 - present © cnpmjs.org