mirror of
https://github.com/visgl/luma.gl.git
synced 2025-12-08 17:36:19 +00:00
API Overview
The luma.gl API is designed to expose the capabilities of the GPU and shader programming to web applications.
Core responsibilities for any GPU library are to enable applications to perform:
- GPU device access - Open a GPU device and query its capabilities
- GPU memory management - Create, upload memory to and read from Buffers, Textures etc.
- GPU resource management - Create
Shader,Renderpipeline,RenderPassetc objects. - GPU binding management - Make attribute buffers, uniforms, textures, samplers available to GPU shaders.
- Shader execution / rendering - Drawing into textures, running compute shaders.
- GPU parameter management - Configuring blending, clipping, depth tests etc.
Portability
luma.gl enables the creation of portable applications that can run on top of either WebGPU, WebGL 2, or WebGL.
The @luma.gl/core module provides an abstract API for writing application code
that works with both WebGPU and WebGL.
The @luma.gl/core module cannot be used on its own: it relies on being backed up by another module
that implements the API. luma.gl provides adapters (implementations of the abstract API)
through the @luma.gl/webgl and @luma.gl/webgpu modules.
Usage
Most luma.gl applications will:
- Create a
Deviceclass to access the GPU (either using WebGPU or WebGL). - Use that device to upload data to the GPU in the form of
BufferandTextureobjects. - Create one or more
RenderingPipelineobjects from GLSL or WGSL shader code. - Bind attribute buffers and bindings (textures, uniform buffers or uniforms).
- Start a render loop, and use a
RenderPassto draw.