#pragma once #include #include #include #include class Camera; class Renderer { public: Renderer() = default; bool init(SDL_Window* window, int width, int height); void shutdown(); void begin_frame(Camera& camera); void end_frame(); void resize(int width, int height); // Draw a filled axis-aligned box in world coordinates. void draw_box(float cx, float cy, float half_w, float half_h, float angle, float r, float g, float b, float a); // Load a texture (cached by path). Returns nullptr on failure. SDL_Texture* load_texture(const std::string& path); // Load `primary` if set, falling back to `fallback` if it is empty or fails // to load. Used for BYO Forts art ("forts:...") that degrades to the CC0 // placeholder when the game is not installed. Returns nullptr if neither // loads. SDL_Texture* load_texture_or(const std::string& primary, const std::string& fallback); // Draw a textured quad in world coordinates, colour-modulated by (r,g,b,a). void draw_sprite(float cx, float cy, float half_w, float half_h, float angle, SDL_Texture* tex, float r = 1.0f, float g = 1.0f, float b = 1.0f, float a = 1.0f); // Draw a simple HUD bar in screen pixels (top-left origin). void draw_hud_bar(float x, float y, float fill, float r, float g, float b); // Draw a radial (pie) countdown at a world position. `frac` in [0,1] is the // remaining portion drawn as a filled wedge over a dim background ring. void draw_radial_timer(float cx, float cy, float radius_world, float frac, float r, float g, float b, float a); // Draw a filled wedge (world space) between world angles a0..a1 — used for // a weapon's firing arc. void draw_arc(float cx, float cy, float radius_world, float a0, float a1, float r, float g, float b, float a); int width() const { return width_; } int height() const { return height_; } SDL_Renderer* sdl_renderer() const { return sdl_renderer_; } private: SDL_Renderer* sdl_renderer_ = nullptr; Camera* current_cam_ = nullptr; int width_ = 1280; int height_ = 720; bool imgui_ready_ = false; std::vector fan_scratch_; // reused by draw_radial_timer std::unordered_map tex_cache_; };