fps: overlay debug a dalt-dreta del canvas (verd, F10 toggle, 8bithud, alineat amb notificacions i overscan-aware)

This commit is contained in:
2026-05-19 20:59:35 +02:00
parent 73f210bc2c
commit fa2dc9bbf3
5 changed files with 73 additions and 1 deletions
+14
View File
@@ -73,6 +73,10 @@ class Screen {
void notify(const std::string &text, Color text_color, Color outline_color, Uint32 duration_ms); // Muestra una notificación en la línea superior del canvas durante durationMs. Sobrescribe cualquier notificación activa (sin apilación).
void clearNotification(); // Limpia la notificación actual
// FPS overlay (debug, no persistent)
void toggleFps(); // Alterna la visibilitat de l'overlay de FPS
[[nodiscard]] auto isFpsVisible() const -> bool; // Estat actual
// GPU / shaders (post-procesado). En builds con NO_SHADERS (Emscripten) son no-op.
void initShaders(); // Crea el backend GPU si no existe y lo inicializa
void shutdownShaders(); // Libera el backend GPU
@@ -115,6 +119,10 @@ class Screen {
void renderNotification(); // Dibuja la notificación activa (si la hay) sobre el gameCanvas
[[nodiscard]] auto safeNotificationY() const -> int; // Y minima dins del canvas que segueix sent visible en overscan (segons aspect ratio finestra/canvas)
// FPS overlay
void updateFps(); // Acumula temps i recalcula fps cada segon (a cridar des de blit)
void renderFps(); // Dibuixa "NN FPS" a dalt a la dreta del canvas
#ifndef NO_SHADERS
// Aplica els paràmetres actuals del shader al backend segons options
// (pass-through si `videoShaderEnabled==false`, preset per defecte si true).
@@ -142,6 +150,12 @@ class Screen {
Uint32 notification_end_time_; // SDL_GetTicks() hasta el cual se muestra
int notification_y_; // Fila vertical en el canvas virtual
// FPS overlay (debug, no persistent)
bool fps_visible_{false}; // F10 toggle
int fps_value_{0}; // Ultim valor calculat (frames per segon)
int fps_frame_count_{0}; // Frames acumulats durant la finestra actual
Uint32 fps_window_start_ticks_{0}; // Inici de la finestra d'1s actual (SDL_GetTicks)
#ifndef NO_SHADERS
// GPU / shaders
std::unique_ptr<Rendering::ShaderBackend> shader_backend_; // Backend GPU (nullptr si inactivo)