何が悪いのかわかりました。sizeof(array)
私の使い方が間違っていたことが判明しました。(具体的には、以下のコードを参照して、を使用する代わりに、単純にi < numCurves
実行しようとしましたi < sizeof(points)
)
したがって、4 ~ 5 点を描画する代わりに、192 の曲線を描画することになり、奇妙な結果になりました。中央のひし形は、開始点に接続していないためです。これをやりたいと思っている将来の人々の参考のために、コードは次のとおりです。
誤った画像:
誤った画像 http://img535.imageshack.us/img535/8207/failfd.png
最終製品:
最終製品 http://img685.imageshack.us/img685/7641/finalsa.png
void drawIrregularPolygon(GLfloat points[][4][3], int numCurves)
// REQUIRES: GLfloat points to be a polygon and center of circle to be current matrix
// EFFECTS: An irregular shape would be drawn
{
for (int i = 0; i < numCurves; i++)
{
glMap1f( GL_MAP1_VERTEX_3, 0.0f, 1.0f, 3, 4, &points[i][0][0] );
glBegin(GL_POLYGON); //replace GL_POLYGON with GL_LINE_STRIP if you need outline
for (int j = 0; j <= TOTAL_SEGMENTS; j++)
glEvalCoord1f((GLfloat) j / TOTAL_SEGMENTS);
glVertex2f(points[0][0][0], points[0][0][1]);
glEnd();
}
}