Skip to content
A lightweight WebGL library
JavaScript HTML Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore added documentation Jun 28, 2011
LICENSE initial commit Jun 26, 2011 switch from closure compiler to uglify Jun 29, 2016 switch from closure compiler to uglify Jun 29, 2016


This library makes it easier to quickly prototype WebGL applications. It's lower level than many other WebGL libraries and while it doesn't provide a scene graph, it re-implements OpenGL's modelview/projection matrix stack to provide similar functionality. It also re-introduces some built-in uniforms from GLSL (such as gl_Vertex and gl_ModelViewProjectionMatrix) and OpenGL's immediate mode.

Building the library

  • python build lightgl.js from the files in the src directory
  • python debug: rebuild the library any time the contents of the src directory change
  • python release: minify the library using UglifyJS, which assumes there is an uglifyjs command in your path
  • docco src/*.js: build the documentation, which is generated in the docs directory

The latest lightgl.js build can be found at

Sample code

    <!DOCTYPE html>
      <script src="lightgl.js"></script>

    var angle = 0;
    var gl = GL.create();
    var mesh = GL.Mesh.cube();
    var shader = new GL.Shader('\
      void main() {\
        gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\
    ', '\
      void main() {\
        gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\

    gl.onupdate = function(seconds) {
      angle += 45 * seconds;

    gl.ondraw = function() {
      gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
      gl.translate(0, 0, -5);
      gl.rotate(30, 1, 0, 0);
      gl.rotate(angle, 0, 1, 0);





The documentation is automatically generated using Docco:


Available examples:

You can’t perform that action at this time.