al_draw_fille...gon_with_holes(3alleg5)
π al_draw_filled_polygon_with_holes β the Allegro 5 API page, but make it cute π
okay so bestie, you opened the 3alleg5 manual (that's the Allegro 5 reference manual, in case the vibe check needed clarifying) and landed on al_draw_filled_polygon_with_holes. Sit down, hydrate, we're drawing shapes with β¨holesβ¨ in them.
β¨ NAME β¨
al_draw_filled_polygon_with_holes β it's the Allegro 5 API, and it's giving "filled polygon but make it hollow" π
πΈ SYNOPSIS πΈ
#include <allegro5/allegro_primitives.h>
void al_draw_filled_polygon_with_holes(const float *vertices,
const int *vertex_counts, ALLEGRO_COLOR color)
π DESCRIPTION π
So basically it draws a filled simple polygon, and then it subtracts zero or more other simple polygons from it β those subtracted ones are the holes. Iconic. But listen: the holes cannot touch or intersect with the outline of the filled polygon. Not even a little. Not even a pinky toe. π«Ά
Here's the tea on the three args:
verticesβ an interleaved array of(x, y)vertex coordinates, covering every one of the polygons, holes included. Interleaved means x, y, x, y, x, y, no cap.vertex_countsβ how many vertices each polygon has. The count for the filled polygon lives atvertex_counts[0]and must be at least three. Everything after that tells you how many vertices each hole has. And the array must be terminated with an element whose value is zero. That zero is the little "we're done here" bow π.colorβ the color of the filled polygon. Obviously. π
Now the geometry rules, and bestie these matter:
When the y-axis is facing downwards (which is the usual case), the filled polygon's coordinates must be ordered anti-clockwise. All the hole vertices must use the opposite order β that's clockwise when y is down. Also every hole vertex must be inside the main polygon, and no hole may overlap the main polygon. Rules are rules. π
For example:
float vertices[] = {
0, 0, // filled polygon, upper left corner
0, 100, // filled polygon, lower left corner
100, 100, // filled polygon, lower right corner
100, 0, // filled polygon, upper right corner
10, 10, // hole, upper left
90, 10, // hole, upper right
90, 90 // hole, lower right
};
int vertex_counts[] = {
4, // number of vertices for filled polygon
3, // number of vertices for hole
0 // terminator
};
So there are 7 vertices total: four of them make an outer square going from (0, 0) to (100, 100) in anti-clockwise order, and the other three make an inner triangle in clockwise order. The outer main polygon uses vertices 0 to 3 (inclusive), and the hole uses vertices 4 to 6 (inclusive). Math ate and left no crumbs π₯
β SINCE β
5.1.0 β vintage but still slaying π«
π¦ SEE ALSO π¦
al_draw_filled_polygon(3alleg5)al_draw_filled_polygon_with_holes(3alleg5)al_triangulate_polygon(3alleg5)
not this page recommending itself in SEE ALSO π honestly? self-love. we support it. π
and that's the whole page, bestie β straight from the Allegro reference manual, page al_draw_fille...gon_with_holes(3alleg5), 3alleg5 era. go forth and punch some holes in your polygons πβ¨ππ¦πΈπ
π«Ά
π¦ where this page comes from
- debian trixie: allegro5-doc 2:5.2.10.1+dfsg-1 Β· Zlib
- ubuntu questing: allegro5-doc 2:5.2.10.1+dfsg-1build1
- ubuntu resolute: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- ubuntu stonking: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms