Skip to content

Comments

Add Emscripten WebGPU backend in thirteen.h#8

Merged
Atrix256 merged 2 commits intoAtrix256:mainfrom
fcarucci:webgpu
Feb 14, 2026
Merged

Add Emscripten WebGPU backend in thirteen.h#8
Atrix256 merged 2 commits intoAtrix256:mainfrom
fcarucci:webgpu

Conversation

@fcarucci
Copy link
Contributor

Summary

Adds WebAssembly support to Thirteen using a WebGPU backend implemented in thirteen.h, and updates the Emscripten build flow in readme.md.

Changes

  • Added __EMSCRIPTEN__ support path in thirteen.h.
  • Implemented PlatformWeb for browser input/canvas handling:
    • keyboard + mouse mapped to existing Thirteen input state.
    • canvas resize integration with Thirteen sizing.
  • Implemented RendererWebGPU in thirteen.h:
    • creates surface from #canvas.
    • async adapter/device setup with wgpuInstanceRequestAdapter and wgpuAdapterRequestDevice.
    • uploads Thirteen RGBA pixel buffer each frame to the WebGPU surface texture.
    • handles resize reconfiguration.
  • Added Emscripten frame yield in Render() (emscripten_sleep(0) under __EMSCRIPTEN__) so browser events/promises progress with native-style sample loops.
  • Updated backend selection so Emscripten uses the new web platform/renderer.
  • Updated web build instructions in readme.md to current flags (--use-port=emdawnwebgpu, -sASYNCIFY).

Build

emcc Examples/Simple/main.cpp -std=c++17 -I. \
  --use-port=emdawnwebgpu \
  -sASYNCIFY \
  -sALLOW_MEMORY_GROWTH=1 \
  -o simple.html

@Atrix256
Copy link
Owner

Looking good! i might re-arrange things in the readme a bit after merging.

@Atrix256 Atrix256 merged commit 0edaff3 into Atrix256:main Feb 14, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants