al_draw_soft_line(3)

πŸ“¦
version 5.2.11.3 Β· 3 versions
, in arch rolling

πŸ’… al_draw_soft_line

okay so real talk, bestie β€” this is from the Allegro 5 API, and it's the lowkey MVP of the primitives addon: it's the one that lets you do the pixel pushing. πŸŽ€


✨ NAME ✨

al_draw_soft_line β€” the Allegro 5 API function that draws a line with the software rasterizer and hands the per-pixel work off to functions you supply 🫢


🌸 SYNOPSIS 🌸

#include <allegro5/allegro_primitives.h>

void al_draw_soft_line(ALLEGRO_VERTEX* v1, ALLEGRO_VERTEX* v2, uintptr_t state,
   void (*first)(uintptr_t, int, int, ALLEGRO_VERTEX*, ALLEGRO_VERTEX*),
   void (*step)(uintptr_t, int),
   void (*draw)(uintptr_t, int, int))

πŸ’– DESCRIPTION πŸ’–

So what it does is draw a line using the software rasterizer plus user supplied pixel functions. It's giving "build your own shading routine" energy, fr fr. 🌈

If you want help understanding what these functions actually do, go peek at the implementation of the various shading routines in addons/primitives/line_soft.c β€” that's the blueprint, iykyk. πŸ‘‘

And the line is drawn top to bottom. Noted. πŸ’…

πŸ¦‹ Parameters πŸ¦‹

  • v1, v2 β€” the two vertices of the line πŸ’œ
  • state β€” a pointer to a user supplied struct; this struct gets passed to all the pixel functions. It's literally the main character carrying the context around πŸ‘‘
  • first β€” called before drawing the first pixel of the line. It gets passed the coordinates of this pixel, plus the two vertices above. Careful though: the passed vertices may have been altered by clipping πŸ™ˆ
  • step β€” called once per pixel. The second parameter is set to 1 if the step is a minor step, and 0 if this step is a major step. Minor steps are taken only either in x or y directions. Major steps are taken in both directions diagonally. In all cases, the absolute value of the change in coordinate is at most 1 in either direction ⭐
  • draw β€” called once per pixel. The function is expected to draw the pixel at the coordinates passed to it πŸ”₯
ngl bestie, the step rules are the whole vibe check of this function β€” minor = one axis, major = diagonal, and never more than 1 of movement per axis. Write that down. πŸ“

πŸŽ€ SEE ALSO πŸŽ€


and that's the whole page, bestie β€” no cap, every flag and every note intact πŸ’–βœ¨

signing off from the Allegro reference manual πŸ’« (source of all this wisdom, mwah) πŸ§šπŸ’œ

πŸ“¦ where this page comes from
  • arch rolling: allegro 5.2.11.3-2 Β· Zlib AND BSD-3-Clause AND OFL-1.1 AND LicenseRef-Custom
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms