glslify-promise v1.0.2
glslify-promise
A Promise wrapper for glslify, providing a consistent interface between both Node.js and browserify.
Intended for use with Pex.
Usage
promise = glslify(file, [options])
Where file and options accept the same arguments as
the glslify package.
For example, the following should work out of the box with Node:
var glslify = require('glslify-promise')
var promise = glslify(__dirname + '/shader.glsl')
promise.then(function(source) {
console.log(source) // your glslified GLSL source!
})By adding glslify-promise/transform to your package.json
file, you should be able to do the same in browserify too:
{
"browserify": {
"transform": [
"glslify-pex/transform"
]
}
}Note that like glslify and brfs file paths need to be statically determinable, meaning that you can't use variables in your require statements. The following script would produce an error when running with browserify:
var glslify = require('glslify')
var filename = __dirname + '/shader.glsl'
var promise = glslify(filename)Whereas the following is still valid:
var glslify = require('glslify')
var promise = glslify(__dirname + '/shader.glsl')Also note that this package is using the native Promise global.
For cross-browser compatibility you'll want to include the
es6-promise polyfill.
Contributing
See stackgl/contributing for details.
License
MIT. See LICENSE.md for details.
