luma.gl

WebGL Context

Provides functions to create and initialize a WebGL context, and to check for presence of WebGL and extensions.

Note that the use of these functions is NOT required to use the remaining functions and classes in luma.gl.

You could e.g. manually create a WebGLContext by using canvas.getContext, or use a context created by another WebGL library. In fact, luma.gl is explicitly designed to work with any WebGL context, and in contrast to some other approaches, luma.gl maintains no “hidden state” that might complicate composing your code with other WebGL based modules.

Function: createGLContext

Creates and returns a WebGL context, both in browsers and in Node.js.

Syntax:

const gl = createGLContext(options);

Arguments:

  1. options (object) - An object with the following properties:

Options:

Remarks

import headlessGL from 'gl';
import {createGLContext} from 'luma.gl';
const gl = createGLContext({headlessGL})

Static Method: getGLExtension

Returns the WebGL extension with the given name, For example OES_texture_float. Throws an Error if the extension is not available.

More info here.

Syntax:

getGLExtension(gl, name);

Arguments:

  1. name (string) - The name of the extension.

luma.gl WebGL Wrappers - Design Goals


luma.gl provides JavaScript classes that manage core WebGL object types, with the intention of making these WebGL objects easier to work with in JavaScript, without adding an abstraction layer.

To maximize interoperability with WebGL code that does not use luma.gl, the WebGLRendingContexttype does not have a corresponding luma.gl wrapper class, but is instead used directly by the luma.gl API. A simple global function is provided to help in creating gl contexts.

Debugging


Luma has a number of provisions for debugging that can help you save a lot of time during development.