Added support for simulated vsync in the renderer

This kicks in if the platform doesn't support vsync directly, or if the present fails for some reason (e.g. minimized on some platforms)

Fixes https://github.com/libsdl-org/SDL/issues/5134
This commit is contained in:
Sam Lantinga
2022-09-15 01:00:12 -07:00
parent 339f7a2f6b
commit d744aafb05
15 changed files with 115 additions and 37 deletions

View File

@@ -519,6 +519,8 @@ extern void SDL_ToggleDragAndDropSupport(void);
extern int SDL_GetPointDisplayIndex(const SDL_Point * point);
extern int SDL_GL_SwapWindowWithResult(SDL_Window * window);
#endif /* SDL_sysvideo_h_ */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -4152,22 +4152,26 @@ SDL_GL_GetSwapInterval(void)
}
}
void
SDL_GL_SwapWindow(SDL_Window * window)
int
SDL_GL_SwapWindowWithResult(SDL_Window * window)
{
CHECK_WINDOW_MAGIC(window,);
CHECK_WINDOW_MAGIC(window, -1);
if (!(window->flags & SDL_WINDOW_OPENGL)) {
SDL_SetError("The specified window isn't an OpenGL window");
return;
return SDL_SetError("The specified window isn't an OpenGL window");
}
if (SDL_GL_GetCurrentWindow() != window) {
SDL_SetError("The specified window has not been made current");
return;
return SDL_SetError("The specified window has not been made current");
}
_this->GL_SwapWindow(_this, window);
return _this->GL_SwapWindow(_this, window);
}
void
SDL_GL_SwapWindow(SDL_Window * window)
{
SDL_GL_SwapWindowWithResult(window);
}
void