VSYNC fixes for 100Hz displays

This commit is contained in:
BADIM-PC\Vadim 2018-01-04 15:22:33 +03:00
parent 908757880b
commit 37b5e246b0
1 changed files with 8 additions and 4 deletions

View File

@ -2755,11 +2755,15 @@ 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)
@ -2767,7 +2771,7 @@ s32 main(s32 argc, char **argv)
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();