2.3.9 • Published 10 years ago
webgl-compile-shader v2.3.9
webgl-compile-shader
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.