al_draw_filled_polygon(3)
π al_draw_filled_polygon(3) π
okay so bestie, welcome to the <allegro_primitives.h> corner of the Library Functions Manual β this is the Allegro 5 API primer on filling in shapes, and honestly? it slays. let's get into it π
β¨ SYNOPSIS β¨
#include <allegro5/allegro_primitives.h>
void al_draw_filled_polygon(const float *vertices, int vertex_count,
ALLEGRO_COLOR color)
that's the whole vibe right there β three little args and you're drawing. π
πΈ DESCRIPTION πΈ
okay so this one draws a filled, simple polygon. and "simple" here is doing a LOT of work, so let's be clear about what it means: the polygon does not have to be convex (so no worries, you don't have to be all well-behaved and bulgey), but it must not be self-overlapping. like, at all. self-overlap is not the move, it's giving chaos, it's giving undefined-adjacent behavior energy π β so keep your edges from crossing each other, periodt.
your three arguments, bestie:
verticesβ interleaved array of(x, y)vertex coordinates β¨ (yes, interleaved β x then y then x then y, do not try to be cute and split them into two arrays, that's not what she asked for)vertex_countβ number of vertices in the array π’colorβ color of the filled polygon π¨
and here's the part you CANNOT skip, iykyk: when the y-axis is facing downwards (which is the usual, the normal situation, the standard vibe), the coordinates must be ordered anti-clockwise. π not clockwise, not "whatever feels right" β anti-clockwise. the winding order is the main character here and you WILL respect her.
β SINCE β
5.1.0 β she's been iconic since 5.1.0, no cap π«Ά
π¦ SEE ALSO π¦
al_draw_polygon(3)β for when you want the outline only, no fill, lowkey the thinner sisteral_draw_filled_polygon_with_holes(3)β for when your polygon has β¨loreβ¨ (holes, specifically)
and that's the page!! π go forth and fill your simple, non-self-overlapping, anti-clockwise polygons, bestie, you're gonna eat π₯
fr fr keep that winding order correct or your shape will simply not be the shape you wanted, and that's on the y-axis facing downwards π
al_draw_filled_polygon(3) β Allegro reference manual π§ββοΈ (the footer's just the manual name, no date on this one, that's all she wrote) π
π¦ 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