Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 :-)

like image 369
Vinzius Avatar asked Oct 06 '10 12:10

Vinzius


People also ask

What kind of polygons can OpenGL draw?

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.


1 Answers

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.

like image 87
Nic Roets Avatar answered Sep 25 '22 00:09

Nic Roets