I just started learning openGL for an application that I am working on. My task is to draw a polygon that can be:
- texture filled
The outlined polygon is simple with the primType GL_LINE_STRIP. When i try to draw things of the GL_POLYGON primType my object does not render correctly at all. Any suggestions to why this is happenening?
You can only render convex polygons with GL_POLYGON.
I’d recommend using GL_TRIANGLES or, even better, GL_TRIANGLE_STRIP. The latter requires a special geometry layout called a triangle strip, though (see this wikipedia article), and not all polygons can be made into such strips.
The code at the link below does what you are trying to do. Maybe by looking at this code you’ll be able to figure out what you did wrong? Good luck.
Triangle Demo Source Code
anything other then triangles are not optimized well on hardware, that is anything else has to be split up into subtriangles. even lines are rendered with two triangles on some cards. i would forget about GL_POLYGON and use TRIANGLES only and you can render convex and concave geometry.