-1
我正在學習OpenGL(使用OpenTK)。今天我想用VBO來有效地渲染我的四邊形。 當我打電話使其崩潰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:我沒有使用任何顏色或紋理。
我不確定,但你不是初始化數組「Vector3 []頂點;」。此外,您將緩衝區初始化爲「BufferTarget.ElementArrayBuffer」,但將數據放入「BufferTarget.ArrayBuffer」中。以及您使用的OpenGL版本,因爲從一些更新的版本開始,您也必須使用Vertex Arrays。 – Michael
@Michael頂點被定義(我把它從我的代碼中刪除,其中是生成器)。我試圖將BufferTarget更改爲相同的值(對於這兩個值),但仍然無法工作。 – AbitDeveloper