-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Parent: #41
Goal
Implement the Canvas WebGL context (WebGLRenderingContext) so that JavaScript can use GPU-accelerated 3D graphics on <canvas> elements.
Prerequisites
- Step 5 (Canvas 2D context — reuse canvas element infrastructure)
Implementation
- Expose
WebGLRenderingContext(WebGL 1.0) in Boa JS engine - Map WebGL API calls to wgpu equivalents
- GLSL ES to WGSL shader translation via
naga(already a transitive dep of wgpu) - Shader management:
createShader,shaderSource,compileShader,createProgram,linkProgram - Buffer management:
createBuffer,bindBuffer,bufferData - Texture management:
createTexture,bindTexture,texImage2D - Framebuffer management:
createFramebuffer,bindFramebuffer,framebufferTexture2D - Draw calls:
drawArrays,drawElements - Uniforms and attributes:
getUniformLocation,uniformNf/i,vertexAttribPointer,enableVertexAttribArray - Render to same offscreen texture as 2D context
- WebGL 2.0 deferred to Phase 5+
Tests
- Shader compilation and linking tests (GLSL ES → WGSL)
- Buffer creation and data upload tests
- Texture creation and sampling tests
- Draw call output validation tests
- Context switching between 2D and WebGL on same canvas
Acceptance Criteria
- WebGL 1.0 API is functional in JS
- GLSL ES shaders translate to WGSL and compile correctly
- Basic WebGL programs (triangle, textured quad) render correctly
- WebGL canvas displays in the page using shared offscreen texture
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels