gl-flags
Easily change and access your WebGL flags set by gl.enable/gl.disable with minimised overhead
Last updated 6 years ago by hughsk .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install gl-flags 
SYNC missed versions from official npm registry.

gl-flags

stable

Easily change and access your WebGL flags set by gl.enable/gl.disable with minimised overhead. This package transparently adds a caching layer to these functions, providing a more convenient API, smoothly interoperating with other libraries unaware of gl-flags, and only requiring to read from the GPU once for each parameter on creation.

Usage

NPM

flags = glFlags(gl)

Creates a new flags instance attached to gl, which is a WebGLRenderingContext.

flags.FLAG_NAME

Returns a boolean value reflecting whether gl.FLAG_NAME is enabled or not. For example, the following:

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

flags.BLEND = true
flags.CULL_FACE = true

Is equivalent to this:

gl.enable(gl.BLEND)
gl.disable(gl.CULL_FACE)

You can access each property without needing to hit the GPU either, so you can easily toggle flags temporarily without effecting global state like so:

var previousBlend = flags.BLEND

flags.BLEND = true
// drawing API
flags.BLEND = previousBlend

Parameters are only changed if their state has changed.

Contributing

See stackgl/contributing for details.

License

MIT. See LICENSE.md for details.

Current Tags

  • 1.1.0                                ...           latest (6 years ago)

2 Versions

  • 1.1.0                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (6)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |