gg, week 5: shapes, sound and a UI
An engine that makes noise and draws a menu, a mixer that never touches the frame loop, and what a month of this actually produced.
Four weeks in, the renderer is finished enough to leave alone for a bit. This week was the two subsystems a player notices before any of that stuff: the engine made no sound at all, and it couldn't draw a menu. Both are in now, along with two smaller things that had to come first.
Shapes with nothing behind them
The engine builds nine basic shapes in-process now, from a handful of numbers on the entity. There's no source file behind any of them and nothing in the cooker. The scene stores the recipe (the file says "a torus with a tube ratio of 0.3 and 24 segments"), and every shape is unit-sized, so the entity's transform is the size.

All of it collides, picks, undoes and saves like anything else, because a primitive is a component and the registration layer does the rest.
They exist because blocking out a level with imported meshes is silly, and because the first playable is going to be a greybox. The one wrinkle was identity. With no file to mint a uuid against, a generated shape derives one from the parameters that built it, and two entities asking for the same torus get the same mesh.
More than one game
Each game gets a folder under source/games/ with its sources and a content declaration, and GG_GAME picks which one a build compiles. That declaration is how the asset pipeline finally knows what ships. Everything cooks and the editor can place any of it, but only what a game actually reaches should go in the pack: the scenes it walks, plus whatever it looks up by name. Fonts are the worked example, since no scene references one, and you'd otherwise ship a pack full of text with no face to draw it in.
Over-stripping is the failure nothing else can see. A dangling reference is loud, but an asset that was needed and never reached is silent until a player finds it. So the pack writer prints where every cooked file went, and a test loads each root scene with nothing mounted but the pack.
Audio, from nothing
There was literally none: no dependency, no decoder, and SDL_Init wasn't even asking for the audio subsystem.
SDL owns the device and runs the thread that asks for more. Everything above that is engine code, because the event, bus, snapshot and scheduling layer was going to be mine whichever library sat underneath. The mix runs on that device thread and touches no engine state at all. The frame thread posts commands through a lock-free ring, the mixer reports back through another, and nothing on the device thread allocates, locks, logs or reads a file.
The reason for all that ceremony is week two, when the frame loop parked for seconds at a time behind an obscured window. Audio riding the frame loop would drop out on every hitch and stop entirely when the window was covered, which is not a thing I'm willing to ship.

The mixer panel: buses, peaks, how many voices are sounding, and how long the last block took.
Above the mixer there are three layers, each of which exists because otherwise the one below it would end up being authored in C++. A wave is a recording, with its loudness measured when it cooks. A sound document is a hand-written TOML file naming one or more waves and the rules for playing them. It levels every wave to one loudness target, so a set gathered from four sources at four levels plays at one. A random set never picks the one it just played, or there'd be no point authoring four footsteps. The same document says how the sound behaves once it's placed in the world, and an audio_source component plays it from wherever its entity is.
One thing I haven't decided is what a footstep should key off. A contact already reports the terrain layer it's standing on, and the sfx pack files its footsteps by surface. The two sets don't line up, though: mud and wood chip map straight across, while forest floor and leaf litter have nothing. The layer name is probably the right key, and I don't know yet whether the mapping from it belongs on the layer or beside it. Later.
Music is streamed. It cooks to Opus packets decoded on the device thread, and the demo's music goes from about 1.5 MB to under 100 KB. The mix is a file too, because what a bus gives way to is the game's decision. The demo's music ducks under sfx by half, and its pause menu moves the whole mix into a menu snapshot.
A user interface
The flat UI layer is one call a frame. A game describes its whole interface as a flat array of nodes and gets one result per node back, and the engine lays it out, animates it and draws it in one pipeline after the tonemap.

Nine widget kinds, a theme, and the type ladder they draw with.
Text is cooked too. A font goes to one atlas of multi-channel signed distance fields with every metric in ems, so one cooked font serves every size on screen. Kerning is read out of GPOS by shaping each pair, since that's where a modern face typically keeps it. Inter carries no legacy kern table at all, so the path FreeType takes finds nothing in it.
A distance field is the one cooked thing whose defects are all invisible in its numbers. A flip, a transpose, or a neighbour bleeding into a glyph makes a perfectly plausible field that's obvious the moment you look at a specimen sheet. So the cook writes one, and I look at it.

The demo's pause menu. The blur is the existing bloom chain with its prefilter open, so the cost was one knob.
The theme is a file beside the game's content declaration, because a look belongs to the game. It's applied whole or not at all, so a theme that won't parse leaves the interface on screen as it was.
The tick's input struct crossed the C ABI waist this week too. A game module now receives the inputs its tick was fed, and the demo walks a character with them. That's the first bit of phase 8 arriving early.
Taking stock

Where it ended up. This is the same golden test case as week one's checkerboard room, four weeks on.
Five weeks in, what's there is a fixed-step loop with hot reload, a cooked asset pipeline, an editor with auditable undo and a command socket, Jolt physics over sculptable terrain, a clustered forward renderer under a physically lit sky, a mixer, and a flat UI layer with cooked type.
What isn't there is the game. The C ABI waist is still thin, the editor can't author a camera, a spline or a prefab, and there's no streaming, because so far there's only one region.
If I had to pick two things to tell anyone starting something like this:
Build the iteration loop first. Weeks one and two were mostly infrastructure with nothing to photograph, and every week after them was faster for it. The two decisions that paid off the most were fixed timestep plus an offscreen synthetic-time mode, which is what made committed golden images possible at all, and the command socket, which turned "can I test this?" from an afternoon's work into a script.
Instruments before features, every time. Nearly every entry in these five posts that looks like a debugging story is really a story about a missing instrument. The occluded-window hang needed a diagnostic that reported which GPU call blocked, the overdraw finding needed the overdraw view before the sort it was meant to judge, and the moon's phase needed a verb reporting an illuminated fraction, because an image can't be its own oracle. The engine has 59 debug views now, and every one of them exists because something was invisible once.
Next is phase 7 and phase 8: springs and animation blending, and then an actual traversal slice with a greybox forest edge, four waystones and a glide. Which means the next of these posts might finally be about a game.
Credits
Everything in these shots that isn't engine is bought or borrowed:
- The buildings, props, trees, foliage and rocks are Quaternius kits: the Medieval Village and Stylized Nature MegaKits, bought as the paid source versions, plus the free Ultimate Stylized Nature set. All of it is released CC0, and he takes Patreon support.
- The ground materials are Poly Haven textures, CC0.
- The sound effects are Imphenzia's Universal Sound FX, under a purchased licence. That licence covers the sounds inside a game and not passing them on as sounds, which is why the pack I build from them is private.
- The type is Inter by Rasmus Andersson, under the SIL Open Font License.