Removed state tracking for VertexBufferHandle due to potential overlapping states.

This commit is contained in:
Harrison Deng 2020-02-17 02:27:14 -05:00
parent 1a256eb664
commit 115608b2a5

View File

@ -4,27 +4,18 @@ namespace RecrownedGTK.Graphics {
public class VertexBufferHandle : IDisposable {
private bool disposed;
private int handle;
public bool Bound {
get;
private set;
}
public VertexBufferHandle() {
handle = GL.GenBuffer();
}
public void Bind() {
Bound = true;
GL.BindBuffer(BufferTarget.ArrayBuffer, handle);
}
public void Unbind() {
Bound = false;
GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
}
public void Buffer(float[] vertices, BufferUsageHint hint = BufferUsageHint.StaticDraw) {
if (Bound) {
GL.BufferData(BufferTarget.ArrayBuffer, vertices.Length * sizeof(float), vertices, hint);
return;
}
throw new InvalidOperationException("Buffer is not bound.");
public void Flush(float[] vertices, BufferUsageHint hint = BufferUsageHint.StaticDraw) {
GL.BufferData(BufferTarget.ArrayBuffer, vertices.Length * sizeof(float), vertices, hint);
}
public void Dispose() {
Dispose(true);