glwrap.js

If you just want to jump to the source code go to https://github.com/artkalev/glwrap

This is a WebGL convenience library that I decided to create and properly format after realizing that I was constantly writing and rewriting a few of the same js classes that wrapped some WebGL related functionality in a more convenient way.

The features include using textures, framebuffers, meshes, mesh attributes, shaderprograms, object transformations, etc… Some of the most core components when drawing something with OpenGL.

Example

example source code: https://github.com/artkalev/glwrap/blob/master/test/test.html

Purpose

This library is suited for projects/experiments that do not benefit from using a massive library like THREE.js.

It makes working with raw webgl more convenient. After all there are only so many ways to write a class to handle texturing or mesh storage 🙂

Structure

The classes are designed to work independently from each other. Only constant that needs to be passed into methods is the webgl context object. But The constructors can be used without a webgl context present. Basically the webgl related buffers and initialisations are done the first time they are used.

For example when a Texture2D class is instanced it will have all the parameters present but not a webgl texture object. That is created when the texture is first used by its setActive() method (in case of a loaded url image it is initialized after the image is loaded). This enables to have a more flexible code in my opinion.

The separation from gl context allows the objects to be instanced before the gl context is even present, which also removes the need to depend on a global webgl context variable at initialization.

Check the documentation for more info

Future

A way load a mesh with the same simplicity as a texture is one of the main goals for me at the moment. Skeletal mesh handling is another big topic.