create_light_table(3alleg4)
π create_light_table β bestie edition π
okay so you're deep in the Allegro manual, page create_light_table(3alleg4), and this is the Allegro game programming library we're talking about. no big deal. just your fave little function that fills a color mapping table so your sprites can get all glowy and moody. β¨
π SYNOPSIS π
#include <allegro.h>
void create_light_table(COLOR_MAP *table, const PALETTE pal, int r, g, b,
void (*callback)(int pos));
β¨ DESCRIPTION β¨
so basically, this function fills the color mapping table you hand it (table) with all the lookup data it needs to do lighting effects using the palette you also hand it (pal). π
here's the tea on how the lookup actually works. when you combine two colors β call them c1 and c2 β using this table, c1 gets treated as a light level from 0-255. so:
- at light level
255, the table spits outc2completely unchanged, like nothing happened, main character untouched π - at light level
0, it spits out ther,g,bvalues you specified when you called this function - at every level in between? it gives you a color that's somewhere between those two extremes. a lil gradient moment. π¦
and the r, g, and b values you pass in live in the range 0-63. not 0-255, bestie. sixty-three. don't forget. π«Ά
this function will also take advantage of the global rgb_ap variable to speed up color conversions β lowkey iconic of it honestly.
if the callback function is not NULL, it gets called 256 times during the calculation, which is your moment to show off a progress indicator and let the people know you're working. π
example time:
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(3alleg4)create_trans_table(3alleg4)create_color_table(3alleg4)create_blender_table(3alleg4)draw_trans_sprite(3alleg4)draw_lit_sprite(3alleg4)draw_gouraud_sprite(3alleg4)rgb_map(3alleg4)ex3d(3alleg4)exshade(3alleg4)extrans(3alleg4)
and that's the whole page, bestie!! this was Allegro, version 4.4.3, and the page itself is create_light_table(3alleg4). go build something gorgeous with it. no cap. πππ
π¦ 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