Textures & surfacesSDL 3.2

SDL_DestroyTexture

Frees a texture's GPU memory.

Signature

void SDL_DestroyTexture(SDL_Texture *texture);

How it works

Destroy textures you no longer need, e.g. when a level ends. Destroying the renderer destroys all of its textures too, so do not destroy a texture after its renderer is gone.

Parameters

textureSDL_Texture *

The texture to free.

Example

example.cpp
1SDL_DestroyTexture(levelBackground);
2levelBackground = nullptr;
Official SDL wiki