al_flip_display(3alleg5)

πŸ“¦
version 5.2.11.3 Β· 4 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’… al_flip_display β€” the Allegro 5 glow-up moment

okay bestie, so this one is from the Allegro 5 API (the Allegro reference manual, we stan) and it's literally the function that makes your drawing appear on screen. she's the moment. no cap.


✨ NAME ✨

al_flip_display β€” Allegro 5 API 🫢


🌸 SYNOPSIS 🌸

#include <allegro5/allegro.h>

void al_flip_display(void)

like. that's it. no args. she takes nothing and gives you everything πŸ’–


πŸ¦‹ DESCRIPTION πŸ¦‹

So what she does is: she copies or updates the front and back buffers, so that everything you've been drawing on the currently selected display actually becomes visible on screen. the glow-up from "hidden in the backbuffer" to "main character on your monitor" ✨

and here's the cute part β€” pointers to that special back buffer bitmap stay valid, and they keep all their back-buffer semantics, even though the contents may have changed. so don't panic, your pointer isn't ghosting you, she's just been through a little something πŸ™ˆ

note bestie: if you're not using the ALLEGRO_SINGLE_BUFFER option, you typically want to redraw every single pixel of the backbuffer bitmap, otherwise you get uninitialized memory artifacts. which is giving cursed. do not let it happen to you πŸ’€

πŸŽ€ how display options change her behaviour πŸŽ€

a bunch of display options lowkey change how this function acts, so let's vibe check them:

  • with ALLEGRO_SINGLE_BUFFER, no flipping is done at all. but you still have to call this function to display graphics, and how much that matters depends on how the graphics system you're using works. so like, call her anyway, she's doing her best πŸ’…
  • the ALLEGRO_SWAP_METHOD option may have extra info about what kind of operation is used internally to flip the front and back buffers. iykyk 🧚
  • if ALLEGRO_VSYNC is 1, this function will force waiting for vsync. if ALLEGRO_VSYNC is 2, this function will not wait for vsync. but here's the tea: with many drivers, the vsync behaviour is controlled by the user and not the application, so ALLEGRO_VSYNC will not be set. and in that case, al_flip_display will wait for vsync depending on the settings set in the system's graphics preferences. so it's giving "it depends" and honestly? valid 🌈

⭐ SEE ALSO ⭐


okay that's the whole page, go flip something iconic πŸ’œ

from the Allegro reference manual, all about al_flip_display(3alleg5) β€” mwah, take care of her, she's doing the lord's work for your framerate πŸŽ€βœ¨πŸ‘‘

πŸ“¦ where this page comes from