regl is a JavaScript library that wraps WebGL with command and resource abstractions. It removes shared GL state to make draw calls declarative and easier to compose.
Overview
regl reframes WebGL programming around immutable command objects and GPU resource handles instead of mutable global state. Developers describe static and dynamic parameters for each draw, and regl compiles that description into optimized JavaScript for execution.
The library stays dependency-free for npm or standalone script-tag use, targets browser environments, and documents a gallery of examples from minimal triangles through effects ported from other WebGL ecosystems. It intentionally avoids scene-graph opinions so consumers integrate their own math and structure.
Design goals emphasize simplicity, correctness checks in development mode, performance via code generation, semver stability, and direct access to advanced extensions such as instancing and multiple render targets. Extensive unit tests back runtime validation.
Teams pick regl when they want lower-level GPU control than a full engine yet more structure than raw WebGL calls, including visualization and interactive graphics tooling.
Key features
- Command-based WebGL API
- GPU resource abstractions
- Dynamic code generation
- Development-time validation
- No npm dependencies
- Browser and bundler support
- Gallery of example shaders
- Access to WebGL extensions
Use cases
- Custom WebGL visualizations
- Interactive graphics prototypes
- Shader effect experiments
- Embedding GPU views in web apps
- Teaching WebGL fundamentals