public static void Draw(BeginMode beginMode, PositionColor[] vertexData)
{
int primativeCount;
switch (beginMode)
{
case BeginMode.Triangles: primativeCount = vertexData.Length / 3; break;
case BeginMode.TriangleStrip: primativeCount = vertexData.Length - 2; break;
default: throw new ArgumentException();
}
if (primativeCount == 0) return;
GL.EnableClientState(EnableCap.VertexArray);
GL.EnableClientState(EnableCap.ColorArray);
shader.Use();
unsafe
{
fixed (float* pData = &vertexData[0].x)
{
GL.VertexPointer(3, VertexPointerType.Float, PositionColor.stride, (IntPtr)pData);
GL.ColorPointer(3, ColorPointerType.Float, PositionColor.stride, (IntPtr)(pData + 3));
GL.DrawArrays(beginMode, 0, vertexData.Length);
}
}
GL.DisableClientState(EnableCap.VertexArray);
GL.DisableClientState(EnableCap.ColorArray);
//GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
//GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
}
}