Jelajahi Sumber

Add SDL_GetRenderVSync (see #6495) (#6965)

Sylvain Becker 2 tahun lalu
induk
melakukan
851b0e16be

+ 1 - 0
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

+ 11 - 0
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
 }

+ 1 - 0
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: *;
 };

+ 1 - 0
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

+ 1 - 0
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)

+ 10 - 0
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;
+}