Ver Fonte

render: Added SDL_GetTextureRenderer().

Ryan C. Gordon há 1 ano atrás
pai
commit
9bc7cfc755

+ 17 - 0
include/SDL3/SDL_render.h

@@ -702,6 +702,23 @@ extern DECLSPEC SDL_Texture *SDLCALL SDL_CreateTextureWithProperties(SDL_Rendere
  */
 extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetTextureProperties(SDL_Texture *texture);
 
+/**
+ * Get the renderer that created an SDL_Texture.
+ *
+ * \param texture the texture to query
+ * \returns a pointer to the SDL_Renderer that created the texture, or NULL
+ *          on failure; call SDL_GetError() for more information.
+ *
+ * \threadsafety It is safe to call this function from any thread.
+ *
+ * \since This function is available since SDL 3.0.0.
+ *
+ * \sa SDL_CreateTexture
+ * \sa SDL_CreateTextureFromSurface
+ * \sa SDL_CreateTextureWithProperties
+ */
+extern DECLSPEC SDL_Renderer *SDLCALL SDL_GetTextureRenderer(SDL_Texture *texture);
+
 /**
  * Query the attributes of a texture.
  *

+ 1 - 0
src/dynapi/SDL_dynapi.sym

@@ -961,6 +961,7 @@ SDL3_0.0.0 {
     SDL_wcsnstr;
     SDL_SyncWindow;
     SDL_GetGamepadSteamHandle;
+    SDL_GetTextureRenderer;
     # extra symbols go here (don't modify this line)
   local: *;
 };

+ 1 - 0
src/dynapi/SDL_dynapi_overrides.h

@@ -986,3 +986,4 @@
 #define SDL_wcsnstr SDL_wcsnstr_REAL
 #define SDL_SyncWindow SDL_SyncWindow_REAL
 #define SDL_GetGamepadSteamHandle SDL_GetGamepadSteamHandle_REAL
+#define SDL_GetTextureRenderer SDL_GetTextureRenderer_REAL

+ 1 - 0
src/dynapi/SDL_dynapi_procs.h

@@ -1011,3 +1011,4 @@ SDL_DYNAPI_PROC(char*,SDL_strnstr,(const char *a, const char *b, size_t c),(a,b,
 SDL_DYNAPI_PROC(wchar_t*,SDL_wcsnstr,(const wchar_t *a, const wchar_t *b, size_t c),(a,b,c),return)
 SDL_DYNAPI_PROC(int,SDL_SyncWindow,(SDL_Window *a),(a),return)
 SDL_DYNAPI_PROC(Uint64,SDL_GetGamepadSteamHandle,(SDL_Gamepad *a),(a),return)
+SDL_DYNAPI_PROC(SDL_Renderer*,SDL_GetTextureRenderer,(SDL_Texture *a),(a),return)

+ 6 - 0
src/render/SDL_render.c

@@ -1396,6 +1396,12 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s
     return texture;
 }
 
+SDL_Renderer *SDL_GetTextureRenderer(SDL_Texture *texture)
+{
+    CHECK_TEXTURE_MAGIC(texture, NULL);
+    return texture->renderer;
+}
+
 SDL_PropertiesID SDL_GetTextureProperties(SDL_Texture *texture)
 {
     CHECK_TEXTURE_MAGIC(texture, 0);