Skip to content

Add WebGPU triangle sample for wasm_c#980

Merged
cx20 merged 1 commit into
masterfrom
feature/add-wasm-c-webgpu-triangle
Jun 28, 2026
Merged

Add WebGPU triangle sample for wasm_c#980
cx20 merged 1 commit into
masterfrom
feature/add-wasm-c-webgpu-triangle

Conversation

@cx20

@cx20 cx20 commented Jun 28, 2026

Copy link
Copy Markdown
Owner

Summary

Add a C (Emscripten) WebGPU "hello triangle" sample under web/wasm_c/webgpu/triangle, mirroring the existing wasm_cpp sample but written in plain C. This fills the previously empty wasm_c cell in the WebGPU row of the README matrix.

Details

  • Built with Dawn's --use-port=emdawnwebgpu, using the up-to-date webgpu.h C API:
    • Surface-based rendering (wgpuSurfaceConfigure / wgpuSurfaceGetCurrentTexture).
    • WGPUStringView, WGPUEmscriptenSurfaceSourceCanvasHTMLSelector, WGPUShaderSourceWGSL.
    • Asynchronous wgpuInstanceRequestAdapter / wgpuAdapterRequestDevice device acquisition.
  • Renders the same per-vertex coloured triangle on a white background and follows the browser window size.
  • Single-file hello.c with a hand-written index.html, consistent with the other wasm_c samples (standard runtime, -o index.js).
  • README.md: added a wasm_c link to the WebGPU row.

Build

Compiles cleanly (no warnings) with Emscripten 6.0.1.

Notes

  • In-browser rendering was not verified in this environment; the implementation mirrors the verified wasm_cpp sample. Please confirm via the Live Demo after deploy.

🤖 Generated with Claude Code

Add a C (Emscripten) WebGPU "hello triangle" sample under
web/wasm_c/webgpu/triangle, mirroring the existing wasm_cpp sample but
written in plain C.

- Uses Dawn's `--use-port=emdawnwebgpu`, the up-to-date webgpu.h C API
  (surface-based rendering, WGPUStringView, async adapter/device request).
- Draws the same per-vertex coloured triangle on a white background and
  follows the browser window size.
- README.md: add a wasm_c link to the WebGPU row.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cx20 cx20 merged commit 34bb683 into master Jun 28, 2026
@cx20 cx20 deleted the feature/add-wasm-c-webgpu-triangle branch June 28, 2026 22:27
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.

1 participant