Merge branch 'tweak/debug-hud-layout': FPS gran, RES i DRIVER al HUD de debug

This commit is contained in:
2026-05-24 14:15:05 +02:00
3 changed files with 39 additions and 4 deletions
+3 -1
View File
@@ -33,7 +33,9 @@ namespace Defaults::Hud {
namespace DebugOverlay { namespace DebugOverlay {
constexpr float X = 30.0F; constexpr float X = 30.0F;
constexpr float Y_FPS = 24.0F; constexpr float Y_FPS = 24.0F;
constexpr float LINE_HEIGHT = 18.0F; // separació entre línies (scale 0.4 → ~16 px alt) constexpr float FPS_LINE_HEIGHT = 28.0F; // separació després del FPS (scale 0.7 → ~28 px)
constexpr float LINE_HEIGHT = 18.0F; // separació entre línies (scale 0.4 → ~16 px alt)
constexpr float FPS_SCALE = 0.7F; // FPS més gran que la resta
constexpr float TEXT_SCALE = 0.4F; constexpr float TEXT_SCALE = 0.4F;
constexpr float TEXT_SPACING = 2.0F; constexpr float TEXT_SPACING = 2.0F;
constexpr float BRIGHTNESS = 1.0F; constexpr float BRIGHTNESS = 1.0F;
+35 -3
View File
@@ -2,20 +2,32 @@
#include "core/system/debug_overlay.hpp" #include "core/system/debug_overlay.hpp"
#include <SDL3/SDL.h>
#include <cctype>
#include <string> #include <string>
#include "core/defaults.hpp" #include "core/defaults.hpp"
#include "core/rendering/gpu/gpu_frame_renderer.hpp"
#include "core/types.hpp" #include "core/types.hpp"
namespace System { namespace System {
namespace { namespace {
namespace Cfg = Defaults::Hud::DebugOverlay; namespace Cfg = Defaults::Hud::DebugOverlay;
auto toUpperAscii(std::string s) -> std::string {
for (char& c : s) {
c = static_cast<char>(std::toupper(static_cast<unsigned char>(c)));
}
return s;
}
} // namespace } // namespace
DebugOverlay::DebugOverlay(Rendering::Renderer* renderer, DebugOverlay::DebugOverlay(Rendering::Renderer* renderer,
const Config::RenderingConfig& rendering_cfg) const Config::RenderingConfig& rendering_cfg)
: text_(renderer), : text_(renderer),
renderer_(renderer),
rendering_cfg_(&rendering_cfg) {} rendering_cfg_(&rendering_cfg) {}
void DebugOverlay::update(float delta_time) { void DebugOverlay::update(float delta_time) {
@@ -35,23 +47,43 @@ namespace System {
} }
const std::string FPS_TEXT = "FPS: " + std::to_string(fps_display_); const std::string FPS_TEXT = "FPS: " + std::to_string(fps_display_);
const std::string RES_TEXT = "RES: " + std::to_string(rendering_cfg_->render_width) + "X" + std::to_string(rendering_cfg_->render_height);
const char* driver_raw = SDL_GetGPUDeviceDriver(renderer_->device().get());
const std::string DRIVER_TEXT = "DRIVER: " + toUpperAscii(driver_raw != nullptr ? driver_raw : "?");
const std::string VSYNC_TEXT = std::string("VSYNC: ") + (rendering_cfg_->vsync == 1 ? "ON" : "OFF"); const std::string VSYNC_TEXT = std::string("VSYNC: ") + (rendering_cfg_->vsync == 1 ? "ON" : "OFF");
const std::string AA_TEXT = std::string("AA: ") + (rendering_cfg_->antialias == 1 ? "ON" : "OFF"); const std::string AA_TEXT = std::string("AA: ") + (rendering_cfg_->antialias == 1 ? "ON" : "OFF");
float y = Cfg::Y_FPS;
text_.render(FPS_TEXT, text_.render(FPS_TEXT,
Vec2{.x = Cfg::X, .y = Cfg::Y_FPS}, Vec2{.x = Cfg::X, .y = y},
Cfg::FPS_SCALE,
Cfg::TEXT_SPACING,
Cfg::BRIGHTNESS,
Cfg::COLOR);
y += Cfg::FPS_LINE_HEIGHT;
text_.render(RES_TEXT,
Vec2{.x = Cfg::X, .y = y},
Cfg::TEXT_SCALE, Cfg::TEXT_SCALE,
Cfg::TEXT_SPACING, Cfg::TEXT_SPACING,
Cfg::BRIGHTNESS, Cfg::BRIGHTNESS,
Cfg::COLOR); Cfg::COLOR);
y += Cfg::LINE_HEIGHT;
text_.render(DRIVER_TEXT,
Vec2{.x = Cfg::X, .y = y},
Cfg::TEXT_SCALE,
Cfg::TEXT_SPACING,
Cfg::BRIGHTNESS,
Cfg::COLOR);
y += Cfg::LINE_HEIGHT;
text_.render(VSYNC_TEXT, text_.render(VSYNC_TEXT,
Vec2{.x = Cfg::X, .y = Cfg::Y_FPS + Cfg::LINE_HEIGHT}, Vec2{.x = Cfg::X, .y = y},
Cfg::TEXT_SCALE, Cfg::TEXT_SCALE,
Cfg::TEXT_SPACING, Cfg::TEXT_SPACING,
Cfg::BRIGHTNESS, Cfg::BRIGHTNESS,
Cfg::COLOR); Cfg::COLOR);
y += Cfg::LINE_HEIGHT;
text_.render(AA_TEXT, text_.render(AA_TEXT,
Vec2{.x = Cfg::X, .y = Cfg::Y_FPS + (2.0F * Cfg::LINE_HEIGHT)}, Vec2{.x = Cfg::X, .y = y},
Cfg::TEXT_SCALE, Cfg::TEXT_SCALE,
Cfg::TEXT_SPACING, Cfg::TEXT_SPACING,
Cfg::BRIGHTNESS, Cfg::BRIGHTNESS,
+1
View File
@@ -31,6 +31,7 @@ namespace System {
private: private:
Graphics::VectorText text_; Graphics::VectorText text_;
Rendering::Renderer* renderer_;
const Config::RenderingConfig* rendering_cfg_; const Config::RenderingConfig* rendering_cfg_;
bool visible_{false}; bool visible_{false};