draw_gouraud_sprite(3)

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

πŸ’… draw_gouraud_sprite β€” Allegro manual, page 3, bestie edition

okay so we're in the Allegro manual today and the function on the docket is draw_gouraud_sprite(3). she's a glow-up function. literally. ✨


✨ NAME ✨

draw_gouraud_sprite β€” draws a sprite with gouraud shading, courtesy of the Allegro game programming library. πŸŽ€


🌸 SYNOPSIS 🌸

#include <allegro.h>

void draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y, int c1, int c2, int c3, int c4);

πŸ’– DESCRIPTION πŸ’–

so draw_gouraud_sprite() is the fancier, more sophisticated sibling of draw_lit_sprite(). the glow-up? the color parameter is not constant across the sprite image anymore. nope. instead it gets interpolated between the four corner colors you hand her. it's giving gradient. it's giving ✨dimension✨.

the corner values you pass in tell her the strength of the color applied on each corner, and the range is:

  • 0 β€” no strength at all, babes. zero. nada.
  • 255 β€” full strength. maxed out. πŸ’―

and obvs anything in between is fair game.

here's the example, straight from the source, no notes:

/* Some one time initialisation code. */
COLOR_MAP global_light_table;
create_light_table(&global_trans_table, my_palette,
                   0, 0, 0, NULL);
...
if (get_color_depth() == 8)
   color_map = &global_light_table;
else
   set_trans_blender(0, 0, 0, 128);

/* Enemies are in shadow unless lit by torch. */
draw_gouraud_sprite(buffer, menacing_spy, x, y,
                    light_strength_on_corner_1,
                    light_strength_on_corner_2,
                    light_strength_on_corner_3,
                    light_strength_on_corner_4);
not me crying over menacing_spy in the shadows until a torch finds him 😭 the atmospheric lighting is immaculate, no cap.

πŸ¦‹ SEE ALSO πŸ¦‹


and that's the whole page, bestie, you ate it. 🫢 this was Allegro, version 4.4.3, and yes the footer says draw_gouraud_sprite(3) again because she's the main character and she knows it. πŸ‘‘πŸ’œ

πŸ“¦ where this page comes from