recrownedgtk/RecrownedGTK/Graphics/ElementBufferArrayHandle.cs

38 lines
1.0 KiB
C#
Raw Normal View History

using System;
using OpenTK.Graphics.OpenGL;
namespace RecrownedGTK.Graphics {
2020-02-22 19:41:44 +00:00
public class ElementBufferArrayHandle : IDisposable {
private bool disposed;
private int handle;
2020-02-22 19:41:44 +00:00
public ElementBufferArrayHandle() {
handle = GL.GenBuffer();
}
public void Bind() {
GL.BindBuffer(BufferTarget.ElementArrayBuffer, handle);
}
public void Buffer(uint[] indices, BufferUsageHint hint = BufferUsageHint.DynamicDraw) {
Bind();
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;
GL.DeleteBuffer(handle);
}
2020-02-22 19:41:44 +00:00
~ElementBufferArrayHandle() {
Dispose(false);
}
}
}