Added SDL_SetWindowSurfaceVSync() and SDL_GetWindowSurfaceVSync()

Fixes https://github.com/libsdl-org/SDL/issues/9347
This commit is contained in:
Sam Lantinga
2024-05-27 10:27:17 -07:00
parent 7c75801571
commit dfe4445214
9 changed files with 106 additions and 21 deletions

View File

@@ -2142,6 +2142,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_AddVulkanRenderSemaphores(SDL_Renderer *rend
/**
* Toggle VSync of the given renderer.
*
* When a renderer is created, vsync defaults to SDL_RENDERER_VSYNC_DISABLED.
*
* \param renderer The renderer to toggle
* \param vsync the vertical refresh sync interval, 1 to synchronize present
* with every vertical refresh, 2 to synchronize present with
@@ -2168,7 +2170,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetRenderVSync(SDL_Renderer *renderer, int v
*
* \param renderer The renderer to toggle
* \param vsync an int filled with the current vertical refresh sync interval.
* See SDL_SetRenderVSync for the meaning of the value.
* See SDL_SetRenderVSync() for the meaning of the value.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*

View File

@@ -1801,6 +1801,40 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_WindowHasSurface(SDL_Window *window);
*/
extern SDL_DECLSPEC SDL_Surface *SDLCALL SDL_GetWindowSurface(SDL_Window *window);
/**
* Toggle VSync for the window surface.
*
* When a window surface is created, vsync defaults to SDL_WINDOW_SURFACE_VSYNC_DISABLED.
*
* \param window the window
* \param vsync the vertical refresh sync interval, 1 to synchronize present with every vertical refresh, 2 to synchronize present with every second vertical refresh, etc., SDL_WINDOW_SURFACE_VSYNC_ADAPTIVE for late swap tearing (adaptive vsync), or SDL_WINDOW_SURFACE_VSYNC_DISABLED to disable. Not every value is supported by every driver, so you should check the return value to see whether the requested setting is supported.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetWindowSurfaceVSync
*/
extern SDL_DECLSPEC int SDLCALL SDL_SetWindowSurfaceVSync(SDL_Window *window, int vsync);
#define SDL_WINDOW_SURFACE_VSYNC_DISABLED 0
#define SDL_WINDOW_SURFACE_VSYNC_ADAPTIVE (-1)
/**
* Get VSync for the window surface.
*
* \param window the window to query
* \param vsync an int filled with the current vertical refresh sync interval.
* See SDL_SetWindowSurfaceVSync() for the meaning of the value.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_SetWindowSurfaceVSync
*/
extern SDL_DECLSPEC int SDLCALL SDL_GetWindowSurfaceVSync(SDL_Window *window, int *vsync);
/**
* Copy the window surface to the screen.
*