1ef9ca551f
Permet alternar l'AA geomètric en runtime:
- Action::TOGGLE_ANTIALIAS bound a F5.
- GlobalEvents::handle reacciona al scancode F5 cridant sdl.toggleAntialias().
- SDLManager::toggleAntialias muta cfg_->rendering.antialias i propaga a
gpu_renderer_.setAntialias().
- GpuFrameRenderer manté l'estat antialias_enabled_ (true per defecte) i
pushLine adapta extrusió i edge_dist en funció del flag — geometria nua
quan està OFF, fade als bords quan està ON.
- RenderingConfig guanya el camp `antialias{1}` per coherència amb vsync;
l'estat NO es persisteix al YAML de moment (decisió volgudament conservadora,
podem afegir-ho en un commit a part si cal).
- DebugOverlay (F11) mostra una tercera línia "AA: ON/OFF" sota VSYNC per
poder comparar a temps real.
67 lines
2.2 KiB
C++
67 lines
2.2 KiB
C++
// debug_overlay.cpp - Implementación del overlay de debug.
|
||
|
||
#include "core/system/debug_overlay.hpp"
|
||
|
||
#include <string>
|
||
|
||
#include "core/types.hpp"
|
||
|
||
namespace System {
|
||
|
||
namespace {
|
||
// Posición y tamaño del overlay en coordenadas lógicas (1280×720).
|
||
constexpr float OVERLAY_X = 12.0F;
|
||
constexpr float OVERLAY_Y_FPS = 12.0F;
|
||
constexpr float OVERLAY_LINE_HEIGHT = 18.0F; // separación entre líneas (scale 0.4 → ~16 px alto)
|
||
constexpr float OVERLAY_SCALE = 0.4F;
|
||
constexpr float OVERLAY_SPACING = 2.0F;
|
||
constexpr float OVERLAY_BRIGHTNESS = 1.0F;
|
||
|
||
// Cadencia de actualización del valor de FPS mostrado.
|
||
constexpr float FPS_UPDATE_INTERVAL = 0.5F;
|
||
} // namespace
|
||
|
||
DebugOverlay::DebugOverlay(Rendering::Renderer* renderer,
|
||
const Config::RenderingConfig& rendering_cfg)
|
||
: text_(renderer),
|
||
rendering_cfg_(&rendering_cfg) {}
|
||
|
||
void DebugOverlay::update(float delta_time) {
|
||
fps_accumulator_ += delta_time;
|
||
fps_frame_count_++;
|
||
|
||
if (fps_accumulator_ >= FPS_UPDATE_INTERVAL) {
|
||
fps_display_ = static_cast<int>(fps_frame_count_ / fps_accumulator_);
|
||
fps_frame_count_ = 0;
|
||
fps_accumulator_ = 0.0F;
|
||
}
|
||
}
|
||
|
||
void DebugOverlay::draw() const {
|
||
if (!visible_) {
|
||
return;
|
||
}
|
||
|
||
const std::string FPS_TEXT = "FPS: " + std::to_string(fps_display_);
|
||
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");
|
||
|
||
text_.render(FPS_TEXT,
|
||
Vec2{.x = OVERLAY_X, .y = OVERLAY_Y_FPS},
|
||
OVERLAY_SCALE,
|
||
OVERLAY_SPACING,
|
||
OVERLAY_BRIGHTNESS);
|
||
text_.render(VSYNC_TEXT,
|
||
Vec2{.x = OVERLAY_X, .y = OVERLAY_Y_FPS + OVERLAY_LINE_HEIGHT},
|
||
OVERLAY_SCALE,
|
||
OVERLAY_SPACING,
|
||
OVERLAY_BRIGHTNESS);
|
||
text_.render(AA_TEXT,
|
||
Vec2{.x = OVERLAY_X, .y = OVERLAY_Y_FPS + (2.0F * OVERLAY_LINE_HEIGHT)},
|
||
OVERLAY_SCALE,
|
||
OVERLAY_SPACING,
|
||
OVERLAY_BRIGHTNESS);
|
||
}
|
||
|
||
} // namespace System
|