al_draw_soft_triangle(3)

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

πŸ’– al_draw_soft_triangle(3) πŸ’–

okay so this page is from the Library Functions Manual β€” specifically the Allegro 5 API situation β€” and it's all about letting the software rasterizer draw a triangle while you supply the pixel functions. bestie, it's giving build-your-own-shading-routine energy ✨

🌸 NAME 🌸

al_draw_soft_triangle β€” Allegro 5 API

🫢 SYNOPSIS 🫢

#include <allegro5/allegro_primitives.h>

void al_draw_soft_triangle(
   ALLEGRO_VERTEX* v1, ALLEGRO_VERTEX* v2, ALLEGRO_VERTEX* v3, uintptr_t state,
   void (*init)(uintptr_t, ALLEGRO_VERTEX*, ALLEGRO_VERTEX*, ALLEGRO_VERTEX*),
   void (*first)(uintptr_t, int, int, int, int),
   void (*step)(uintptr_t, int),
   void (*draw)(uintptr_t, int, int, int))

πŸ’… DESCRIPTION πŸ’…

Draws a triangle using the software rasterizer and user supplied pixel functions. For help in understanding what these functions do, see the implementation of the various shading routines in addons/primitives/tri_soft.c.

The triangle is drawn in two segments, from top to bottom. The segments are deliniated by the vertically middle vertex of the triangle. One of the two segments may be absent if two vertices are horizontally collinear.

πŸŽ€ Parameters πŸŽ€

  • v1, v2, v3 β€” The three vertices of the triangle.
  • state β€” A pointer to a user supplied struct; this struct will be passed to all the pixel functions.
  • init β€” Called once per call before any drawing is done. The three points passed to it may be altered by clipping.
  • first β€” Called twice per call, once per triangle segment. It is passed 4 parameters: the first two are the coordinates of the initial pixel drawn in the segment. The second two are the left minor and the left major steps, respectively. They represent the sizes of two steps taken by the rasterizer as it walks on the left side of the triangle. From then on, each step will either be classified as a minor or a major step, corresponding to the above values.
  • step β€” Called once per scanline. The last parameter is set to 1 if the step is a minor step, and 0 if it is a major step.
  • draw β€” Called once per scanline. The function is expected to draw the scanline starting with a point specified by the first two parameters (corresponding to x and y values) going to the right until it reaches the value of the third parameter (the x value of the end point). All coordinates are inclusive.

πŸ‘€ SEE ALSO πŸ‘€

xoxo, the Allegro reference manual β€” page al_draw_soft_triangle(3) β€” no date listed, and honestly that's fine πŸ’–

πŸ“¦ 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