VSYNC fixes for 100Hz displays
This commit is contained in:
parent
908757880b
commit
37b5e246b0
10
src/studio.c
10
src/studio.c
|
@ -2755,11 +2755,15 @@ s32 main(s32 argc, char **argv)
|
||||||
u64 nextTick = SDL_GetPerformanceCounter();
|
u64 nextTick = SDL_GetPerformanceCounter();
|
||||||
const u64 Delta = SDL_GetPerformanceFrequency() / TIC_FRAMERATE;
|
const u64 Delta = SDL_GetPerformanceFrequency() / TIC_FRAMERATE;
|
||||||
|
|
||||||
bool noVsync = false;
|
bool useTimer = false;
|
||||||
{
|
{
|
||||||
SDL_RendererInfo info;
|
SDL_RendererInfo info;
|
||||||
|
SDL_DisplayMode mode;
|
||||||
|
|
||||||
SDL_GetRendererInfo(studio.renderer, &info);
|
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)
|
while (!studio.quitFlag)
|
||||||
|
@ -2767,7 +2771,7 @@ s32 main(s32 argc, char **argv)
|
||||||
nextTick += Delta;
|
nextTick += Delta;
|
||||||
tick();
|
tick();
|
||||||
|
|
||||||
if(SDL_GetWindowFlags(studio.window) & SDL_WINDOW_MINIMIZED || noVsync)
|
if(SDL_GetWindowFlags(studio.window) & SDL_WINDOW_MINIMIZED || useTimer)
|
||||||
{
|
{
|
||||||
s64 delay = nextTick - SDL_GetPerformanceCounter();
|
s64 delay = nextTick - SDL_GetPerformanceCounter();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue