From 37b5e246b08fcea51c2bf5c63cf8dc58a3de31c3 Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Thu, 4 Jan 2018 15:22:33 +0300 Subject: [PATCH] VSYNC fixes for 100Hz displays --- src/studio.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/studio.c b/src/studio.c index 894470a..d69da78 100644 --- a/src/studio.c +++ b/src/studio.c @@ -2755,19 +2755,23 @@ s32 main(s32 argc, char **argv) u64 nextTick = SDL_GetPerformanceCounter(); const u64 Delta = SDL_GetPerformanceFrequency() / TIC_FRAMERATE; - bool noVsync = false; + bool useTimer = false; { SDL_RendererInfo info; + SDL_DisplayMode mode; + SDL_GetRendererInfo(studio.renderer, &info); - noVsync = info.flags & SDL_RENDERER_PRESENTVSYNC ? false : true; + SDL_GetCurrentDisplayMode(SDL_GetWindowDisplayIndex(studio.window), &mode); + + useTimer = !(info.flags & SDL_RENDERER_PRESENTVSYNC) || mode.refresh_rate != TIC_FRAMERATE; } - + while (!studio.quitFlag) { nextTick += Delta; tick(); - if(SDL_GetWindowFlags(studio.window) & SDL_WINDOW_MINIMIZED || noVsync) + if(SDL_GetWindowFlags(studio.window) & SDL_WINDOW_MINIMIZED || useTimer) { s64 delay = nextTick - SDL_GetPerformanceCounter();