| Crates.io | webgl2 |
| lib.rs | webgl2 |
| version | 1.1.4 |
| created_at | 2025-11-09 00:42:38.427446+00 |
| updated_at | 2025-12-26 13:56:57.165383+00 |
| description | WebGL2 shader compiler, emulator, and debugger |
| homepage | |
| repository | https://github.com/mavity/webgl2 |
| max_upload_size | |
| id | 1923443 |
| size | 7,322,004 |
GPU in WASM: slow but guaranteed and immovable like Sisyphus's rock.

import { webGL2 } from 'webgl2';
// Initialize the Rust-backed WebGL2 context
const gl = await webGL2();
// Use it like a standard WebGL2RenderingContext
const buffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
# Build the project (Rust + WASM)
npm run build
# Run the extensive test suite
npm test

The project aims to create a Composite WebGL2 Development Platform built with Rust and WASM. The primary objective is to significantly improve the WebGL2 developer experience by introducing standard software engineering practices—specifically, robust debugging and streamlined resource management—into the WebGL/GLSL workflow, which is currently hindered by hairy API, lack of debugging, incomprehensible errors and opaque GPU execution.
| Key Goals | Target Block | Value Proposition |
|---|---|---|
| GPU Debugging | Block 1 (Emulator) | Enable step-through debugging, breakpoints, and variable inspection for GLSL code. |
| Unit Testing | Block 1 (Emulator) | Provide a stable, deterministic environment for automated testing of graphics logic. |
| Tech Stack | Both | Utilize Rust for safety and WASM for high-performance cross-platform execution in the browser. |
The platform follows a "Rust-first" architecture where the GPU state and shader execution are managed by a high-performance Rust core compiled to WASM.
WasmWebGL2RenderingContext) that mirrors the WebGL2 API.wasm_gl_emu) that executes shader logic and manages the framebuffer.webgl2_context.rs) that tracks all GL resources and handles lifecycle.Current Phase: Phase 1 - Core Emulator & Compiler ✅
node test/visual_demo.js

Uses a simple texture shader to render a cube into an output.png file.
docs/1-plan.md - Original project proposal and plandocs/1.1-ir-wasm.md - Naga IR → WASM architecturedocs/1.1.1-webgl2-prototype.md - Rust-owned Context designdocs/1.1.2-texture.md - Texture implementation detailsdocs/1.1.3-distill.md - Testing coverage# Run Rust tests
cargo test
# Run JS tests
npm test
# Test with a simple shader (prototype, experimental)
cargo run --bin webgl2 -- compile tests/fixtures/simple.vert --debug -o output.wasm
cargo run --bin webgl2 -- run output.wasm
MIT