create_light_table(3)
β¨ create_light_table(3) β¨
okay so bestie, we're deep in the Allegro manual today and this one is a banger. it's create_light_table, and it fills a color mapping table so you can do lighting effects. that's the whole vibe. Allegro game programming library, periodt. π
πΈ SYNOPSIS πΈ
#include <allegro.h>
void create_light_table(COLOR_MAP *table, const PALETTE pal, int r, g,
b, void (*callback)(int pos));
π DESCRIPTION π
So what this does: it fills the color mapping table you hand it (table) with lookup data for doing lighting effects using the palette you give it (pal). π
Now here's the tea about how the combining works. When you combine the colors c1 and c2 with this table, c1 gets treated as a light level from 0-255. and like:
- at light level 255, the table outputs color
c2totally unchanged (no cap, it's untouched π―) - at light level 0, it outputs the
r,g,bvalue you passed in to this function - at intermediate light levels, it outputs a color that's somewhere between those two extremes
and the r, g, and b values? those live in the range 0-63. yeah, 0-63, not 0-255, don't get it twisted. π
Also, this function is lowkey an overachiever: it'll take advantage of the global rgb_ap variable to speed up color conversions. glow up β¨
And if the callback function is not NULL, it gets called 256 times during the calculation, so you can show a progress indicator and let everyone know you're working. iconic behaviour honestly. π«Ά
Example, because we love a demonstration:
COLOR_MAP light_table;
...
/* Build a color lookup table for lighting effects. */
create_light_table(&light_table, pal, 0, 0, 0, NULL);
π¦ SEE ALSO π¦
color_map(3)create_trans_table(3)create_color_table(3)create_blender_table(3)draw_trans_sprite(3)draw_lit_sprite(3)draw_gouraud_sprite(3)rgb_map(3)ex3d(3)exshade(3)extrans(3)
okay that's the whole page, mwah π this came from the Allegro manual, and the version we're repping is version 4.4.3 β go forth and light up those sprites bestie, you ate π πβ
π¦ where this page comes from
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms