iosopengl-espolygonconcave

Drawing a concave polygon in OpenGL


I have a concave polygon I need to draw in OpenGL.
The polygon is defined as a list of points which form its exterior ring, and a list of lists-of-points that define its interior rings (exclusion zones).

I can already deal with the exclusion zones, so a solution for how to draw a polygon without interior rings will be good too.

A solution with Boost.Geometry will be good, as I already use it heavily in my application.

I need this to work on the iPhone, namely OpenGL ES (the older version with fixed pipeline).

How can I do that?


Solution

  • Try OpenGL's tessellation facilities. You can use it to convert a complex polygon into a set of triangles, which you can render directly.

    EDIT (in response to comment): OpenGL ES doesn't support tessellation functions. In this case, and if the polygon is static data, you could generate the tessellation offline using OpenGL on your desktop or notebook computer.

    If the shape is dynamic, then you are out of luck with OpenGL ES. However, there are numerous libraries (e.g., CGAL) that will perform the same function.