12

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.

user1118321
  • 25,567
  • 4
  • 55
  • 86
Laurent Crivello
  • 3,809
  • 6
  • 45
  • 89
  • 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 Answers3

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
0

GLU tesselators provide a flexible way to do this.

Jens Ayton
  • 14,532
  • 3
  • 33
  • 47