webgl-context
Grabs a WebGLRenderingContext, returning null if it doesn't exist. Similar to 2d-context.
var gl = require('webgl-context')()
if (gl) {
document.body.appendChild(gl.canvas)
}
Or, with options:
var gl = require('webgl-context')({
canvas: canvas,
width: 400,
height: 200,
antialias: true
})
Usage
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 change- other attributes are passed to the getContext call, like
alpha
and antialias
You can then get a reference of the canvas element with ctx.canvas
.
See Also
License
MIT, see LICENSE.md for details.