• 2D
  • Creating a "Donut" polygon, i.e., cutting a polygon out of another polygon.

What's the best way to create a 2D filled polygon with a "cut-out" shape in the middle? Like a donut, but the shapes can be arbitrary?

2 months later

I'm wondering the same thing and couldn't reach a definite answer. However, this article from the docs may provide a guide. It has an example in which a drawing function is defined. Maybe similar functions can be defined for other polygons? Or maybe it can be told only to draw an intersection of specific areas or shapes? Please share your experiences if you happen to find an answer, I will experiment with this as well.

Well, as you might be aware gpu's only really draw(rasterize) triangles so you obviously wont be able to then cut one triangle out of another as a hole, at least not without producing more than one triangle surrounding the hole.

In terms of fragments/pixels however it is possible to do pixel processing so that one triangles rasterized fragments would mask off a portion of another.