API reference / Images and textures
SDL_GetTextureSize
Function, SDL3
Gets the size of a texture in pixels.
Declaration
#include <SDL3/SDL.h>
bool SDL_GetTextureSize(SDL_Texture *texture, float *w, float *h);Parameters
texture | The texture. |
w | The address of a float for the width, or NULL. |
h | The address of a float for the height, or NULL. |
Return value
True on success. On failure it returns false.
Example
SDL_GetTextureSize(ship, &width, &height);See this code run in Load an image. Download the full program (.zip)
In SDL2
Use SDL_QueryTexture, which gives int values.