fli_bmp_dirty_from(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

πŸ’– fli_bmp_dirty_from, fli_bmp_dirty_to πŸ’–

okay bestie, so this is from the Allegro manual (yes, the game programming library, the one that lives in fli_bmp_dirty_from(3)) and it's genuinely such a small page but it's SO useful, i promise 🫢


✨ NAME ✨

fli_bmp_dirty_from, fli_bmp_dirty_to β€” literally just telling you which parts of the image have changed. that's it. that's the whole job. Allegro game programming library, periodt πŸ’…


🌸 SYNOPSIS 🌸

#include <allegro.h>

extern int fli_bmp_dirty_from;

extern int fli_bmp_dirty_to;

two lil extern int globals, living their best life 🌈


πŸ¦‹ 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(). iconic behaviour honestly πŸ‘‘

here's the vibe check on the logic:

  • if fli_bmp_dirty_from is greater than fli_bmp_dirty_to β†’ the bitmap has not changed. nothing happened. it's giving "no thoughts, head empty" πŸ’€
  • otherwise β†’ lines fli_bmp_dirty_from to fli_bmp_dirty_to (inclusive, bestie, don't forget the inclusive part) have altered.

so when are these actually useful?? when you're copying the fli_bitmap onto the screen!! because why would you move data you don't need to move?? that's just wasted effort and we don't do that here πŸ’… avoid moving data unnecessarily, slay.

example time, and i mean the exact example, no cap:

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);

look at that guard clause doing its little <= check before it even thinks about blitting. main character energy fr fr ✨


πŸ‘€ SEE ALSO πŸ‘€

go read those too, iykyk πŸŽ€


lowkey this is one of those pages that's short but you WILL come back to it, so maybe bookmark it or whatever πŸ™ˆ

and that's the whole page!! mwah πŸ’œ this has been the Allegro manual, version 4.4.3, and yeah that's the date it was working with β€” catch you on the next manpage, bestie πŸ¦‹βœ¨πŸ’–

πŸ“¦ where this page comes from