OpenTK - VBO - 应用程序崩溃

OpenTK - VBO - Application crash

我正在学习 OpenGL(使用 OpenTK)。今天我想使用 VBO 来有效地渲染我的四边形。 当我调用渲染时它崩溃

=================================================================
Got a SIGSEGV while executing native code. This usually indicates a fatal error in the mono runtime or one of the native libraries used by your application.
=================================================================

Full stacktrace can be found here

这是我的渲染代码:

GL.EnableVertexAttribArray(0);

GL.BindBuffer(BufferTarget.ArrayBuffer, _vbo);
GL.VertexAttribPointer(0, _count, VertexAttribPointerType.Float, false, 0, 0);

GL.DrawArrays(PrimitiveType.Quads, 0, _count);

GL.DisableVertexAttribArray(0);

这就是我生成缓冲区的方式。

GL.GenBuffers(1, out _vbo);
GL.BindBuffer( BufferTarget.ElementArrayBuffer, _vbo );

Vector3[] vertices;
_count = vertices.Length;

GL.BufferData<Vector3>(BufferTarget.ArrayBuffer, new IntPtr(vertices.Length * Vector3.SizeInBytes), vertices, BufferUsageHint.StaticDraw);

PS:我没有为此使用任何颜色或纹理。

将渲染代码更改为此

        GL.BindBuffer( BufferTarget.ArrayBuffer, _vbo );
        GL.VertexPointer (3, VertexPointerType.Float, Marshal.SizeOf(new Vector3()), IntPtr.Zero);
        GL.EnableClientState (ArrayCap.VertexArray);

        GL.DrawArrays(PrimitiveType.Quads, 0, _count);

        GL.DisableClientState (ArrayCap.VertexArray);

它奏效了。 我到处都使用 BufferTarget.ArrayBuffer(ElementArrayBuffer 用于索引)。