glslify-require
v1.1.0
Published
Browserify plugin to require() OpenGL Shading Language (GLSL) files
Downloads
39
Maintainers
Readme
glslify-require
Browserify plugin to require() OpenGL Shading Language (GLSL) files
NOTE: Has not been tested on Node below version 6.0.0. Please report any bugs you may find.
Installation
npm install glslify-require
Usage
Command Line
browserify index.js -p [ glslify-require ] > bundle.js
Middleware
let browserify = require('browserify');
let glslifyRequire = require('glslify-require');
let bundle = browserify()
.plugin(glslifyRequire)
.add('index.js');
Now, you can use require() to retrieve GLSL source code as a JavaScript string:
var src = require('../path/to/my/glsl/file.glsl');
console.log(src);
Events
Being fueled by glslify and glslify-deps, you can import and export GLSL modules. glslify-require will emit file events accordingly on browserify pipeline to keep your middleware up-to-date with dependencies.
Let's consider the following files:
index.js
var src = require('./main.glsl');
main.glsl
#pragma glslify: foo = require(./foo)
void main() {
bar = foo;
};
foo.glsl
struct Foo {
vec3 bar;
};
#pragma glslify: export(Foo)
The file event handler would be called for index.js, main.glsl and foo.glsl:
let browserify = require('browserify');
let glslifyRequire = require('glslify-require');
let bundle = browserify()
.plugin(glslifyRequire)
.add('index.js')
.on('file', function (file, id, parent) {
// called for index.js, main.glsl and foo.glsl
});
Contributing
- Fork the main repository
- Code
- Implement tests using node-tap
- Issue a pull request keeping in mind that all pull requests must reference an issue in the issue queue
License
Apache-2.0 © Eric MORAND