Skip to main content

WebGL Device Adapter

This module contains the WebGL adapter for the "abstract" API (

Simply importing installs the adapter and enables WebGL devices to be created using luma.createDevice(...):

import {luma} from '';
import ''; // Installs the WebGLDevice adapter

const device = await luma.createDevice({type: 'webgl', canvas: ...});

// Resources can now be created
const buffer = device.createBuffer(...);

To use a WebGL Device with raw WebGL calls, the application needs to access the WebGLRenderingContext. The context is available on the WebGLDevice subclass:

// @ts-expect-error
const gl =;

With a bit more work, typescript users can retrieve the WebGLRenderingContext without ignoring type errors:

import {cast} from '';
import {WebGLDevice} from ''; // Installs the WebGLDevice adapter

const webglDevice = cast<WebGPUDevice>(device);
const gl =;