Triangulate a polygon

Monkey Forums/Monkey Code/Triangulate a polygon

JIM(Posted 2011) [#1]
Hello!

Here's a piece of code that handles turning a concave polygon into triangles in order for it to be drawn correctly.

You may not see the difference in the test app in HTML5 (I think it might have something similar already embedded) but it's definitely visible in GLFW.

IMPORTANT NOTE: It only works with simple polygons (no holes and no crossing of edges).

You may want to replace this with a simple DrawPoly on HTML5 to save the computation (also due to antialiasing some seams are visible).

Enjoy!