Buffers now automatically bind when adding to them. Buffer is untested.

This commit is contained in:
Harrison Deng 2020-03-01 18:08:01 -05:00
parent f891abf84e
commit 5b44fee033
2 changed files with 6 additions and 8 deletions

View File

@ -7,15 +7,12 @@ namespace RecrownedGTK.Graphics {
public ElementBufferArrayHandle() {
handle = GL.GenBuffer();
}
public void Bind() {
GL.BindBuffer(BufferTarget.ElementArrayBuffer, handle);
}
public void Unbind() {
GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
}
public void Flush(uint[] indices, BufferUsageHint hint = BufferUsageHint.StaticDraw) {
public void Buffer(uint[] indices, BufferUsageHint hint = BufferUsageHint.DynamicDraw) {
Bind();
GL.BufferData(BufferTarget.ElementArrayBuffer, indices.Length * sizeof(uint), indices, hint);
}
@ -30,7 +27,7 @@ namespace RecrownedGTK.Graphics {
}
disposed = true;
Unbind();
GL.DeleteBuffer(handle);
}

View File

@ -10,7 +10,8 @@ namespace RecrownedGTK.Graphics {
public void Bind() {
GL.BindBuffer(BufferTarget.ArrayBuffer, handle);
}
public void Flush(float[] vertices, BufferUsageHint hint = BufferUsageHint.StaticDraw) {
public void Buffer(float[] vertices, BufferUsageHint hint = BufferUsageHint.DynamicCopy) {
Bind();
GL.BufferData(BufferTarget.ArrayBuffer, vertices.Length * sizeof(float), vertices, hint);
}
public void Dispose() {