Repository navigation
Architecture
Fanalor is a Cargo workspace. The root Cargo.toml is a virtual manifest: it has no src/, and it owns every third-party version in [workspace.dependencies]. Member crates write dep.workspace = true and never pin a version of their own. The long form, including the decisions behind each subsystem, is docs/ARCHITECTURE.md.
- One responsibility per crate. A subsystem that can be described without another subsystem is its own crate.
-
Dependencies point one way. Lower layers do not know about higher ones.
fanalor-renderdoes not know what a window or an entity is. -
Use the abstraction wgpu already has.
fanalor-rendertakes awgpu::SurfaceTarget, not awinitwindow. That is what keeps the renderer testable without a window. - Add a crate when there is code for it. Empty scaffolding is not created ahead of the code.
One crate may depend on winit (fanalor-core), one on wgpu (fanalor-render), one on cpal and symphonia (fanalor-audio), and one on tungstenite (fanalor-net). Everything else uses those crates' re-exports, so a version bump is one line in the root manifest.
The engine is 2D. Transform is a Vec2 plus a Mat3. Camera2D is orthographic. Draw order (sorting layers, then painter's order) decides what covers what. There is no depth buffer. Mat4 appears where a shader uniform wants a 4×4 matrix; it is not a third dimension. 3D, when it exists, will be its own design.
fanalor-editor fanalor-player fanalor-server
\ | /
\ | /
+----------- fanalor-core --------------+
event loop, window, input
(owns winit)
|
fanalor-scene
components and geometry
/ \
fanalor-ecs fanalor-assets
no dependencies handles, caches
/ | \
fanalor-render fanalor-audio (textures, clips)
owns wgpu owns cpal, symphonia
fanalor-scene is the crate that knows both entities and vertices. That is what lets fanalor-ecs stay free of rendering and fanalor-render stay free of entities. The picture leaves out edges that would bury that point: fanalor-scene also reaches fanalor-render for Vertex and Mesh, and both fanalor-core and fanalor-editor own a Textures cache directly.
fanalor-assets caches GPU textures and decoded audio clips, so it depends on fanalor-render and fanalor-audio. It does not depend on wgpu itself; it uses fanalor_render::wgpu.
| Crate | Owns |
|---|---|
fanalor-ecs |
Generational entity handles and one sparse set per component. No dependencies |
fanalor-jobs |
A worker pool and scoped jobs that borrow from their caller. The standard library only |
fanalor-profile |
Named scopes and counters, recorded per thread, summarised as a tree |
fanalor-assets |
Asset identity, paths, and the texture, atlas, and clip caches. FANALOR_ASSET_ROOT
|
fanalor-render |
Device, swapchain, passes, render targets, the egui backend. Owns wgpu
|
fanalor-audio |
Mixer, buses, effects, decoding, the output device. Owns cpal and symphonia
|
fanalor-scene |
Scene components and the geometry they become: transforms, sprites, physics components, names, parents, scenes on disk |
fanalor-physics |
Integration, contacts, the solver, queries, and pose history for lag compensation |
fanalor-nav |
Navigation grids baked from colliders, and A* paths |
fanalor-net |
Datagram transports (UDP, WebSocket, in-memory) and connections. Owns tungstenite
|
fanalor-replication |
Snapshots and deltas, interpolation, prediction, interest, lag compensation |
fanalor-bridge |
JSON-line commands to a running editor over a loopback socket |
fanalor-mcp |
The MCP server binary: scenes, assets, headless runs, and the live editor |
fanalor-core |
The event loop, window, input, time, UI seam, and the game's network session. Owns winit
|
fanalor-editor |
The editor binary and its panels |
fanalor-player |
Runs a scene, or the build beside it, with no editor |
fanalor-server |
A scene headless at a fixed tick, hosted over UDP and WebSocket. Games link it for their own server binary |
fanalor-bench |
Benchmarks of the hot paths, and the regression compare |
fanalor-testkit |
Headless GPU scaffolding for tests. publish = false, dev-dependency only |
xtask |
cargo xtask: dist, new-game, pack-atlas, bench, guide
|
games/platformer, games/breakout, games/dodge, and games/arena are workspace members too. They are games, not engine crates. arena also builds arena-server.
The editor UI is egui. The official egui-wgpu backend is pinned to an older wgpu than this workspace, so the backend is fanalor-render::egui_backend. fanalor-render depends on epaint (triangles), and fanalor-core depends on egui and egui-winit (widgets).
winit event loop (fanalor-core::App)
Resumed create the window, the renderer, the egui layer, the render target
Resized Renderer::resize reconfigures the surface
RedrawRequested
App::update the game tick, then each physics step owed,
each one preceded by the game's fixed tick
sprite batch world to vertices to a mesh
render into the target the viewport, not always the window
egui layout, then the editor's panels
present acquire, clear, draw, present, request another frame
Acquiring the surface returns Option on purpose. A lost or outdated surface reconfigures and skips the frame. Timeout and occlusion skip quietly. A minimised window does not spin a redraw.
The editor's viewport size is applied one frame later. A panel only learns its rectangle while egui is laying out, and the scene has to be drawn before egui can sample it.
A shipped game with no UI callback draws the world straight to the window.
Scenes, prefabs, input maps, themes, animation clips, and build manifests are RON. A game's components appear in those files because register named them. Prefab instances keep overrides against their file. Saving, additive loads, and Persistent entities are part of fanalor-scene / fanalor-core, described from the user's side in the guide's scene and big-world chapters.
| Topic | Page |
|---|---|
| What the GPU actually draws | Rendering |
| How a frame sees keys and pads | Input |
| Multiplayer | Networking |
| Packaging | Export |
| Naming, commits, module shape | Contribution Guide and docs/CONVENTIONS.md |