fli_bmp_dirty_from(3alleg4)

πŸ’– fli_bmp_dirty_from β€” bestie edition πŸ’–

okay so this is a page from the Allegro manual (that's 3alleg4, the Allegro game programming library, and we're in the FLI section, iykyk) πŸ’…


✨ NAME ✨

fli_bmp_dirty_from, fli_bmp_dirty_to β€” these two tell you which parts of the image have actually changed. part of the Allegro game programming library. periodt. πŸŽ€


🌸 SYNOPSIS 🌸

#include <allegro.h>

extern int fli_bmp_dirty_from;

extern int fli_bmp_dirty_to;

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so listen, these two variables get set by next_fli_frame(), and what they do is tell you which part of the fli_bitmap has changed since the last time somebody called reset_fli_variables(). that's it, that's the whole job 🫢

here's the vibe check:

  • if fli_bmp_dirty_from is greater than fli_bmp_dirty_to β†’ bestie, nothing changed, the bitmap is untouched, go home 🌈
  • otherwise β†’ lines fli_bmp_dirty_from to fli_bmp_dirty_to (inclusive, don't forget that part πŸ’€) have altered

so when you're copying the fli_bitmap onto the screen, you can use these to avoid moving data unnecessarily. no need to haul the whole bitmap across town when only a few lines are different, that's just wasteful and we don't do that here πŸ’…

the example, verbatim, no notes:

if (fli_bmp_dirty_from <= fli_bmp_dirty_to)
   blit(fli_bitmap, screen, 0, fli_bmp_dirty_from,
        0, fli_bmp_dirty_from, fli_bitmap->w,
        fli_bmp_dirty_to - fli_bmp_dirty_from + 1);

not me obsessed with a two-variable dirty rectangle system 😭 iconic honestly


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page bestie, go forth and blit responsibly 🧚✨

mwah πŸ’– this was Allegro, version 4.4.3, and yeah it's the fli_bmp_dirty_from(3alleg4) page, thanks for coming to my ted talk, ily, bye πŸŽ€