get_compiled_sprite(3alleg4)

✨ get_compiled_sprite ✨

okay bestie, welcome to the Allegro manual β€” this one's get_compiled_sprite(3alleg4), and it's giving compiled sprite energy πŸ’–


🌸 NAME 🌸

get_compiled_sprite β€” makes you a compiled sprite, using a bitmap as the source. It's part of the Allegro game programming library, no cap. πŸ‘‘


πŸŽ€ SYNOPSIS πŸŽ€

#include <allegro.h>

COMPILED_SPRITE *get_compiled_sprite(BITMAP *bitmap, int planar);

πŸ’… DESCRIPTION πŸ’…

So basically, this function creates a compiled sprite based on the bitmap you hand it β€” and heads up, that bitmap must be a memory bitmap, fr fr, no exceptions. πŸ™ˆ

Compiled sprites are device-dependent, which means you have to tell it whether you want it compiled into a linear format or a planar format. The way you do that is with the second parameter:

  • pass FALSE if you're gonna be drawing it onto memory bitmaps, mode 13h, or SVGA screen bitmaps
  • pass TRUE if you're gonna be drawing it onto mode-X or Xtended mode screen bitmaps

Choose wrong and it's not gonna slay for you, so pick wisely bestie. ✨

Here's the whole vibe in an example:

COMPILED_SPRITE *cspr;
BITMAP *bmp;
...
/* Create compiled sprite from an existent bitmap. */
cspr = get_compiled_sprite(bmp, 0);
if (!cspr)
   abort_on_error("Couldn't create compiled sprite!");

/* We don't need the bitmap any more.*/
destroy_bitmap(bmp);

/* Use the compiled sprite. */
...
/* Destroy it when we don't need it any more. */
destroy_compiled_sprite(cspr);

It returns a pointer to the compiled sprite it just made, or NULL if it couldn't be created at all. 😭 And listen β€” remember to free this compiled sprite later to avoid memory leaks. Don't be the girl who leaks memory, that's not the vibe. 🫢


πŸ¦‹ SEE ALSO πŸ¦‹


and that's the whole page, periodt πŸ’œ β€” this was Allegro, version 4.4.3, bringing you get_compiled_sprite(3alleg4). go compile something iconic, bestie πŸŽ€β­πŸ”₯