recrownedgtk/RecrownedGTK/Graphics/ElementBufferHandle.cs
Harrison 519d31f2e1 Another restructure with code updates.
Updated RectTextrue.cs, VertexInformation.cs, and IDrawable.cs to properly pass indice information.
2020-02-20 18:07:17 -05:00

41 lines
1.1 KiB
C#

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);
}
}
}