2

GL_LINESで5つの角の星を描いています。GL_POLYGONを使用すると、星の形が歪んで最初と最後の頂点が接続されます。助けてください :( ?

4

3 に答える 3

5

最新のグラフィックス カードは 3D ポリゴンを描画できません。彼らは三角形だけを描きます。したがって、 を使用する場合GL_POLYGON、ドライバーはそれを三角形に分割する必要があります。あなたのケースでは、このプロセスが壊れている可能性があります。自分で三角形を作成することをお勧めします。あなたの場合、中心点を追加し、使用GL_TRIANGLE_FANして連続メッシュを作成します。

于 2009-11-11T17:39:00.553 に答える
2

For the specific case of a five-point star, Aaron's suggestion of using a triangle fan with a base vertex at the center works great! Note that a star is a concave polygon; GL_POLYGON can only render a convex polygon.

A number of general-purpose solutions exists for concave polygons. One is simply tessellating the poly into triangles on the CPU; you can use the gluTessBeginPolygon function for this if you're using GLU. If you'd like to avoid linking in the GLU library, you can find its source on the web and extract the relevant pieces.

The red book also describes a cool trick to quickly draw concave polygons using the stencil buffer and a plain old triangle fan. The stencil technique is really sweet, but it might be fancier than what you really need.

于 2009-11-11T19:22:11.233 に答える
1

OpenGL で GL_POLYGON を使用してレンダリングするには、ポイントが同一平面上にあり、結果のポリゴンが凸状である必要があります。あなたが説明した星は凸状ではないため、未定義の動作になります。

于 2009-11-14T03:12:12.937 に答える