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 = ;let glslifyRequire = ; let bundle = ;
Now, you can use require() to retrieve GLSL source code as a JavaScript string:
var src = ; console;
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 = ;
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 = ;let glslifyRequire = ; let bundle = ;
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