gl-context

0.1.1 • Public • Published

gl-context stable

A shorthand module for creating a new WebGL context and basic animation loop.

Normally I'd recommend gl-now, but this is for those cases when you want more flexibility.

Usage

gl-context

gl = createContext(canvas, [opts], [render])

Creates and returns a new WebGL context attached to canvas. Optionally, you can pass in a render function and this will be called once each frame using requestAnimationFrame.

Optionally, you can pass opts to the getContext method, e.g.

var canvas = document.createElement('canvas')
 
var gl = createContext(canvas, {
  premultipliedAlpha: false
}, function render() {
  // render loop...
})

License

MIT. See LICENSE.md for details.

Package Sidebar

Install

npm i gl-context

Weekly Downloads

19

Version

0.1.1

License

MIT

Last publish

Collaborators

  • hughsk