SDL_AppQuit(3)
β¨ SDL_AppQuit(3) β¨
okay bestie, so this is a page from the SDL3 FUNCTIONS collection, and the star of the show is SDL_AppQuit π
π NAME π
SDL_AppQuit β the app-implemented deinit entry point for SDL_MAIN_USE_CALLBACKS apps. it's the goodbye function, the last dance, the "okay pack it up we're done here" π
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_main.h>
void SDL_AppQuit(void *appstate, SDL_AppResult result);
π¦ DESCRIPTION π¦
so here's the tea: you implement this function when you're using SDL_MAIN_USE_CALLBACKS. if you're rocking a standard "main" function instead, then you should not supply this β like, it's not for you, no cap.
SDL calls this function exactly once before it terminates the program. one and done. periodt.
and the way it's called in all cases?? even if SDL_AppInit requests termination right at startup, this still runs. SDL is not skipping your goodbye, bestie.
now, important: this function should not go into an infinite mainloop π it should deinitialize whatever resources need deinitializing, do whatever shutdown activities you've got going on, and then return. that's it. in and out.
you do not need to call SDL_Quit() in here, because SDL will call it for you after this function returns and before the process terminates. but also β it's totally safe if you do. your call, main character π
the appstate parameter is an optional pointer that the app handed over during SDL_AppInit(). if the app never provided a pointer, this will be NULL. and listen: this function call is the last time this pointer will be provided, so any resources tied to it should get cleaned up here. last chance, no takebacks π
also, this function is called by SDL on the main thread. noted. π
β FUNCTION PARAMETERS β
appstateβ an optional pointer, provided by the app inSDL_AppInit. it's giving "you gave me this, i'm giving it back to you one final time" π«Άresultβ the result code that terminated the app (success or failure). basically the receipts for how things ended π
π₯ THREAD SAFETY π₯
SDL_AppEvent() may get called concurrently with this function if other threads that push events are still active. so likeβ¦ stay aware, bestie, things can get a little chaotic in the group chat π
π AVAILABILITY π
this function is available since SDL 3.2.0. it's been here. it's iconic. π
π SEE ALSO π
and that's the whole vibe β¨ this page came to you from Simple Directmedia Layer, version SDL 3.4.18 β so if you're running that, you're literally in the right place. go deinit something and log off gracefully, queen π ππ¦
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms