public void GenerateBuffers()
{
if (VertexData != null)
{
GL.GenBuffers(1, out VertexBufferID);
GL.BindBuffer(BufferTarget.ArrayBuffer, VertexBufferID);
GL.BufferData<Vector3>(BufferTarget.ArrayBuffer,
new IntPtr(VertexData.Length * Vector3.SizeInBytes),
VertexData, BufferUsageHint.StaticDraw);
}
if (NormalData != null)
{
GL.GenBuffers(1, out NormalBufferID);
GL.BindBuffer(BufferTarget.ArrayBuffer, NormalBufferID);
GL.BufferData<Vector3>(BufferTarget.ArrayBuffer,
new IntPtr(NormalData.Length * Vector3.SizeInBytes),
NormalData, BufferUsageHint.StaticDraw);
}
if (ColorData != null)
{
GL.GenBuffers(1, out ColorBufferID);
GL.BindBuffer(BufferTarget.ArrayBuffer, ColorBufferID);
GL.BufferData<int>(BufferTarget.ArrayBuffer,
new IntPtr(ColorData.Length * sizeof(int)),
ColorData, BufferUsageHint.StaticDraw);
}
if (IndicesData != null)
{
GL.GenBuffers(1, out IndicesBufferID);
GL.BindBuffer(BufferTarget.ElementArrayBuffer, IndicesBufferID);
GL.BufferData<uint>(BufferTarget.ElementArrayBuffer,
new IntPtr(IndicesData.Length * sizeof(uint)),
IndicesData, BufferUsageHint.StaticDraw);
}
GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
}