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>
33 lines
960 B
C++
33 lines
960 B
C++
//
|
|
// Created by darman on 9/24/26.
|
|
//
|
|
|
|
#include "SdlContext.h"
|
|
|
|
#include <SDL3/SDL.h>
|
|
#include <spdlog/spdlog.h>
|
|
|
|
namespace SiegeDeck::Engine
|
|
{
|
|
|
|
SdlContext::SdlContext(const string& appName, const string& appVersion)
|
|
{
|
|
// Must precede SDL_Init: some platforms read it during init (audio stream names, Wayland app id).
|
|
SDL_SetAppMetadata(appName.c_str(), appVersion.c_str(), nullptr);
|
|
|
|
// If this throws, the destructor doesn't run, and SDL_Init has cleaned up after itself.
|
|
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMEPAD))
|
|
throw std::runtime_error(std::format("SDL_Init failed: {}", SDL_GetError()));
|
|
|
|
int version = SDL_GetVersion();
|
|
spdlog::info("SDL {}.{}.{} ({} video)", SDL_VERSIONNUM_MAJOR(version), SDL_VERSIONNUM_MINOR(version),
|
|
SDL_VERSIONNUM_MICRO(version), SDL_GetCurrentVideoDriver());
|
|
}
|
|
|
|
SdlContext::~SdlContext()
|
|
{
|
|
SDL_Quit();
|
|
}
|
|
|
|
}
|