From c9fb9cbe73ea25a74713691d854aa36e77cdb607 Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Sun, 31 Dec 2017 13:15:05 +0300 Subject: [PATCH] Games get desynced #491 removed timer using with VSYNC together --- src/studio.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/studio.c b/src/studio.c index 9b6e540..4c78295 100644 --- a/src/studio.c +++ b/src/studio.c @@ -2754,17 +2754,27 @@ s32 main(s32 argc, char **argv) { u64 nextTick = SDL_GetPerformanceCounter(); const u64 Delta = SDL_GetPerformanceFrequency() / TIC_FRAMERATE; + + bool noVsync = false; + { + SDL_RendererInfo info; + SDL_GetRendererInfo(studio.renderer, &info); + noVsync = info.flags & SDL_RENDERER_PRESENTVSYNC ? false : true; + } while (!studio.quitFlag) { nextTick += Delta; tick(); - s64 delay = nextTick - SDL_GetPerformanceCounter(); + if(noVsync || SDL_GetWindowFlags(studio.window) & SDL_WINDOW_MINIMIZED) + { + s64 delay = nextTick - SDL_GetPerformanceCounter(); - if(delay > 0) - SDL_Delay((u32)(delay * 1000 / SDL_GetPerformanceFrequency())); - else nextTick -= delay; + if(delay > 0) + SDL_Delay((u32)(delay * 1000 / SDL_GetPerformanceFrequency())); + else nextTick -= delay; + } } }