al_draw_soft_line(3)
π 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 to1if the step is a minor step, and0if this step is a major step. Minor steps are taken only either inxorydirections. Major steps are taken in both directions diagonally. In all cases, the absolute value of the change in coordinate is at most1in either direction βdrawβ called once per pixel. The function is expected to draw the pixel at the coordinates passed to it π₯
ngl bestie, thesteprules are the whole vibe check of this function β minor = one axis, major = diagonal, and never more than1of 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