al_hold_bitmap_drawing(3alleg5)
π al_hold_bitmap_drawing π
okay bestie, welcome to the Allegro 5 API corner of the Allegro reference manual, where we make pixels go brrr. this one's about al_hold_bitmap_drawing, and honestly? it's giving "quiet little function, unhinged amounts of power" energy. π
β¨ NAME β¨
al_hold_bitmap_drawing β the Allegro 5 API function that lets you hold your bitmap drawing so it all goes down at once π₯
πΈ SYNOPSIS πΈ
#include <allegro5/allegro.h>
void al_hold_bitmap_drawing(bool hold)
π DESCRIPTION π
so basically this function turns deferred bitmap drawing on or off, and the whole point of it is efficiency. like, if you're drawing a ton of bitmaps that all share the same parent bitmap β think sub-bitmaps pulled out of a tilesheet, or just a bunch of identical bitmaps β this is how you make that fast. π¦
now, a lil reality check: drawing bitmaps that do not share a parent? lowkey less efficient. so the move is to stagger your bitmap drawing calls in a way that the parent bitmap stays the same across a big ol' batch of them. keep the fam together, yk? π
β οΈ while deferred bitmap drawing is enabled, the only functions you're allowed to use are the bitmap drawing functions and the font drawing functions. that's it. that's the list.
and it gets spicier: if you go changing state β stuff like the blending modes β while this is held? undefined behaviour. not "probably fine", not "eh, it'll work out", just straight-up undefined. do not do it, bestie, i'm begging π
one exception to that rule though, and it's iconic: the non-projection transformations. you can set a new transformation while the drawing is held. slay. β¨
also super important β and this is the part people sleep on β no drawing is guaranteed to take place until you disable the hold. none. zero. it's all just vibing in the queue until you let it go. so the classic idiom of this function's usage is:
- enable the deferred bitmap drawing
- draw as many bitmaps as you possibly can, taking care to stagger the ones that share parent bitmaps
- disable deferred drawing
and then everything actually happens. periodt. π
bonus: as mentioned above, this function also works with bitmap fonts and truetype fonts, so if you've got multiple lines of text to draw, this function can speed things up too. text girlies, you're included. ππ
π SEE ALSO π
al_is_bitmap_drawing_held(3alleg5)β the lil check-in function, so you can ask "are we holding rn?" π«Ά
and that's the whole page, bestie! Allegro reference manual, al_hold_bitmap_drawing, out. go forth and batch your bitmaps responsibly πβ¨π
π¦ where this page comes from
- debian trixie: allegro5-doc 2:5.2.10.1+dfsg-1 Β· Zlib
- ubuntu questing: allegro5-doc 2:5.2.10.1+dfsg-1build1
- ubuntu resolute: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- ubuntu stonking: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms