How can I draw a concave shape using the mode GL_POLYGON? As I learned GL_POLYGON is defiened for convex shapes
GL_POLYGON
Draws a single, convex polygon. Vertices 1 through N define this polygon.
A bit longer answer. You probably do not want to avoid using GL_POLOYGON
since it is deprecated
And as cmaughan is discussing, you might want to tesselate (render all triangles separately instead). I just want to add that you could use GL_TRIANGLE_FAN
to do some special cases of convex shapes. Like so:
Note that this approach is not at all generalizable for all convex shape and you probably just want to render your shape as separate triangales instead.
Short answer: you can't. You have to dice up the polygon into convex sections. There are geometry libraries that will do this for you. Usually you will dice up the concave shape into triangles.
Here is one example: https://github.com/memononen/libtess2
The reason it is not supported is because this is not typically something the GPU can do for you. The API maps to the hardware for the most part.