Search code examples
iphoneopengl-espolygontessellation

OpenGL ES - How to Draw a filled Polygon?


I tried googling and searching on stack but I didn't find anything :-(
( Mapping irregular shapes or other polygons (cartoons, sprites) to triangles in OpenGL ES )

I want to draw a filled polygon in OpenGL ES on iPad (2D, don't need 3D) (I'm new to OpenGL && OpenGL ES) It seems simple on OpenGL but with ES with just can draw triangle.

But I can't find any good tutorial about this :-( Does it exist any wrapper / library or anything else that could help me ?

I don't want to use CoreGraphics, it's too slow for what I'm doing ^^
And if possible, avoiding too (big) library like Cocos2D.

Edit : Working On the Problem, here are some useful links (will edit)
Links
- Polygon Triangulation
http://www.vterrain.org/Implementation/Libs/triangulate.html
http://en.wikipedia.org/wiki/Polygon_triangulation (WIKI) http://www.flipcode.com/archives/Efficient_Polygon_Triangulation.shtml (polygon WITHOUT holes) http://www.cs.unc.edu/~dm/CODE/GEM/chapter.html (polygon WITH holes, C code)

Solution
I will try using polygon tessellation to get triangles. At first I'm going to try ( http://www.flipcode.com/archives/Efficient_Polygon_Triangulation.shtml ) and as I need polygon with holes, the second one ( http://www.cs.unc.edu/~dm/CODE/GEM/chapter.html ). If anyone has a better way, PLEASE, tell me with a comment ^^

Thanks :-)


Solution

  • Cocos2D is cool library wrapping OpenGL and has many useful features ( mainly for games but not limited to ).

    For polygon tessellation use : http://flipcode.net/archives/Efficient_Polygon_Triangulation.shtml I've used it before and it worked well.