draw_gouraud_sprite(3alleg4)

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

okay so this is draw_gouraud_sprite, and it lives in the Allegro game programming library manual, section 3alleg4. she's a real one. let's get into it 🫢


✨ NAME ✨

draw_gouraud_sprite β€” draws a sprite with gouraud shading, fr fr. Allegro game programming library. that's the whole vibe. πŸ’–


🌸 SYNOPSIS 🌸

#include <allegro.h>

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

like, six params. she's high maintenance but she serves. πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

so draw_gouraud_sprite is the glow-up version of draw_lit_sprite(). it's giving "same girl but she went to the salon". πŸ’…

here's the tea: the color parameter is not constant across the sprite image anymore. instead, it gets interpolated between the four specified corner colors. so each of the four corners of your sprite gets its own lil color value, and everything in between just smoothly blends. it's giving gradient. it's giving ✨ambiance✨.

the corner values you pass in indicate the strength of the color applied on them, and they range from:

  • 0 β€” no strength (basically nothing, she's unbothered)
  • 255 β€” full strength (maxed out, main character energy πŸ”₯)

anywhere in between is fair game. go off. 😌

example time, bestie:

/* 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 the enemies being in shadow unless lit by torch 😭 iconic concept actually. the four light_strength_on_corner_N values are exactly those c1 c2 c3 c4 params from the synopsis, so like, that's where the corner strength numbers go. slay. 🌟


πŸ‘‘ SEE ALSO πŸ‘‘


πŸŽ€ sign-off πŸŽ€

this page is from Allegro, version 4.4.3, and it's the draw_gouraud_sprite(3alleg4) manual page. that's it, that's the whole thing. go shade some sprites bestie, you're gonna eat πŸ’–βœ¨πŸ¦‹πŸŒΈπŸ’…πŸ«ΆπŸŒˆβ­πŸ‘‘