feat: engine skeleton (Build Order step 1) and siege_tests
Engine: - SdlContext and Window: RAII, throwing constructors, non-movable - FrameClock (real time, clamped dt) and SimClock (fixed 1/60 s steps, speed 0 = planning phase, backlog capped per frame) - Application owns them in lifetime order, exposes EngineContext, and runs the fixed-timestep loop; AppConfig::FromArgs parses --frames, --seed and --fullscreen - Temporary window-surface fill so Wayland maps the window until RenderDevice lands in step 2 Build: - Split into the siege_engine static lib and the siege_deck exe - check_engine_deps fails the build if Engine/ includes Game/ - ctest smoke test: siege_deck --frames 30 on the offscreen driver - siege_tests on Catch2 v3.15.3 (nixpkgs + CPM pin), with SimClock, FrameClock and AppConfig tests Docs: - Decision Log: error handling split, Catch2 for unit tests - Build Order step 1 done; Engine Overview, Main Loop and Time and README updated to match - AGENTS.md with build, conventions and gotchas for coding agents - .gitignore: .mcp.json (local CLion MCP port) and Obsidian's workspace.json (tab/pane state), now untracked Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,7 +6,7 @@ tags:
|
||||
|
||||
# Build Order
|
||||
|
||||
- [ ] **1. Skeleton:** split CMake into `siege_engine` and `siege_deck`; write `Application`, `FrameClock`, `SimClock` and the main loop. `--frames N` keeps working. See [[Main Loop and Time]].
|
||||
- [x] **1. Skeleton:** split CMake into `siege_engine` and `siege_deck`; write `Application`, `FrameClock`, `SimClock` and the main loop. `--frames N` keeps working. See [[Main Loop and Time]].
|
||||
- [ ] **2. RenderDevice:** SDL_GPU device and swapchain, the GLSL → SPIR-V build step, clear the screen, ImGui on `imgui_impl_sdlgpu3`. See [[Rendering]].
|
||||
- [ ] **3. Renderer2D:** sprite batch, text, debug overlay.
|
||||
- [ ] **4. SceneRenderer3D:** glTF loading, instanced static meshes, camera, a ground-plane picking ray to a tile.
|
||||
|
||||
@@ -30,7 +30,7 @@ flowchart TD
|
||||
```
|
||||
|
||||
> [!important] Dependency rule
|
||||
> `Engine/` must never include anything from `Game/`. The CMake target split enforces this.
|
||||
> `Engine/` must never include anything from `Game/`. Both targets share `Source/` as their include root, so the compiler can't prevent it; the `check_engine_deps` build step (`cmake/CheckEngineDeps.cmake`) fails the build instead.
|
||||
|
||||
## Source layout
|
||||
|
||||
@@ -61,7 +61,9 @@ Source/
|
||||
|---|---|---|
|
||||
| `siege_engine` | static lib | SDL3 family, glm, EnTT, ImGui, spdlog, script runtime |
|
||||
| `siege_deck` | executable | `siege_engine` + `Game/` |
|
||||
| `siege_tests` (later) | executable | engine + game logic, headless |
|
||||
| `siege_tests` | executable | engine + game logic, headless; Catch2 v3 (`Tests/`) |
|
||||
|
||||
`ctest --preset debug` runs every `siege_tests` case (each `TEST_CASE` is its own ctest entry) plus the `smoke` test: `siege_deck --frames 30` on SDL's offscreen video driver, so it needs no display.
|
||||
|
||||
## Principles
|
||||
|
||||
|
||||
@@ -17,9 +17,8 @@ while (running) {
|
||||
|
||||
scenes.Update(frameClock.Dt()); // UI, tweens, card hand, camera: real time
|
||||
|
||||
simClock.Accumulate(frameClock.Dt() * simClock.Speed());
|
||||
int steps = 0;
|
||||
while (simClock.ConsumeStep() && steps++ < kMaxStepsPerFrame) // spiral-of-death guard
|
||||
simClock.Accumulate(frameClock.Dt()); // scaled by Speed(), backlog capped at kMaxStepsPerFrame steps
|
||||
while (simClock.ConsumeStep())
|
||||
scenes.FixedUpdate(kSimDt); // 1/60 s: movement, targeting, projectiles, damage
|
||||
|
||||
renderer.BeginFrame();
|
||||
@@ -42,7 +41,7 @@ The planning phase is simply `simClock.SetSpeed(0)`. Cards still animate and hov
|
||||
|
||||
At 1×, 2× or 3× the loop runs **more fixed steps per frame, never bigger ones**. A 3× frame runs three 1/60 s steps, not one 1/20 s step, so fast projectiles can't skip past enemies at high speed.
|
||||
|
||||
`kMaxStepsPerFrame` caps the catch-up work after a stall (window drag, breakpoint). The simulation slows down rather than freezing the frame.
|
||||
`kMaxStepsPerFrame` caps the catch-up work after a stall (window drag, breakpoint). `SimClock::Accumulate` clamps the backlog to that many steps and drops the rest, so the simulation slows down rather than freezing the frame, and the lost time never piles up across frames.
|
||||
|
||||
## Interpolation
|
||||
|
||||
|
||||
Reference in New Issue
Block a user