开发者

Drawing NGons with OpenGL

开发者 https://www.devze.com 2022-12-29 08:12 出处:网络
Is OpenGL, given a series of points, able to 开发者_开发知识库fill in a polygon or is this only possible by creating lots of trianges?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消