diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7769096..c4b5ca8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -74,3 +74,33 @@ jobs: - name: Build successful run: echo "Build completed successfully for ${{ matrix.example }} on ${{ runner.os }} (${{ matrix.config }})" + + build-wasm: + name: Build ${{ matrix.example }} with Emscripten (${{ matrix.config }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + example: [Simple, Mandelbrot, Minesweeper] + config: [Debug, Release] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Emscripten + uses: mymindstorm/setup-emsdk@v14 + with: + version: latest + + - name: Build with Emscripten + run: | + emcc -std=c++17 ${{ matrix.config == 'Debug' && '-g -O0' || '-O2' }} \ + -I. \ + --use-port=emdawnwebgpu \ + -sASYNCIFY \ + Examples/${{ matrix.example }}/main.cpp \ + -o ${{ matrix.example }}.html + + - name: Build successful + run: echo "Build completed successfully for ${{ matrix.example }} with Emscripten (${{ matrix.config }})" diff --git a/readme.md b/readme.md index 6b5ff12..45fc56c 100644 --- a/readme.md +++ b/readme.md @@ -10,6 +10,7 @@ Platforms Supported: * Win32/DX12 * MacOS/Metal * Linux/X11+OpenGL +* WASM/WepGPU ## Usage @@ -50,6 +51,19 @@ How to build examples: * **Mac**: For each example: clang++ main.cpp -framework Metal -framework Cocoa -std=c++11 -DTARGET_OS_OSX * **Linux**: For each example: g++ main.cpp -o Simple +**Web**: + +for each example: +```bash +emcc main.cpp -std=c++17 -I. \ + --use-port=emdawnwebgpu \ + -sASYNCIFY \ + -sALLOW_MEMORY_GROWTH=1 \ + -o simple.html +``` + +Then run a local web server and open `simple.html` in a WebGPU-enabled browser. + ### Simple A basic example showing the fundamentals of Thirteen. [View source code](Examples/Simple/main.cpp) @@ -65,22 +79,6 @@ A classic Minesweeper game implementation. [View source code](Examples/Minesweep ![Minesweeper Example](Minesweeper.png) -## Web (WASM + WebGPU) - -Thirteen now has an `__EMSCRIPTEN__` backend that uses WebGPU in the browser. - -### Build Simple example for web - -```bash -emcc Examples/Simple/main.cpp -std=c++17 -I. \ - --use-port=emdawnwebgpu \ - -sASYNCIFY \ - -sALLOW_MEMORY_GROWTH=1 \ - -o simple.html -``` - -Then run a local web server and open `simple.html` in a WebGPU-enabled browser. - ### Notes - The web backend expects a `` in the generated page. - `SetFullscreen()` is currently a no-op on web. @@ -251,6 +249,6 @@ bool clicked = Thirteen::GetMouseButton(0) && !Thirteen::GetMouseButtonLastFrame Alan Wolfe - API, examples and Win32/DX12 implementation -Francesco Carucci - MacOS/Metal implementation +Francesco Carucci - MacOS/Metal and WASM/WebGPU implementation -Nikita Lisitsa - Linux/X11+OpenGL +Nikita Lisitsa - Linux/X11+OpenGL implementation diff --git a/thirteen.h b/thirteen.h index 9d579e7..a630ee7 100644 --- a/thirteen.h +++ b/thirteen.h @@ -8,9 +8,9 @@ It is inspired by the simplicity of the Mode 13h days where you initialized the Alan Wolfe - API, examples and Win32/DX12 implementation -Francesco Carucci - MacOS/Metal implementation +Francesco Carucci - MacOS/Metal and WASM/WebGPU implementation -Nikita Lisitsa - Linux/X11+OpenGL +Nikita Lisitsa - Linux/X11+OpenGL implementation */ #pragma once