Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }})"
34 changes: 16 additions & 18 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Platforms Supported:
* Win32/DX12
* MacOS/Metal
* Linux/X11+OpenGL
* WASM/WepGPU

## Usage

Expand Down Expand Up @@ -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)

Expand All @@ -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 `<canvas id="canvas"></canvas>` in the generated page.
- `SetFullscreen()` is currently a no-op on web.
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions thirteen.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down