From e7202c93323c4f5c5dc4b41e912d2ecdeb0b2977 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sun, 5 Apr 2026 01:42:34 +0200 Subject: [PATCH] modificat el delay de director per acceptar framerates de hasta 250FPS --- source/core/system/director.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/core/system/director.cpp b/source/core/system/director.cpp index 8e28efb..4165ce3 100644 --- a/source/core/system/director.cpp +++ b/source/core/system/director.cpp @@ -58,7 +58,8 @@ void Director::run() { Uint32 presentation_buffer[320 * 200]{}; bool has_frame = false; - constexpr Uint32 TARGET_FRAME_MS = 16; // ~60 FPS + constexpr Uint32 FRAME_MS_VSYNC = 16; // ~60 FPS amb VSync + constexpr Uint32 FRAME_MS_NO_VSYNC = 4; // ~250 FPS sense VSync (límit superior) // Bucle principal del director (no-bloquejant) while (!game_thread_done_ && !quit_requested_) { @@ -98,10 +99,11 @@ void Director::run() { Screen::get()->present(presentation_buffer); } - // Limita a ~60 FPS + // Límit de framerate segons VSync + Uint32 target_ms = Options::video.vsync ? FRAME_MS_VSYNC : FRAME_MS_NO_VSYNC; Uint32 elapsed = SDL_GetTicks() - frame_start; - if (elapsed < TARGET_FRAME_MS) { - SDL_Delay(TARGET_FRAME_MS - elapsed); + if (elapsed < target_ms) { + SDL_Delay(target_ms - elapsed); } }