From b114d75c69fe859a492a383c4e84bf086227eef4 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Mon, 9 Sep 2024 18:47:59 +0200 Subject: [PATCH] Retoques de lo anterior para ser un poco mas eficiente y ordenado --- source/common/screen.cpp | 8 +++++--- source/common/screen.h | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/source/common/screen.cpp b/source/common/screen.cpp index 6b6f598..aefac84 100644 --- a/source/common/screen.cpp +++ b/source/common/screen.cpp @@ -43,6 +43,10 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, Input * #else showFps = false; #endif + SDL_DisplayMode DM; + SDL_GetCurrentDisplayMode(0, &DM); + displayWidth = DM.w; + displayHeight = DM.h; // Crea los objetos notify = new Notify(renderer, asset->get("notify.png"), asset->get("8bithud.png"), asset->get("8bithud.txt"), asset->get("notify.wav"), options); @@ -103,9 +107,7 @@ void Screen::blit() dbg_print(0, 0, fpstext.c_str(), 255, 255, 255); // Resolution - SDL_DisplayMode DM; - SDL_GetCurrentDisplayMode(0, &DM); - const std::string resolution = std::to_string(DM.w) + " X " + std::to_string(DM.h); + const std::string resolution = std::to_string(displayWidth) + " X " + std::to_string(displayHeight); dbg_print(0, 8, resolution.c_str(), 255, 255, 255); } diff --git a/source/common/screen.h b/source/common/screen.h index 09e7b26..9ea436e 100644 --- a/source/common/screen.h +++ b/source/common/screen.h @@ -38,6 +38,8 @@ private: int fpsCounter; // Contador de frames por segundo int fps; // Frames calculados en el último segundo bool showFps; // Indica si ha de mostrar/ocultar la información de los frames por segundo en pantalla + int displayWidth; // Anchura de la pantalla + int displayHeight; // Altura de la pantalla struct effect_t {