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:
@@ -0,0 +1,59 @@
|
||||
//
|
||||
// Created by darman on 9/24/26.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <SDL3/SDL_video.h>
|
||||
#include <glm/vec2.hpp>
|
||||
|
||||
namespace SiegeDeck::Engine
|
||||
{
|
||||
|
||||
class SdlContext;
|
||||
|
||||
struct WindowDesc
|
||||
{
|
||||
string Title { "Siege Deck" };
|
||||
int32 Width { 1600 }; // logical size; the backbuffer is larger on high-DPI displays
|
||||
int32 Height { 900 };
|
||||
bool Resizable { true };
|
||||
bool Fullscreen { false }; // borderless desktop fullscreen, not an exclusive mode change
|
||||
};
|
||||
|
||||
// Not movable: a Window that exists always has a live SDL_Window, and the render
|
||||
// device and ImGui backend will hold on to it by reference.
|
||||
class Window
|
||||
{
|
||||
public:
|
||||
// Takes the SdlContext only as proof that SDL is initialized.
|
||||
// Throws std::runtime_error if the window can't be created.
|
||||
Window(const SdlContext& sdl, const WindowDesc& desc);
|
||||
|
||||
Window(const Window&) = delete;
|
||||
Window& operator=(const Window&) = delete;
|
||||
Window(Window&&) = delete;
|
||||
Window& operator=(Window&&) = delete;
|
||||
|
||||
[[nodiscard]] SDL_Window* Handle() const { return handle.get(); }
|
||||
[[nodiscard]] SDL_WindowID Id() const;
|
||||
|
||||
// Logical size, for UI layout and mouse coordinates.
|
||||
[[nodiscard]] glm::ivec2 Size() const;
|
||||
// Backbuffer size, for the swapchain and viewport.
|
||||
[[nodiscard]] glm::ivec2 PixelSize() const;
|
||||
// Content scale of the current display (1.0 = 96 DPI), for sizing UI and fonts.
|
||||
[[nodiscard]] float DisplayScale() const;
|
||||
|
||||
void SetTitle(const string& title);
|
||||
|
||||
private:
|
||||
struct Destroy
|
||||
{
|
||||
void operator()(SDL_Window* window) const { SDL_DestroyWindow(window); }
|
||||
};
|
||||
|
||||
UniqueRef<SDL_Window, Destroy> handle;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user