39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using System;
|
|
using OpenTK.Graphics.OpenGL;
|
|
namespace RecrownedAthenaeum.Graphics {
|
|
public class VertexArrayHandle : IDisposable {
|
|
private bool disposed;
|
|
private int handle;
|
|
private bool begun;
|
|
public VertexArrayHandle() {
|
|
handle = GL.GenVertexArray();
|
|
}
|
|
|
|
public void Begin() {
|
|
if (begun) throw new InvalidOperationException("The VertexArrayHandle has already been started.");
|
|
GL.BindVertexArray(handle);
|
|
begun = true;
|
|
}
|
|
public void End() {
|
|
if (!begun) throw new InvalidOperationException("The VertexArrayHandle has never been started.");
|
|
GL.BindVertexArray(0);
|
|
begun = false;
|
|
}
|
|
public void Dispose() {
|
|
Dispose(true);
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
protected virtual void Dispose(bool disposing) {
|
|
if (disposed) return;
|
|
if (disposing) {
|
|
|
|
}
|
|
GL.BindVertexArray(0);
|
|
GL.DeleteVertexArray(handle);
|
|
disposed = true;
|
|
}
|
|
~VertexArrayHandle() {
|
|
Dispose(false);
|
|
}
|
|
}
|
|
} |