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