Textures & surfacesSDL 3.2
SDL_DestroySurface
Frees a surface (an image in CPU memory). SDL2 called it SDL_FreeSurface.
Signature
void SDL_DestroySurface(SDL_Surface *surface);
How it works
Surfaces are usually temporary: load, turn into a texture, destroy. Keep one only if you need to read its pixels on the CPU later (for example for pixel-perfect collision).
Parameters
surfaceSDL_Surface *
The surface to free. NULL is allowed.
Example
example.cpp
1SDL_Surface* text = TTF_RenderText_Blended(font, "Score: 120", 0, white);
2SDL_Texture* label = SDL_CreateTextureFromSurface(renderer, text);
3SDL_DestroySurface(text);