Drawing NGons with OpenGL
Is OpenGL, given a series of points, able to 开发者_开发知识库fill in a polygon or is this only possible by creating lots of trianges? Thanks
Setting glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
should give you a filled polygon, as long as the vertices satisfy appropriate conditions (all the points have to be coplanar, and define a convex polygon, iirc).
You'd draw the polygon with the standard glBegin(GL_POLYGON)
, glVertex*(coords)
and then glEnd()
calls.
As long as the Ngons planar and convex, OpenGL handles them well. You'll have to triangulate the polygon yourself if it becomes concave (generally) or the polygon becomes non-planar and you want some algorithm for keeping it as non-generate as possible.
精彩评论