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.
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
Implement Chazelle's method. Triangulation in linear time! What's not to like? :)
More realistically, poly2tri.
GLU tesselators provide a flexible way to do this.
来源:https://stackoverflow.com/questions/7316000/convert-polygon-to-triangles