modificat el delay de director per acceptar framerates de hasta 250FPS

This commit is contained in:
2026-04-05 01:42:34 +02:00
parent 22ee9538a2
commit e7202c9332

View File

@@ -58,7 +58,8 @@ void Director::run() {
Uint32 presentation_buffer[320 * 200]{}; Uint32 presentation_buffer[320 * 200]{};
bool has_frame = false; 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) // Bucle principal del director (no-bloquejant)
while (!game_thread_done_ && !quit_requested_) { while (!game_thread_done_ && !quit_requested_) {
@@ -98,10 +99,11 @@ void Director::run() {
Screen::get()->present(presentation_buffer); 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; Uint32 elapsed = SDL_GetTicks() - frame_start;
if (elapsed < TARGET_FRAME_MS) { if (elapsed < target_ms) {
SDL_Delay(TARGET_FRAME_MS - elapsed); SDL_Delay(target_ms - elapsed);
} }
} }