Font 8bithud, classe Text i overlay RenderInfo (F3, persistit a config.yaml) (v0.7.0)

This commit is contained in:
JailDesigner committed 2026-04-19 00:31:02 +02:00
1 parent ce5bec1b34
commit e6f3c888e6
19 files changed
+712 -6

No files matched your search

+24
View File
@@ -62,6 +62,10 @@ class Screen {
[[nodiscard]] auto getCanvasWidth() const -> int { return canvas_width_; }
[[nodiscard]] auto getCanvasHeight() const -> int { return canvas_height_; }
// Mètriques per a overlays de debug (RenderInfo).
[[nodiscard]] auto getLastFPS() const -> int { return fps_.last_value; }
[[nodiscard]] auto getGPUDriver() const -> const std::string& { return gpu_driver_; }
private:
Screen() = default;
~Screen() = default;
@@ -69,6 +73,23 @@ class Screen {
void destroySdl();
void createSdl();
// Comptador intern de frames per segon. S'incrementa a cada present() i
// es recalcula quan ha passat un segon complet (SDL_GetTicks en ms).
struct FPS {
std::uint32_t ticks{0};
int frame_count{0};
int last_value{0};
void increment() { ++frame_count; }
void calculate(std::uint32_t current_ticks) {
if (current_ticks - ticks >= 1000) {
last_value = frame_count;
frame_count = 0;
ticks = current_ticks;
}
}
};
bool subsystem_initialized_{false};
Config config_{};
@@ -83,4 +104,7 @@ class Screen {
int canvas_width_{0};
int canvas_height_{0};
std::vector<std::uint32_t> canvas_;
FPS fps_{};
std::string gpu_driver_;
};