glslify-require
Browserify plugin to require() OpenGL Shading Language (GLSL) files
Last updated 4 years ago by ericmorand .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install glslify-require 
SYNC missed versions from official npm registry.

glslify-require

NPM version Build Status Dependency Status Coverage percentage

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

Current Tags

  • 1.1.0                                ...           latest (4 years ago)

4 Versions

  • 1.1.0                                ...           4 years ago
  • 1.0.2                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 4
Dependencies (4)
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |