Completely reset the state of a WebGL context, deleting any allocated resources
Last updated 6 years ago by hughsk .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install gl-reset 
SYNC missed versions from official npm registry.


Completely reset the state of a WebGL context, deleting any allocated resources.

Resetting is slow and instrumentation introduces a very slight overhead on creating new resources. However, this is useful:

  • If you want to safely recycle a WebGL context without state leaking between renders.
  • To capture and remove any generated resources during a render.

There's a limit on the number of contexts you can have running simultaneously on a page, and (at least on Chrome) when hitting the threshold you simply lose the least recently created one. To work around this limit, you can instead reset and reuse a single WebGL context between multiple renders.



reset = require('gl-reset')(gl)

Returns a function that, when called, will remove any existing resources and reset the current WebGL state.

Note: this function must be created before creating any resources, as it instruments several WebGL methods to do its thing.

var reset = require('gl-reset')(gl)

function render() {
  // Triggers a context reset


Resets the state, without instrumenting the context and without removing any allocated resources.


MIT. See for details.

Current Tags

  • 1.0.0                                ...           latest (6 years ago)

1 Versions

  • 1.0.0                                ...           6 years ago
Today 0
This Week 0
This Month 3
Last Day 0
Last Week 1
Last Month 3
Dependencies (0)
Dev Dependencies (4)

Copyright 2014 - 2016 © |