Buffers now automatically bind when adding to them. Buffer is untested.
This commit is contained in:
parent
f891abf84e
commit
5b44fee033
@ -7,15 +7,12 @@ namespace RecrownedGTK.Graphics {
|
|||||||
public ElementBufferArrayHandle() {
|
public ElementBufferArrayHandle() {
|
||||||
handle = GL.GenBuffer();
|
handle = GL.GenBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Bind() {
|
public void Bind() {
|
||||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, handle);
|
GL.BindBuffer(BufferTarget.ElementArrayBuffer, handle);
|
||||||
}
|
}
|
||||||
|
public void Buffer(uint[] indices, BufferUsageHint hint = BufferUsageHint.DynamicDraw) {
|
||||||
public void Unbind() {
|
Bind();
|
||||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Flush(uint[] indices, BufferUsageHint hint = BufferUsageHint.StaticDraw) {
|
|
||||||
GL.BufferData(BufferTarget.ElementArrayBuffer, indices.Length * sizeof(uint), indices, hint);
|
GL.BufferData(BufferTarget.ElementArrayBuffer, indices.Length * sizeof(uint), indices, hint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,7 +27,7 @@ namespace RecrownedGTK.Graphics {
|
|||||||
|
|
||||||
}
|
}
|
||||||
disposed = true;
|
disposed = true;
|
||||||
Unbind();
|
|
||||||
GL.DeleteBuffer(handle);
|
GL.DeleteBuffer(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,8 @@ namespace RecrownedGTK.Graphics {
|
|||||||
public void Bind() {
|
public void Bind() {
|
||||||
GL.BindBuffer(BufferTarget.ArrayBuffer, handle);
|
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);
|
GL.BufferData(BufferTarget.ArrayBuffer, vertices.Length * sizeof(float), vertices, hint);
|
||||||
}
|
}
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user