初始化Vector3数组时的StackOverFlowException

时间:2016-05-16 19:47:19

标签: c# opentk

我一直试图用VBO绘制犹他茶壶,每当我运行程序时,它会在我的茶壶类中抛出StackOverFlowException

我的茶壶课程:

public class Teapot
{
    Vector3[] teapot;
    int VBO_ID;
    public Teapot()
    {
        teapot = new Vector3[18960]
        {
            #region teapot vectors
            new Vector3(1.368074f, 2.435437f, -0.227403f),
            new Vector3(1.381968f, 2.400000f, -0.229712f),
            new Vector3(1.400000f, 2.400000f, 0.000000f),
            new Vector3(1.400000f, 2.400000f, 0.000000f),
            new Vector3(1.385925f, 2.435437f, 0.000000f),
            ...............
            #endregion
        };
        VBO_ID = GL.GenBuffer();
        GL.BindBuffer(BufferTarget.ArrayBuffer, VBO_ID);
        GL.BufferData<Vector3>(BufferTarget.ArrayBuffer, (IntPtr)(Vector3.SizeInBytes * teapot.Length), teapot, BufferUsageHint.StaticDraw);
        GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
    }

    public void DRAW_TEAPOT()
    {
        GL.EnableClientState(ArrayCap.VertexArray);
        GL.BindBuffer(BufferTarget.ArrayBuffer, VBO_ID);
        GL.VertexPointer(3, VertexPointerType.Float, Vector3.SizeInBytes,0);
        GL.DrawArrays(PrimitiveType.Triangles ,0, teapot.Length);
    }

}

有没有其他方法可以在我的程序中存储3D模型?

0 个答案:

没有答案