allegro_exit(3alleg4)

✨ allegro_exit ✨

okay bestie, so allegro_exit is the page in the Allegro manual that tells you how to say bye-bye to the whole Allegro system πŸ’… it's like the goodbye hug at the end of the party, except the party is your graphics library.


🌸 NAME 🌸

allegro_exit β€” closes down the Allegro system, fr fr 🫢


πŸŽ€ SYNOPSIS πŸŽ€

#include <allegro.h>

void allegro_exit();

πŸ¦‹ DESCRIPTION πŸ¦‹

So what does it do? It closes down the Allegro system. That means:

  • it returns the system to text mode πŸ“Ί
  • it removes whatever mouse, keyboard, and timer routines have been installed πŸ‘‹

and here's the slay part: you don't normally need to bother making an explicit call to this function, because allegro_init() installs it as an atexit() routine, so it just gets called automatically when your program exits. no cap. it handles itself. main character energy honestly πŸ‘‘

πŸ’€ but wait, the warning. After you call this function, other functions like destroy_bitmap() will most likely crash. and that is a problem for C++ global destructors, because those usually get called after atexit(), so don't put Allegro calls in them. 😭

the fix tho? you can write the destructor code in another method, and manually call that method before your program exits β€” that avoids the whole problem entirely. iconic workaround, honestly. ✨


πŸ’– SEE ALSO πŸ’–


mwah πŸ’‹ that was the Allegro manual, version 4.4.3 β€” go forth and exit cleanly, bestie, and don't you dare put Allegro calls in a global destructor πŸŽ€βœ¨πŸ¦‹