diff --git a/WhatsNew.txt b/WhatsNew.txt index e6befaaa4..56172f41b 100644 --- a/WhatsNew.txt +++ b/WhatsNew.txt @@ -20,3 +20,4 @@ General: * Added SDL_DelayNS() to specify a delay in nanoseconds, to the highest precision the system will support * The timestamp member of the SDL_Event structure is now in nanoseconds, filled in with the time the event was generated, or the time it was queued if that's not available * Added SDL_modf() and SDL_modff() to separate the whole and fractional portions of a floating point number +* Added SDL_GetRenderVSync() to get vsync of the given renderer diff --git a/include/SDL3/SDL_render.h b/include/SDL3/SDL_render.h index 3eda734b1..c772c4759 100644 --- a/include/SDL3/SDL_render.h +++ b/include/SDL3/SDL_render.h @@ -1925,6 +1925,17 @@ extern DECLSPEC void *SDLCALL SDL_GetRenderMetalCommandEncoder(SDL_Renderer * re */ extern DECLSPEC int SDLCALL SDL_SetRenderVSync(SDL_Renderer* renderer, int vsync); +/** + * Get VSync of the given renderer. + * + * \param renderer The renderer to toggle + * \param set output vsync 1 for on, 0 for off. All other values are reserved + * \returns a 0 int on success, or non-zero on failure + * + * \since This function is available since SDL 3.0.0. + */ +extern DECLSPEC int SDLCALL SDL_GetRenderVSync(SDL_Renderer *renderer, int *vsync); + /* Ends C function definitions when using C++ */ #ifdef __cplusplus } diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym index 0d22987c4..ac9ab4da8 100644 --- a/src/dynapi/SDL_dynapi.sym +++ b/src/dynapi/SDL_dynapi.sym @@ -856,6 +856,7 @@ SDL3_0.0.0 { SDL_wcsstr; SDL_modf; SDL_modff; + SDL_GetRenderVSync; # extra symbols go here (don't modify this line) local: *; }; diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h index b88702ce8..39f822710 100644 --- a/src/dynapi/SDL_dynapi_overrides.h +++ b/src/dynapi/SDL_dynapi_overrides.h @@ -884,3 +884,4 @@ /* New API symbols are added at the end */ #define SDL_modf SDL_modf_REAL #define SDL_modff SDL_modff_REAL +#define SDL_GetRenderVSync SDL_GetRenderVSync_REAL diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index 069178d22..79517f8ac 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -929,3 +929,4 @@ SDL_DYNAPI_PROC(wchar_t*,SDL_wcsstr,(const wchar_t *a, const wchar_t *b),(a,b),r /* New API symbols are added at the end */ SDL_DYNAPI_PROC(double,SDL_modf,(double a, double *b),(a,b),return) SDL_DYNAPI_PROC(float,SDL_modff,(float a, float *b),(a,b),return) +SDL_DYNAPI_PROC(int,SDL_GetRenderVSync,(SDL_Renderer *a, int *b),(a,b),return) diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index 204b7d399..81edcf324 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -4492,3 +4492,13 @@ int SDL_SetRenderVSync(SDL_Renderer *renderer, int vsync) } return 0; } + +int SDL_GetRenderVSync(SDL_Renderer *renderer, int *vsync) +{ + CHECK_RENDERER_MAGIC(renderer, -1); + if (vsync == NULL) { + return SDL_InvalidParamError("vsync"); + } + *vsync = renderer->wanted_vsync; + return 0; +}