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 :-)
OpenGL can render only convex polygons, but many nonconvex polygons arise in practice. To draw these nonconvex polygons, you typically subdivide them into convex polygons—usually triangles, as shown in Figure 2-12—and then draw the triangles.
On the Wikipedia Polygon Triangulation Talk page I argue that more triangles will in fact be faster.
I have written a triangulation engine that supports holes and runs in O(n log (n)) time. I tested it under Gdk and then made an Android app from it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With