AEPOD.IO :: Doom in egui (WeftOS + RuVector)
►
Quest // egui

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 ▶
LIVE SLOT :: FreedoomFull page

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.

How the WeftOS egui Doom wasm runtime starts and runs Page load shows a click-to-play poster. A click fetches and instantiates the wasm module, fetches and decompresses the Freedoom WAD, starts eframe on a WebGL canvas, then loops: input to 35 Hz ticcmds, a software framebuffer uploaded as an egui texture, console chrome and RuVector HUD drawn by egui, FM music and DMX sound mixed into Web Audio, and saves written to browser storage on the full page. 01 PAGE LOAD HTML poster, CSS bezel, no wasm yet 02 CLICK TO PLAY Unlocks Web Audio, hides the poster 03 FETCH + INSTANTIATE WASM app.js loads app_bg.wasm, single-threaded 04 FREEDOOM WAD Fetch freedoom1.wad.gz, then flate2 rust-backend inflate in wasm, IWAD check 05 EFRAME / EGUI START-UP WeftOS theme on the canvas glow WebGL (not wgpu), WebOptions default 06 PER-FRAME LOOP Input events → room4doom ticcmd at 35 Hz Display rate is independent of game tics Software 640×400 ARGB → egui texture NEAREST Console chrome + RuVector HUD drawn by egui 07 AUDIO vector-synth FM + DMX sample drops mix ScriptProcessor 1024 frames, stereo, context rate 08 SAVES Full page writes slots to browser storage The sandboxed live iframe has no storage

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.

Architecture of the WeftOS egui Doom wasm demo The browser JS shell loads a single-threaded wasm module. aepod_console hosts the doom and hello cartridges. WeftOS clawft-gui-egui, eframe and glow draw the canvas. doom_cart talks to the room4doom crates, fm_music and doom_sfx through vector-synth-core, ruvector_hud through ruvector-core, and browser_saves through localStorage. The WAD is inflated with flate2. 01 BROWSER JS shell play.html, boot.js Canvas Web Audio localStorage 02 WASM MODULE · aepod-egui-doom single-threaded wasm32 flate2 WAD loader inflate freedoom1.wad.gz 03 AEPOD CONSOLE + CARTRIDGES aepod_console bezel, input, audio pull doom_cart hello_cart 04 WEFTOS EGUI + EFRAME clawft-gui-egui eframe glow / WebGL 05 ROOM4DOOM · vendored @ 5a07fcb wad gamestate gameplay game-config gamestate-traits input level math doom-ui ui-draw render-backend render-common software25d pic-data rbsp sound-common 06 AUDIO fm_music MUS → FM voices doom_sfx DMX as engine drops vector-synth-core OscFm, drops, limiter 07 RUVECTOR HUD ruvector_hud nearest-seen recall ruvector-core memory-only index 08 SAVES browser_saves localStorage full page only Software 640×400 ARGB framebuffer is uploaded as an egui texture. The native executable and OPL backend sit outside this graph.

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 SaveStore so 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 FREEDOOM IWAD 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::NoChange sentinel when reading a pending weapon from a save.
  • Skip the OS BSP cache directory on wasm, and use web_time::Instant for timings and screen wipes (std::time::Instant::now() panics in the browser).
  • Map pic-data work sequentially on wasm (no standard-library thread spawn).
  • Keep BSP-tool CLI dependencies native-only; select flate2’s rust_backend explicitly.
  • Add a display-memory software 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-memory backend; doom_cart uploads 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 localStorage saves, 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_music job: 8 tests. A native release build rendered 10 seconds of D_E1M1 in 0.0928 s (107.73× real-time), RMS 0.316191 at 48 kHz.
  • Bounded doom_sfx job: 7 tests. Pistol RMS 0.164084 over 0.5 s at 48 kHz.
  • Bounded ruvector_hud job: 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.

Versions

  1. v1 /a/egui-doom/v1/