Skip to content

mattdesl/webgl-compile-shader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

compiles vertex and fragment source into a WebGLProgram object

Resources

License

Stars

Watchers

Forks

Packages

No packages published