Doom in egui (WeftOS + RuVector)
The whole of Freedoom Phase 1 — all four episodes, menus, saves, SFX and per-level FM music — running in an egui/eframe WebAssembly app inside the aepod console, with WeftOS theming and a RuVector nearest-seen HUD.
Play egui ▶Click to play; full page for mouse look
How it runs
This is not a raycaster toy. It is WeftOS egui (clawft-gui-egui) compiled to WebAssembly, hosting a real Doom engine inside an egui texture — the aepod console chrome and a RuVector “nearest-seen” HUD are drawn by the same egui frame, in the browser.
The runtime is a single-threaded wasm32 module (no std::thread). Game logic ticks at 35 Hz; the display can run at whatever the browser paints. The software renderer writes a 640×400 framebuffer in 0xAARRGGBB, uploaded each frame as an egui ColorImage with nearest-neighbour filtering. The canvas itself is driven by eframe + glow (WebGL), not wgpu.
After the click, the status strip in the console reports live FPS, TIC (the 35 Hz game tic), and, in the browser, MEM (the wasm linear memory size). Music and sound effects share one vector-synth Engine: a Rust FM synth (OscFm voices) plays each map’s MUS lump, and the original DMX clips are dropped onto the same bus and clock, then limited. The mixed stereo is pumped from the eframe tick into a short ring and played by a Web Audio ScriptProcessorNode (1024-frame buffers at the AudioContext sample rate, typically 44.1 or 48 kHz) that only copies, so a busy frame cannot punch a hole of silence.
Saves work on the full-page console via localStorage. The homepage live slot is intentionally sandboxed (allow-scripts plus allow-pointer-lock, no same-origin), so it can request mouse capture but cannot store saves.
Controls
Click the game, then Esc / Enter to start a New Game; the mouse locks once you're in a level. For mouse look, open Full page — the live slot is a short window; pointer lock is most reliable there. Press ? in-game, or the ? in the title bar, for the same list.
| Action | Keys / mouse |
|---|---|
| Move | W A S D or arrow keys |
| Look | Mouse (click the game to capture the pointer) |
| Fire | Left click or Ctrl |
| Use / open | Right click, E, or Space |
| Run | Shift |
| Weapons | 1–7 or mouse wheel |
| Automap | Tab (+/- zoom, F follow) |
| Menu | Esc (Esc also releases mouse capture) |
| Fullscreen | F or the title-bar button (full page only) |
| Help | ? or the title-bar ? |
While the console is focused, the page will not scroll and the usual reserved keys stay with the game. This is the whole of Freedoom Phase 1 — menus, episodes, sound, and music — running inside WeftOS egui in the browser.
Architecture
The wasm module is a stack: a reusable aepod console, a Freedoom cartridge, WeftOS egui, and a vendored Doom engine. The Mermaid source for the figure lives with the project as architecture.mmd.
Crates
| Crate | Origin | License | Role |
|---|---|---|---|
aepod-egui-doom (app) |
Our new code | — | Wasm and native entry, boot shell, WAD fetch |
aepod_console |
Our new code | — | Reusable console: bezel, theme, pointer lock, fullscreen, Web Audio pull |
doom_cart |
Our new code | — | Freedoom cartridge: engine host, display, input, HUD, automap, saves |
hello_cart |
Our new code | — | Second cartridge, showing the console is reusable |
fm_music |
Our new code | — | MUS/SMF to FM voices through vector-synth-core |
doom_sfx |
Our new code | — | DMX clips dropped onto the vector-synth Engine |
ruvector_hud |
Our new code | — | Nearest-seen recall over ruvector-core |
room4doom (wad, gamestate, gameplay, game-config, gamestate-traits, input, level, math, doom-ui, ui-draw, render-backend, render-common, software25d, pic-data, rbsp, sound-common) |
Vendored at 5a07fcb |
MIT | Game logic, software renderer, WAD, menus |
clawft-gui-egui |
WeftOS (git dependency, rev fbdcbc1) |
MIT OR Apache-2.0 | Theme and widgets |
egui / eframe 0.34 |
Third-party | MIT OR Apache-2.0 | Immediate-mode UI; glow WebGL canvas |
ruvector-core 2.5.2 |
RuVector (memory-only) |
MIT | In-memory nearest-neighbour index |
vector-synth-core |
Private path dependency | — | FM operators (OscFm), sample drops, and limiter used by music and SFX |
flate2 |
Third-party | MIT OR Apache-2.0 | Inflate freedoom1.wad.gz in wasm (rust_backend) |
Our own crates are not published with a license file, so this table does not assign one. vector-synth-core is private; only its role in this demo is described here.
What we coded
Line counts below are from the current tree: code is non-blank, non-comment source; total also includes comments and blanks. Front-end files for the app (boot.js, HTML, CSS) and the build/test scripts are included. Vendored engine code is listed separately.
| Path | Code | Total | Notes |
|---|---|---|---|
app |
304 | 317 | Wasm entry, boot, play page |
aepod_console |
1,322 | 1,432 | Includes pointer lock, fullscreen, Web Audio, theme |
doom_cart |
2,231 | 2,494 | Includes 376 code lines in tests/freedoom.rs |
hello_cart |
63 | 71 | Minimal second cartridge |
fm_music |
964 | 1,047 | Includes playback tests |
doom_sfx |
407 | 457 | Includes mixer tests |
ruvector_hud |
271 | 299 | Includes recall tests |
scripts |
552 | 613 | wasm build, Chromium headless and input tests |
| Our total | 6,114 | 6,730 | |
Vendored room4doom |
161,499 | 185,916 | 440 Rust files at 5a07fcb, plus the patches below |
Vendor patches to room4doom, all made so the engine can run as a wasm cartridge (software25d + display-memory). The native executable and OPL backend stay outside this graph.
- Load an IWAD from memory (
WadData::from_bytes). - Make the sound thread optional and avoid a blocking sleep in the cartridge.
- Route save and load through a byte-oriented
SaveStoreso the browser can use the existing menu and save format; native builds still write through the OS. - Expose the current music lump, recognize SMF and MUS headers, and prefer Freedoom’s episode-four map-named tracks when present.
- Recognize the
FREEDOOMIWAD marker and report Freedoom’s own name. - Expose the level’s start tic so the automap can reset on a new or reloaded map.
- Expose whether the menu is active or a save description is being edited.
- Restore the
WeaponType::NoChangesentinel when reading a pending weapon from a save. - Skip the OS BSP cache directory on wasm, and use
web_time::Instantfor timings and screen wipes (std::time::Instant::now()panics in the browser). - Map
pic-datawork sequentially on wasm (no standard-library thread spawn). - Keep BSP-tool CLI dependencies native-only; select flate2’s
rust_backendexplicitly. - Add a
display-memorysoftware presenter so the cartridge can borrow the composited 640×400 frame, including the HUD.
How it was built
Nine milestones, implemented with Codex (gpt-6.2-sol) on the workspace. Three crates began as bounded Codex (gpt-6.2-astra) jobs — fm_music, doom_sfx, and ruvector_hud — and were then folded into the workspace.
- M1 Workspace, wasm vendor patches, in-memory WAD load, and a native headless tick test on Freedoom Phase 1.
- M2
display-memorybackend;doom_cartuploads frames as an egui texture. - M3
aepod_console: WeftOS theme, Tiny5, weave bezel, title bar, status strip, focus overlay, and input mapping. - M4 wasm build script,
index.html/play.html; the game runs in the browser (still silent). - M5 Web Audio output and DMX SFX through the vector-synth engine (
doom_sfx). - M6 Per-level music: MUS/SMF to GENMIDI-mapped FM voices (
fm_music). - M7 RuVector nearest-seen HUD (
ruvector_hud). - M8
localStoragesaves, fullscreen,hello_cart, README, credits, headless browser test, and screenshot. - M9 Freedoom identification, automap, and a 36-map sweep that checks music on every level.
Tests and numbers, taken from the milestone logs:
- Bounded
fm_musicjob: 8 tests. A native release build rendered 10 seconds ofD_E1M1in 0.0928 s (107.73× real-time), RMS 0.316191 at 48 kHz. - Bounded
doom_sfxjob: 7 tests. Pistol RMS 0.164084 over 0.5 s at 48 kHz. - Bounded
ruvector_hudjob: 4 tests. A path-revisit query ranked the original moment first with similarity greater than 0.99. - After those crates were integrated (M5–M8), the workspace passed 22 integration tests. A five-second E1M1 stereo pull had RMS 0.206831 at 48 kHz. Docker Chromium headless tests started a new game, checked moving and firing, fullscreen, poster-delayed wasm and WAD fetches, and a full-page save restore.
- M9: 26 workspace tests. The all-map sweep (E1M1–E4M9) took 11.12 s with a warm BSP cache (21.50 s on the first run, which filled missing cache entries). The slowest map was E2M9 at 622 ms, including warp and audio pulls.
Browser coverage is Docker Chromium, including a later Playwright run that uses real mouse.click and keyboard.press and requires E1M1 (not merely advancing title-demo tics).
Credits and licenses
- Freedoom Phase 1 v0.13.0 by the Freedoom project, BSD-3-Clause. Freedoom
- room4doom by Luke Jones, MIT, based on upstream commit
5a07fcb. Engine source - egui and eframe by Emil Ernerfeldt and contributors, MIT OR Apache-2.0. Source
- WeftOS clawft-gui-egui by the clawft contributors, MIT OR Apache-2.0. The console uses its theme and widgets. Source
- RuVector Core 2.5.2 by the RuVector team, MIT. Source
- vector-synth audio engine by Mathew Beane, used here as a private path dependency for FM voices, sample drops, and the limiter.
- Tiny5 by the Tiny5 Project Authors, SIL Open Font License 1.1. Source
Doom is a trademark of id Software and ZeniMax. This demo uses Freedoom and is unaffiliated with them.
The browser bundle includes a generated dependency license list.