diff --git a/RecrownedGTK/Graphics/VertexAttributesHandle.cs b/RecrownedGTK/Graphics/VertexAttributesHandle.cs index 61d47fd..a93c3c2 100644 --- a/RecrownedGTK/Graphics/VertexAttributesHandle.cs +++ b/RecrownedGTK/Graphics/VertexAttributesHandle.cs @@ -5,20 +5,15 @@ namespace RecrownedGTK.Graphics { public class VertexAttributesHandle : IDisposable { private bool disposed; private int handle; - private bool begun; public VertexAttributesHandle() { handle = GL.GenVertexArray(); } - public void Begin() { - if (begun) throw new InvalidOperationException("The VertexArrayHandle has already been started."); + public void Bind() { GL.BindVertexArray(handle); - begun = true; } public void End() { - if (!begun) throw new InvalidOperationException("The VertexArrayHandle has never been started."); GL.BindVertexArray(0); - begun = false; } /// @@ -33,16 +28,19 @@ namespace RecrownedGTK.Graphics { public static VertexAttributesHandle CreateBasicVA(Shader shader = null, string positionAttribName = "aPosition", string textureAttribName = "aTexture", string colorAttribName = "aColor") { if (shader == null) shader = Shader.CreateBasicShader(); VertexAttributesHandle vertexAttribs = new VertexAttributesHandle(); + vertexAttribs.Bind(); GL.VertexAttribPointer(shader.GetAttribLocation(positionAttribName), 3, VertexAttribPointerType.Float, false, 9 * sizeof(float), 0); - GL.VertexAttribPointer(shader.GetAttribLocation(textureAttribName), 2, VertexAttribPointerType.Float, true, 9 * sizeof(float), 3 * sizeof(float)); + GL.VertexAttribPointer(shader.GetAttribLocation(textureAttribName), 2, VertexAttribPointerType.Float, false, 9 * sizeof(float), 3 * sizeof(float)); GL.VertexAttribPointer(shader.GetAttribLocation(colorAttribName), 4, VertexAttribPointerType.Float, false, 9 * sizeof(float), 5 * sizeof(float)); vertexAttribs.End(); return vertexAttribs; } + public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } + protected virtual void Dispose(bool disposing) { if (disposed) return; if (disposing) {