diff --git a/include/SDL3/SDL_render.h b/include/SDL3/SDL_render.h index e689b94c20..7005f78f83 100644 --- a/include/SDL3/SDL_render.h +++ b/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. * diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym index 4e3ea9e52a..51f3629b81 100644 --- a/src/dynapi/SDL_dynapi.sym +++ b/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: *; }; diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h index 0e2636fa4f..ddd57de6a6 100644 --- a/src/dynapi/SDL_dynapi_overrides.h +++ b/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 diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index fbd18f1b8e..7d92febecd 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/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) diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index 76f8074e8a..66453024b5 100644 --- a/src/render/SDL_render.c +++ b/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);