예제 #1
0
        private static void DrawBuffered([NotNull] VertexBuffer vertexBuffer, [NotNull] IndexBuffer indexBuffer, uint startIndex, uint elementCount)
        {
            Debug.Assert(elementCount % 3 == 0);

            vertexBuffer.Activate();
            indexBuffer.Activate();

            GL.EnableVertexAttribArray(0);
            GL.EnableVertexAttribArray(1);

            GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 6 * sizeof(float), IntPtr.Zero);
            GL.VertexAttribPointer(1, 3, VertexAttribPointerType.Float, false, 6 * sizeof(float), IntPtr.Zero + 3 * sizeof(float));

            GL.DrawElements(BeginMode.Triangles, (int)elementCount * 3, DrawElementsType.UnsignedInt, (int)startIndex * sizeof(uint));

            GL.DisableVertexAttribArray(0);
            GL.DisableVertexAttribArray(1);

            GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
            GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
        }