Init, errors & main callbacksSDL 3.2
SDL_AppQuit
A function YOU write: SDL calls it once at the end, so you can free everything.
Signature
void SDL_AppQuit(void *appstate, SDL_AppResult result);
How it works
It runs after any callback returned SDL_APP_SUCCESS or SDL_APP_FAILURE (the value arrives as result). Destroy your textures, renderer and window and delete your state. SDL calls SDL_Quit itself right after, so you do not have to.
It also runs when SDL_AppInit failed, so appstate can be NULL or half-built: check before using it.
Parameters
appstatevoid *
The pointer you stored in SDL_AppInit (may be NULL).
resultSDL_AppResult
SDL_APP_SUCCESS or SDL_APP_FAILURE: why the program is ending.
Example
example.cpp
1void SDL_AppQuit(void* appstate, SDL_AppResult result) {
2 auto* app = static_cast<App*>(appstate);
3 if (app) {
4 SDL_DestroyRenderer(app->renderer);
5 SDL_DestroyWindow(app->window);
6 delete app;
7 }
8 // SDL_Quit() is called by SDL after this returns
9}