Device
Quick answer
Device is the single entry point for GPU resources: it creates buffers, textures, shaders, pipelines, framebuffers and canvas contexts. In v9 create it asynchronously with luma.createDevice, passing type, adapters and createCanvasContext, and read device.features and device.limits to branch on backend capabilities.
luma. createDevice ( props ) → Promise<Device>
Key points
- luma.createDevice resolves a Promise<Device>; the constructor is not public.
- type accepts 'webgl', 'webgpu', 'best-available' or null.
- destroy() releases every resource the device owns.
Example
<script src="https://cdn.jsdelivr.net/npm/@luma.gl/core@9.4.2/dist/dist.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@luma.gl/webgl@9.4.2/dist/dist.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@luma.gl/shadertools@9.4.2/dist/dist.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@luma.gl/engine@9.4.2/dist/dist.min.js"></script>const device = await luma.luma.createDevice({
type: 'webgl',
adapters: [luma.webgl2Adapter],
createCanvasContext: {
canvas: document.getElementById('cv'),
useDevicePixels: Math.min(window.devicePixelRatio, 2),
autoResize: true
}
});
Notes
- Building resources before the promise resolves leaves undefined handles.
- Mixing WebGL and WebGPU devices in one rendering context is unsupported.
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Atlaslog (2026). Device. https://www.jingweizhi.com/en/lumagl/api/device.html (accessed 2026-11-03).