https://github.com/stackgl/gl-clear
A helper WebGL module for clearing the current buffer
https://github.com/stackgl/gl-clear
Last synced: about 1 year ago
JSON representation
A helper WebGL module for clearing the current buffer
- Host: GitHub
- URL: https://github.com/stackgl/gl-clear
- Owner: stackgl
- License: other
- Created: 2014-05-12T12:20:22.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2017-04-29T20:18:00.000Z (about 9 years ago)
- Last Synced: 2025-04-12T05:05:39.991Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 151 KB
- Stars: 11
- Watchers: 8
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# gl-clear [](http://github.com/badges/stability-badges)
A helper WebGL module for clearing the current buffer – extracted from
[@mikolalysenko](http://github.com/mikolalysenko)'s
[gl-now](http://github.com/mikolalysenko/gl-now).
## Usage
[](https://nodei.co/npm/gl-clear/)
### `clear = glClear(options)`
Creates a clear function for you, accepting the following options:
* `color`: An RGBA array for the colors to clear the buffer to, between 0 and 1.
Set to `false` to disable.
* `depth`: A single value to clear the depth buffer to. Set to `false` to disable.
* `stencil`: A single value to clear the stencil buffer to, disabled by default.
### `clear(gl)`
Clears the current buffer on the `gl` context.
### `clear.color = color`
Updates the clear color. Set to `false` to disable.
### `clear.depth = depth`
Updates the depth value to clear to. Set to `false` to disable.
### `clear.stencil = stencil`
Updates the stencil value to clear to. Set to `false` to disable.
## Alternatives
This module is intended as a small shorthand to WebGL's clear methods.
Thankfully clearing is a simple procedure so you are also welcome to fall back
onto WebGL's clear methods if `gl-clear` doesn't meet your needs. For example:
``` javascript
// clear the screen red, and clear the depth buffer:
gl.clearColor(1, 0, 0, 1)
gl.clearDepth(1)
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
```
If you've written your own clear module, let us know and we'll link to it
here!
## License
MIT. See [LICENSE.md](http://github.com/hughsk/gl-clear/blob/master/LICENSE.md) for details.