Files
Seele/docs/subsystems/game-interface.md
T
coding-agent 1324d903cb docs: add per-subsystem deep-dives + cross-repo orientation (for coding agents)
Adds docs/ — a navigation layer on top of AGENTS.md for future coding
agents working on the Seele engine and the MeshShadingDemo harness.

- docs/README.md: index + 30-second orientation + how-to-use workflow.
- docs/cross-repo.md: the engine<->demo contract (2-symbol ABI, the
  ComponentSystem<...> demo pattern with the FlyCamSystem example, the
  CMake in-tree vs install(EXPORT) split, a where-to-look task map).
- docs/subsystems/*.md: 16 per-subsystem deep-dives (scene/ECS, systems,
  game-interface, window, graphics backends, render graph, materials,
  physics, UI, assets, platform, core utils). Each maps public types to
  their defining headers and gives file:line pointers + gotchas.

All cross-links verified resolving. This is documentation only — no source
changes.
2026-11-07 22:08:50 +00:00

7.1 KiB

Game Interface & Frame Loop (GameView / GameInterface)

How the engine hosts a game DLL: the GameInterface contract, the GameView frame loop, window/graphics setup, and the reload path.

This is a navigation doc: it tells you where things live, how data actually flows, and the sharp edges — so you can orient in minutes instead of hours. It complements the repository's AGENTS.md (map + rules) and the cross-repo guide (engine ↔ demo contract). Everything below is grounded in the checked-out source at commit d3ed573.

Key types & where they live

Type Defined in
GameInterface src/Engine/Platform/Linux/GameInterface.h
GameView src/Engine/Window/GameView.h
Game src/Engine/Game.h
GameInterface (abstract) git grep in src/
Game (abstract game base) git grep in src/

Paths above are resolved against the actual source tree (namespace ≈ directory in this codebase). A (search) marker means the file contains the name but may also define others — open it and grep. git grep is always a fallback. The full per-file map is in Where to look below.

Data flow / lifecycle

GameInterface (src/Engine/Interface/GameInterface.h + .cpp, 1.3KB header + 1.2KB impl) is the abstract contract between the engine and the game. It defines the virtual methods that a game DLL must implement: setupScene(PScene, PSystemGraph) (called once when the game is loaded — the game populates the scene with entities/components and may add custom systems to the system graph), updateScene() (called every frame before the built-in systems run — the game can do custom per-frame work), and potentially other hooks (check the full header). Game (src/Engine/Interface/Game.h, 634B) is the abstract game base class (DEFINE_REF(Game) -> PGame) — it is the type that the game DLL exports. GameView (src/Engine/Window/GameView.h + .cpp, 1.7KB header + 5.4KB impl) is the ENGINE-SIDE host that: (1) creates the Gfx::Graphics backend (Vulkan::Graphics or Metal::Graphics — the selection is done by the embedding app, NOT by GameView; GameView receives a PGraphics), (2) creates a Scene, (3) loads the game DLL (via a dynamic library loader — check GameView.cpp for the dlopen/LoadLibrary call), (4) calls game->setupScene(scene, systemGraph) to let the game populate the scene, (5) runs the frame loop: GameView::update() (compute deltaTime, reset VertexData, run systemGraph->run(dt), scene->update(dt), re-create VertexData descriptors, lightEnv->commit()) and GameView::render() (find main camera, call renderGraph.render(cam, transform), call rayTracingGraph.render(cam, transform) if RT enabled). The main entry point is src/Main.cpp (9.4KB) — it parses command-line arguments (window size, graphics backend, project path), creates the Graphics backend, creates a GameView, creates the GameInterface (loads the game DLL), and enters the main loop. The game DLL is a separate compilation unit that links against the engine's exported symbols (the engine exports a C or C++ ABI for the game to link against). The game DLL exports a factory function (check the Interface/ headers for the exact export name) that returns a PGame.

Where to look

Path What's there
src/Engine/Interface/GameInterface.h + .cpp game<->engine contract
src/Engine/Interface/Game.h abstract game base
src/Engine/Window/GameView.h + .cpp engine-side host: frame loop, game loading, render wiring
src/Main.cpp main entry point, 9.4KB — backend selection, GameView creation, main loop

Gotchas & sharp edges

  • The graphics backend is NOT selected by GameView or the game DLL — it is selected by the EMBEDDING APP (Main.cpp or a custom launcher). Main.cpp parses a command-line argument to choose between Vulkan and Metal. If you want to change the backend, you modify Main.cpp (or write your own launcher that constructs the appropriate backend and passes it to GameView).
  • The game DLL is loaded at RUNTIME via dlopen (Linux) or LoadLibrary (Windows). The DLL path is either a command-line argument or a hardcoded path (check Main.cpp / GameView.cpp). If the DLL is missing, the engine will fail at startup with a clear error message. If the DLL exports the wrong symbol name, the dlsym/GetProcAddress will fail — check the exact export name in the Interface/ headers.
  • GameView::render() finds the main camera by iterating ALL Camera+Transform entities and checking the mainCamera boolean. If the game forgets to set mainCamera=true on its camera, the render will use a default-constructed (identity) camera and you will see a broken view with no error message. This is a common game-side bug.
  • The system graph is REBUILT on every reloadGame() call — the game's setupScene is called again. If the game's setupScene is not idempotent (e.g. it adds duplicate entities), the scene will accumulate duplicates on reload. The game must clean up its entities before re-populating (or the engine must clear the scene before calling setupScene — check GameView.cpp reloadGame() for whether it clears the scene first).
  • GameView::update() calls VertexData::getList() to iterate ALL registered VertexData instances and reset their mesh data. This is a GLOBAL side-channel — if you create a VertexData outside the ECS (e.g. in a system that doesn't own it), it will still be in the global list and will be reset every frame. If you need per-vertex-data update logic, hook into the VertexData's own update callback (check VertexData.h for a callback mechanism).
  • The main loop in Main.cpp is a standard while(running) { update(); render(); } loop. There is no vsync control in the engine — the vsync is controlled by the window system (Vulkan::Window or Metal::Window). If you see frame rate issues, check the swapchain configuration in the backend's Window implementation.
  • GameInterface is the CONTRACT, not the implementation. The engine does NOT contain a default game — it is a pure interface. The game DLL provides all game logic. If you are building a new game, you must implement the GameInterface contract in a separate DLL.
  • The scene is created by GameView (not by the game). The game receives the scene as a parameter to setupScene() and populates it. The game CANNOT create a new scene — it must use the one provided by the engine. If the game tries to create its own Scene, it will have a different entt::registry and the engine's render pipeline will not see the game's entities.
  • The frame timing (updateTime) is computed in GameView::update() using std::chrono. It is the ACTUAL wall-clock delta between frames, not a fixed timestep. If the frame takes longer than expected (e.g. due to Slang compilation), updateTime will be large and the simulation will take a large step. There is no clamping of deltaTime in the engine — the game is responsible for clamping if it wants stable simulation (check the game's system implementations).

Generated from a full read of the checked-out source at commit d3ed573. If a path has moved, git grep for the type name — the engine is small enough to find anything in seconds.