glslify-promise
A Promise wrapper for glslify, providing a consistent interface between both Node.js and browserify
Last updated 5 years ago by hughsk .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install glslify-promise 
SYNC missed versions from official npm registry.

glslify-promise

experimental

A Promise wrapper for glslify, providing a consistent interface between both Node.js and browserify.

Intended for use with Pex.

Usage

NPM

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.

Current Tags

  • 1.0.2                                ...           latest (5 years ago)

3 Versions

  • 1.0.2                                ...           5 years ago
  • 1.0.1                                ...           5 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 1
Dependencies (5)
Dev Dependencies (4)
Dependents (1)

Copyright 2014 - 2017 © taobao.org |