Skip to content

mattdesl/kami-batch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kami-batch

unstable

A fast and efficient 2D sprite batcher based loosely on LibGDX's implementation.

Usage

NPM

See examples folder for details. A full program could look like this:

//setup a canvas
var gl = require('webgl-context')({
    width: 512,
    height: 512
});

//an opaque white texture, useful for tinting lines and rectangles
var tex = require('kami-white-texture')(gl);

//create a sprite batcher
var batch = require('kami-batch')(gl);

batch.begin();

//tint the vertex attributes
batch.setColor(1,0,0);

//draw some sprites
batch.draw(tex, 0, 0, 256, 256);
batch.draw(tex, 5, 5, 12, 51);

//submit to GPU
batch.end();

//add to DOM
document.body.appendChild( gl.canvas );

Planned Changes

  • use projection matrices instead of a vector
  • support rotation on the fly

License

MIT, see LICENSE.md for details.

About

fast 2D sprite batcher for kami / WebGL

Resources

License

Stars

Watchers

Forks

Packages

No packages published