Started work on the ElementBufferHandle.
This commit is contained in:
parent
e58af8ce56
commit
289799a6af
41
RecrownedGTK/Graphics/ElementBufferHandle.cs
Normal file
41
RecrownedGTK/Graphics/ElementBufferHandle.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
namespace RecrownedGTK.Graphics {
|
||||
public class ElementBufferHandle : IDisposable {
|
||||
private bool disposed;
|
||||
private int handle;
|
||||
public ElementBufferHandle() {
|
||||
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) {
|
||||
GL.BufferData(BufferTarget.ElementArrayBuffer, indices.Length * sizeof(uint), indices, hint);
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing) {
|
||||
if (disposed) return;
|
||||
if (disposing) {
|
||||
|
||||
}
|
||||
disposed = true;
|
||||
Unbind();
|
||||
GL.DeleteBuffer(handle);
|
||||
}
|
||||
|
||||
~ElementBufferHandle() {
|
||||
Dispose(false);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user