@builder/web/graphics will give you WebGL2 rendering for games, simulations and 3D applications. It keeps WebGL's model of shaders, buffers, textures and draw calls, with Moth types in place of JavaScript overloads and numeric constants.
The package is registered but doesn't expose any functions yet. Its first API waits for binding features that let it accept a @builder/web/canvas canvas and upload vertex and pixel data cleanly.
Use @builder/web/canvas for 2D drawing today.
For the package scope, the planned areas and what the first API needs, see @builder/web/graphics advanced.
@builder/web/graphics is the HTML builder's WebGL2 package. It belongs to the Builder origin family with ExternalBinding backing. See Package origins and backing for origin and backing rules.
Current surface
The HTML builder registers @builder/web/graphics with no public functions, types or constants. A dependency clause naming the package resolves, and selecting any symbol from it is rejected as a missing symbol. No public API ships until its binding prerequisites are accepted and implemented. The package publishes no placeholder or temporary forms in the meantime.
Scope
The package targets WebGL2 only. WebGL1 compatibility is outside current scope.
It has two areas:
Area | Role | Status |
graphics.gl | The WebGL2 graphics interface: contexts, shaders, programs, buffers, vertex arrays, uniforms, textures, samplers, framebuffers, renderbuffers, drawing and render state. | Initial implementation area |
graphics.frame | Browser animation-frame scheduling that drives rendering at the browser's frame cadence. | Accepted scope, waiting for an accepted host-to-Moth execution mechanism |
The package stays close to WebGL2. Programs keep explicit control of GPU resource lifetime, shader compilation, program linking, buffer upload, render state, draw calls and framebuffer use. It isn't a scene graph or game engine. Higher-level graphics libraries build on it without requiring changes to it.
Relationship to @builder/web/canvas
@builder/web/canvas owns canvas discovery, creation, sizing and Canvas 2D rendering. @builder/web/graphics owns WebGL2 rendering, and WebGL isn't part of @builder/web/canvas.
Context creation will take the canvas handle owned by @builder/web/canvas rather than a second canvas type. The package will also support projects that author their own canvas HTML without depending on @builder/web/canvas.
Prerequisites for the first API
The current annotated JavaScript binding profile can't yet express the final API. These capabilities come first:
- a binding package signature naming an opaque type owned by another package, so context creation can take
@builder/web/canvas's canvas handle - nested symbol paths for annotated JavaScript packages, so the API can live under
graphics.gl and graphics.frame - richer closed-domain forms beyond flat named
U32 constants - bulk numeric and byte data crossing the binding boundary for buffer upload, texture upload, uniform arrays and readback, keeping numeric
U8 distinct from Byte
The shared boundary provides exact I32, I64, U32, U64, F32 and F64 scalar slots, flat literal U32 constants and compiler-owned error code exports. Those capabilities don't supply shared opaque identities, nested names or bulk data. See External binding
contracts for their validation rules.
Frame scheduling also waits for Moth to suspend and resume work or for another accepted host-reentry design. It won't be provided through a synchronous polling function.
Backend behaviour
The package is supported only for the HTML builder's JavaScript target. See packages and builders progress matrix for current status.
Related concepts