Added VAO handler (attribute saving handler).

This commit is contained in:
Harrison Deng 2019-12-28 14:36:32 -06:00
parent 5e21790e2b
commit c9ad922341

View File

@ -0,0 +1,39 @@
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);
}
}
}