# How to triangulate.

Hello!

I’m having polygon with > 3 vertexes, How could i make it bunch of triangles?

I have had great luck with the GPC (Generic Polygon Clipping) library. I believe it also does triangulation. Why code something like this when you can just use the code?
http://www.cs.man.ac.uk/aig/staff/alan/software//index.html

You need help drawning more then one triangle?
Not sure what you are asking for.

Originally posted by runggu:
[b]Hello!

I’m having polygon with > 3 vertexes, How could i make it bunch of triangles?[/b]

One (not optimal) way which always works:
Create a new vertex in the middle of all vertices. Draw all triangles using 2 neighbouring vertices and the middle vertex.

What you can also do is choose one vertex of the polygon as the central vertex, and draw using 2 adjacent vertices and the chosen vertex

I know how to draw more than one triangle, i just want to know how to complex polygon to bunch of simple ones.

edotorpedo: That doesn’t work with reaally complex polygons(like shape of G)

Use a tesselation object. It’s made for just that cause: tesselation is triangulation.
Go look for gluNewTess() in the SDK

Ciao,

Niftybitz.

this is a classical computational geometry problem. look for “polygon triangulation” on google.
The basic idea of the common algorithm is to make trapezoids with your polygon, then cuting trapezoids accordingly (cut it in half anywhere if all its vertices are convex, otherwise cut it at the non-convex vertex). This works, providing your polygon is “simple” enougth (the G shape is).