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 in SDL_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