Made texture size and format public in the API

Also added refcount to textures so they can be retained by application code.
This commit is contained in:
Sam Lantinga
2024-09-30 20:40:54 -07:00
parent 5136b30652
commit 1f3a0d12e6
8 changed files with 76 additions and 66 deletions

View File

@@ -48,7 +48,6 @@ static void DrawOnViewport(SDL_Renderer *renderer)
{
SDL_FRect rect;
SDL_Rect cliprect;
float w, h;
/* Set the viewport */
SDL_SetRenderViewport(renderer, &viewport);
@@ -91,15 +90,11 @@ static void DrawOnViewport(SDL_Renderer *renderer)
SDL_RenderFillRect(renderer, &rect);
/* Add a clip rect and fill it with the sprite */
SDL_GetTextureSize(sprite, &w, &h);
rect.x = (viewport.w - w) / 2;
rect.y = (viewport.h - h) / 2;
rect.w = w;
rect.h = h;
cliprect.x = (int)rect.x;
cliprect.y = (int)rect.y;
cliprect.w = (int)rect.w;
cliprect.h = (int)rect.h;
cliprect.x = (viewport.w - sprite->w) / 2;
cliprect.y = (viewport.h - sprite->h) / 2;
cliprect.w = sprite->w;
cliprect.h = sprite->h;
SDL_RectToFRect(&cliprect, &rect);
SDL_SetRenderClipRect(renderer, &cliprect);
SDL_RenderTexture(renderer, sprite, NULL, &rect);
SDL_SetRenderClipRect(renderer, NULL);