public void Draw() { if (state == DrawStates.None) { return; } if ((state & DrawStates.Vertex) == DrawStates.Vertex) { VertexBuffer.Bind(BufferTarget.ArrayBuffer); VertexBuffer.UseVertexPointer(vertexSize, VertexStride, VertexOffset); } if ((state & DrawStates.TexCoord) == DrawStates.TexCoord) { TexCoordBuffer.Bind(BufferTarget.ArrayBuffer); TexCoordBuffer.UseTexCoordPointer(texCoordSize, TexCoordStride, TexCoordOffset); } if ((state & DrawStates.Normal) == DrawStates.Normal) { NormalBuffer.Bind(BufferTarget.ArrayBuffer); NormalBuffer.UseNormalPointer(NormalStride, NormalOffset); } //TODO this needs to become static/part of some graphics context class. GL.BindBuffer(BufferTarget.ArrayBuffer, 0); IndexBuffer.Bind(BufferTarget.ElementArrayBuffer); GL.DrawElements(DrawMode, IndexBuffer.Length, (DrawElementsType)IndexBuffer.DataType, 0); IndexBuffer.Unbind(BufferTarget.ElementArrayBuffer); }
public void Update(float[] vertices, uint[] indexes, float[] colors, float[] normals, float[] lighting, int vertexCount) { Bind(); ElementBuffer.Bind(); ElementBuffer.SetData(sizeof(uint) * indexes.Length, indexes); VertexBuffer.Bind(); VertexBuffer.SetData(sizeof(float) * vertices.Length, vertices); ColorBuffer.Bind(); ColorBuffer.SetData(sizeof(float) * colors.Length, colors); NormalBuffer.Bind(); NormalBuffer.SetData(sizeof(float) * normals.Length, normals); LightingBuffer.Bind(); LightingBuffer.SetData(sizeof(float) * lighting.Length, lighting); VertexCount = vertexCount; Unbind(); }