# gl-reset

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

Latest version **1.0.0** (published 2014-10-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install gl-reset
pnpm add gl-reset
yarn add gl-reset
bun add gl-reset
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2014-10-26 |
| First published | 2014-10-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Hugh Kennedy |
| Maintainers | hughsk |
| Keywords | webgl, stackgl, gl, reset, state, remove, delete, purge |

## Links

- npm: https://www.npmjs.com/package/gl-reset
- Repository: https://github.com/stackgl/gl-reset
- Issues: https://github.com/stackgl/gl-reset/issues
- npm.io page: https://npm.io/package/gl-reset

## Alternatives

- [@reckona/mreact-store](https://npm.io/package/@reckona/mreact-store.md) — 976 weekly downloads
- [regular-state](https://npm.io/package/regular-state.md) — 410 weekly downloads
- [@pacote/flux-actions](https://npm.io/package/@pacote/flux-actions.md) — 65 weekly downloads
- [@pilotlab/lux-debug](https://npm.io/package/@pilotlab/lux-debug.md) — 39 weekly downloads
- [vue-persist-state](https://npm.io/package/vue-persist-state.md) — 19 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2014-10-26

## README

# gl-reset
![](http://img.shields.io/badge/stability-experimental-orange.svg?style=flat)
![](http://img.shields.io/npm/v/gl-reset.svg?style=flat)
![](http://img.shields.io/npm/dm/gl-reset.svg?style=flat)
![](http://img.shields.io/npm/l/gl-reset.svg?style=flat)

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.

## Usage

[![NPM](https://nodei.co/npm/gl-reset.png)](https://nodei.co/npm/gl-reset/)

### `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.

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

function render() {
  // Triggers a context reset
  reset()
}
```

### `require('gl-reset/state')(gl)`

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

## License

MIT. See [LICENSE.md](http://github.com/hughsk/gl-reset/blob/master/LICENSE.md) for details.

---
_Source: https://npm.io/package/gl-reset · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
