gl-extension
Grabs an extension from the specified WebGL context.
If the context is using WebGL 2.0, core functions and contexts are wrapped with dummy interfaces, so your code does not need to change.
Example
var getExtension = // get an extensionvar ext = if ext // this will work even when gl is a WebGL 2.0 context var array = ext console
Install
npm install gl-extension --save
Usage
ext = getExtension(gl, name)
If gl
is a WebGL 1.0 instance, or if the extension is not part of core in WebGL 2.0, this is the same as calling gl.getExtension(name)
.
If gl
is a WebGL 2.0 instance and name
is an extension that has been promoted to core, a new wrapper object will be returned mimicing the API and constants of the WebGL 1 extension.
See the WebGL Extension Registry for extension details.
require('gl-extension').patch(gl)
Patches the gl.getExtension
function correctly so that legacy code bases (e.g. ThreeJS) can use WebGL2 without problems.
See Also
License
MIT, see LICENSE.md for details.