modificat el delay de director per acceptar framerates de hasta 250FPS
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user