In order to create a VBO in OpenGl, I need to convert polygons to triangles. Is there an example of script/code somewhere that would describe this ? I would need something robust for convex and concave polygons.
Asked
Active
Viewed 1.2k times
12
-
I untagged this [cocoa] and tagged it [c] because I don't think it's a Cocoa question (or even an Objective-C question). – paulmelnikow Sep 11 '11 at 20:30
-
for those of you who need an implementation and not a pdf or description: https://github.com/mapbox/earcut – viggity Jan 10 '19 at 22:30
3 Answers
16
Ear clipping is by far the best way to do this.
It is fully robust for both convex and concave polygons and runs in O(n^2) time

Hannesh
- 7,256
- 7
- 46
- 80
6
Implement Chazelle's method. Triangulation in linear time! What's not to like? :)
More realistically, poly2tri.

genpfault
- 51,148
- 11
- 85
- 139