The WebGL Classes
luma.gl's WebGL classes are designed to offer a simple way to work with WebGL in JavaScript, without hiding or interfering with the WebGL API.
Highlights:
- luma.gl organizes the WebGL API in a set JavaScript classes that manage the underlying WebGL objects
- Instead of accessing all WebGL methods through the WebGL context, the methods that manipulate a certain WebGL object are collected in a class.
- This makes it easy see at a glance what classes WebGL offers, and allows you to quickly read up on what functionality is offered by each specific class.
WebGL Resources
luma.gl provides a set of JavaScript classes that wrap WebGL resource objects, with the goal of making WebGL easier to work with and to learn.
These objects all inherit from the Resource class.
| ----------------------------------- | ============== | =============== |
| Resource Class | WebGL Type | Description |
| ----------------------------------- | ============== | =============== |
| Buffer | WebGLBuffer | Holds memory on GPU |
| Framebuffer | WebGLFrameBuffer | Off-screen render target, Container for textures and renderbuffers. |
| Renderbuffer | WebGLRenderBuffer | Holds image data that is optimized for rendering but does not supporting sampling |
| Program | WebGLProgram | Shaders, attributes and uniforms. |
| Shader | WebGLShader | Holds a compiled GLSL shader program. |
| Texture2D | WebGLTexture(GL.TEXTURE_2D) | Holds a loaded texture in a format that supports sampling |
| TextureCube | WebGLTexture(GL.TEXTURE_CUBE) | Holds 6 textures |
| Texture2DArray WebGL2 | WebGLTexture(GL.TEXTURE_2D_ARRAY) | Holds an array of textures |
| Texture3D WebGL2 | WebGLTexture(GL.TEXTURE_3D) | Holds a stack of textures |
| Query WebGL2/ext* | WebGLQuery | Occlusion, Tranform Feedback and Performance Queries |
| Sampler WebGL2 | WebGLSampler | Stores texture sampling params |
| Sync WebGL2 | WebGLSync | Synchronize GPU and app. |
| TransformFeedback WebGL2 | WebGLTransformFeedback | Capture Vertex Shader output |
| VertexArrayObject WebGL2/ext | WebGLVertexArrayObject | Save global vertex attribute array. |
| ----------------------------------- | ============== | =============== |
| Class/Module | WebGL Type | Description |
| ----------------------------------- | ============== | =============== |
| context | WebGLRenderingContext | The main GL context. |
| VertexAttributes | gl.vertexAttrib* | Manipulates shader attributes (TBD merge with VAO?) |