Added VAO handler (attribute saving handler).
This commit is contained in:
parent
5e21790e2b
commit
c9ad922341
39
RecrownedAthenaeum/Graphics/VertexArrayHandle.cs
Normal file
39
RecrownedAthenaeum/Graphics/VertexArrayHandle.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user