mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-26 03:30:46 +00:00
sdlayer.cpp: fix vsync heartbeat issue on some NVidia & Intel drivers
git-svn-id: https://svn.eduke32.com/eduke32@6689 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
b2470aa677
commit
9f48927ea8
1 changed files with 11 additions and 0 deletions
|
@ -101,6 +101,7 @@ char nogl=0;
|
||||||
#endif
|
#endif
|
||||||
static int32_t vsync_renderlayer;
|
static int32_t vsync_renderlayer;
|
||||||
int32_t maxrefreshfreq=0;
|
int32_t maxrefreshfreq=0;
|
||||||
|
static uint32_t currentVBlankInterval=0;
|
||||||
|
|
||||||
// last gamma, contrast, brightness
|
// last gamma, contrast, brightness
|
||||||
static float lastvidgcb[3];
|
static float lastvidgcb[3];
|
||||||
|
@ -1521,6 +1522,8 @@ void setrefreshrate(void)
|
||||||
initprintf("Refresh rate: %dHz\n", newmode.refresh_rate);
|
initprintf("Refresh rate: %dHz\n", newmode.refresh_rate);
|
||||||
SDL_SetWindowDisplayMode(sdl_window, &newmode);
|
SDL_SetWindowDisplayMode(sdl_window, &newmode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentVBlankInterval = 1000/newmode.refresh_rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sdl_trycreaterenderer_fail(char const * const failurepoint)
|
static void sdl_trycreaterenderer_fail(char const * const failurepoint)
|
||||||
|
@ -1789,7 +1792,15 @@ void showframe(int32_t w)
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
AndroidDrawControls();
|
AndroidDrawControls();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static uint32_t lastSwapTime = 0;
|
||||||
SDL_GL_SwapWindow(sdl_window);
|
SDL_GL_SwapWindow(sdl_window);
|
||||||
|
if (vsync)
|
||||||
|
{
|
||||||
|
// busy loop until we're ready to update again
|
||||||
|
while (SDL_GetTicks()-lastSwapTime < currentVBlankInterval) {}
|
||||||
|
}
|
||||||
|
lastSwapTime = SDL_GetTicks();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue