aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine/renderer.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/renderer.hpp')
-rw-r--r--src/engine/renderer.hpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/engine/renderer.hpp b/src/engine/renderer.hpp
new file mode 100644
index 0000000..ddc8055
--- /dev/null
+++ b/src/engine/renderer.hpp
@@ -0,0 +1,60 @@
+#pragma once
+
+#include <SDL3/SDL.h>
+#include <vector>
+#include <string>
+#include <unordered_map>
+
+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);
+
+ // 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<SDL_Vertex> fan_scratch_; // reused by draw_radial_timer
+ std::unordered_map<std::string, SDL_Texture*> tex_cache_;
+};