draw_lit_sprite(3alleg4)
π draw_lit_sprite β bestie edition π
okay so you're in the Allegro manual, page 3alleg4, and today's main character is a little function called draw_lit_sprite β¨
π NAME π
draw_lit_sprite β draws a sprite, but make it tinted with a specific color π
straight from the Allegro game programming library, no cap.
β¨ SYNOPSIS β¨
#include <allegro.h>
void draw_lit_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y, int
color);
π¦ DESCRIPTION π¦
so here's the tea, and it depends on your color depth, okay? two whole situations:
In 256-color modes, it uses the global color_map table to tint the sprite image to the specified color, or to light it to the level specified by color β which one you get depends entirely on which function you used to build that table (create_trans_table or create_light_table, iykyk). Then it draws the resulting image onto the destination bitmap. π
In truecolor modes, it uses the blender functions to light the sprite image using the alpha level specified by color β and yes, the alpha level that was passed to the blender functions is ignored, so don't come for her about it π β then it draws the resulting image onto the destination bitmap.
the color parameter must be in the range [0-255] whatever its actual meaning is. like, whatever it's doing in there, the number itself has to live between 0 and 255. periodt.
π«Ά lowkey important: this must only be used after you have set up the color mapping table (for 256-color modes) or the blender functions (for truecolor modes). do it out of order and it's giving chaos, bestie.
example time, look at her:
/* Some one time initialisation code. */
COLOR_MAP global_light_table;
create_light_table(&global_trans_table, my_palette,
10, 10, 60, NULL);
...
if (get_color_depth() == 8)
color_map = &global_light_table;
else
set_trans_blender(40, 40, 255, 255);
/* Lit the cape with a blueish light. */
draw_lit_sprite(buffer, colored_cape, x, y, 64);
π SEE ALSO π
draw_sprite(3alleg4)draw_trans_sprite(3alleg4)draw_gouraud_sprite(3alleg4)draw_lit_rle_sprite(3alleg4)color_map(3alleg4)set_trans_blender(3alleg4)bitmap_mask_color(3alleg4)exblend(3alleg4)
and that's the whole vibe check π this was Allegro version 4.4.3, page draw_lit_sprite(3alleg4) β slay, go light up some sprites, mwah ππβ¨
π¦ where this page comes from
- debian bookworm: allegro4-doc 2:4.4.3.1-3 Β· Allegro-gift-ware
- debian trixie: allegro4-doc 2:4.4.3.1-5 Β· Allegro-gift-ware
- ubuntu jammy: allegro4-doc 2:4.4.3.1-2 Β· Allegro-gift-ware
- ubuntu noble: allegro4-doc 2:4.4.3.1-4.1build3 Β· Allegro-gift-ware
- ubuntu questing: allegro4-doc 2:4.4.3.1-6
- ubuntu resolute: allegro4-doc 2:4.4.3.1-7 Β· Allegro-gift-ware
- ubuntu stonking: allegro4-doc 2:4.4.3.1-9 Β· Allegro-gift-ware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms