al_triangulate_polygon(3alleg5)

πŸ“¦
version 5.2.11.3 Β· 4 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– al_triangulate_polygon β€” Allegro 5 API πŸ’–

okay bestie, welcome to the 3alleg5 page for al_triangulate_polygon ✨ this is the Allegro 5 API and she is ready to slice your polygons into lil triangle confetti πŸŽ€


✨ SYNOPSIS ✨

#include <allegro5/allegro_primitives.h>

bool al_triangulate_polygon(
   const float* vertices, size_t vertex_stride, const int* vertex_counts,
   void (*emit_triangle)(int, int, int, void*), void* userdata)

πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the vibe: this function takes one simple polygon and chops it up into triangles πŸ”ΊπŸ”ΊπŸ”Ί β€” and you can also subtract zero or more other simple polygons from it, and those subtracted ones are the holes. The holes are like, "not me being a void in your shape πŸ’€" and the main polygon is like "periodt".

⚠️ real talk though: the holes cannot touch or intersect with the outline of the main polygon. Like, zero contact. Don't even try it πŸ™ˆ

And when we say simple, we mean the polygon does not have to be convex (she can be as lumpy as she wants, we love her for that πŸ’…), but it must not be self-overlapping. Self-overlapping is giving chaos and we don't do that here.

🌸 Parameters 🌸

  • vertices β€” an interleaved array of (x, y) vertex coordinates, for every single one of the polygons, holes included. Everybody's in the same array, no cap 🫢
  • vertex_stride β€” the distance, in bytes, between successive pairs of vertices in that array. It's giving "how far apart are your besties standing" πŸ’«
  • vertex_counts β€” how many vertices each polygon has. The main polygon's vertex count lives at vertex_counts[0] and it must be at least three (a triangle is the bare minimum, you can't have a shape with two points, bestie 😭). Every element after that says how many vertices each hole has. And the whole array must be terminated with an element with value zero β€” that zero is the little "k that's it, we're done here" πŸŽ€
  • emit_triangle β€” a function that gets called for every set of three points that form a triangle. She receives the indices of the points in vertices, plus userdata. Iconic callback energy πŸ‘‘
  • userdata β€” arbitrary data that gets passed straight through to emit_triangle. Whatever you want, it's yours, she won't judge πŸ’œ

⭐ SINCE ⭐

5.1.0 β€” yes she's been around, she's a legend 🌈


πŸ‘€ SEE ALSO πŸ‘€


mwah πŸ’‹ that's the whole page! This was the Allegro reference manual, page al_triangulate_polygon(3alleg5) β€” go forth and triangulate, bestie, you're gonna slay πŸ”₯πŸ‘‘πŸ’…

πŸ“¦ where this page comes from