webgl-compile-shader

2.3.9 • Public • Published

webgl-compile-shader

experimental

Compiles a WebGL shader program from the given vertex and fragment source. Throws an error on failure, providing clear logging with line numbers and the problematic shader (vertex vs. fragment).

The shaders are not detached/deleted after link, as this was causing issues with Chrome's WebGLInspector.

Usage

var compiler = require('webgl-compile-shader');
var info = compile({
    vertex: vertSource,
    fragment: fragSource,
 
    //optional args
    gl: gl, //WebGL context; if not specified a new one will be created
    verbose: true, //whether to emit console.warn messages when throwing errors
    attributeLocations: { ... key:index pairs ... },
});
 
//for dealing with the WebGL object
var program = info.program;
//for dealing with logging/warnings 
var log = info.log;
//vert and frag shader GL objects are also exported
console.log(info.vertex, info.fragment);

License

MIT, see LICENSE.md for details.

Package Sidebar

Install

npm i webgl-compile-shader

Weekly Downloads

11

Version

2.3.9

License

MIT

Last publish

Collaborators

  • mattdesl