Files
orni-attack/source/core/system/debug_overlay.cpp
T
JailDesigner 0573022b7c Debug overlay (FPS + VSync) toggleable con F11
Crea core/system/DebugOverlay como sistema global propiedad del Director
que muestra FPS y estado de VSync en la esquina superior izquierda usando
VectorText. Visible por defecto en builds debug, oculto en release; F11
alterna.

Cambios:

- Nuevo DebugOverlay con su propio contador de FPS interno (cadencia 0.5s).
  El cálculo que vivía en SDLManager::updateFPS se mueve aquí.
- Director construye el overlay una vez y lo pasa a runFrameLoop. F11 se
  intercepta directamente en el event loop del Director (no en
  GlobalEvents para no acoplar la firma a la presencia del overlay).
- Limpieza de SDLManager: fuera updateFPS, updateColors (era no-op desde
  Fase 8c), setWindowTitle (no se usaba) y los campos fps_*.
- Título de ventana estático estilo CCAE:
    © 2026 Orni Attack — JailDesigner
  Ya no se reescribe cada 0.5s con FPS y VSync; ese estado vive en el
  overlay.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 09:34:46 +02:00

65 lines
1.8 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// debug_overlay.cpp - Implementación del overlay de debug.
#include "core/system/debug_overlay.hpp"
#include <string>
#include "core/types.hpp"
#include "game/options.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)
: text_(renderer),
#ifdef _DEBUG
visible_(true),
#else
visible_(false),
#endif
fps_accumulator_(0.0F),
fps_frame_count_(0),
fps_display_(0) {}
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: ")
+ (Options::rendering.vsync == 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);
}
} // namespace System