1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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_;
};
|