Litegl.js is a library that wraps WebGL to make it more user-friendly by creating classes for managing different items like Buffer, Mesh, Texture, Shader and other common aspects of any WebGL applications. It is a fork from LightGL.js by Evan Wallace, but some major changes have been made. Some of the main differences:
- Matrices have been replaced by glMatrix
- Meshes are forced to be stored in ArrayBuffer formats
- Meshes support range rendering with offset
- Removed fixed pipeline behaviour
- Better event handling (mouse position, mouse wheel, dragging)
- Textures expanded to support Arraybuffers and Cubemaps
- Events system to trigger events from any object
Demos are included in the Examples folder but you can check them in this website.
Include the library and dependencies
<script src="js/gl-matrix-min.js"></script>
<script src="js/litegl.js"></script>
Create the context
var gl = GL.create({width:800, height:600});
Attach to DOM
document.getElementById("mycontainer").appendChild( gl.canvas )
Hook events
gl.ondraw = function() { ... }
gl.onupdate = function(dt) { ... }
Get user input
gl.captureMouse();
gl.onmousedown = function(e) { ... }
gl.captureKeys();
gl.onkey = function(e) { ... }
Compile shader
var shader = new Shader( vertex_shader_code, fragment_shader_code);
Create Mesh
var mesh = Mesh.cube();
Render
shader.uniforms( my_uniforms ).draw( mesh );
The doc folder contains the documentation. For info about http://glmatrix.com check the documentation in its website.
It includes several commands in the utils folder to generate doc, check errors and build minifyed version.
You can write any feedback to [email protected]