using System; using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Text; namespace StgSharp.Graphics { public partial class Form { /// /// Create a set of . /// /// Amount of VAO to be crated. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] protected VertexArray CreateVertexArray(uint count) { return new VertexArray(count, gl); } } public unsafe class VertexArray : IBufferObject { internal VertexArray(uint n, IglFunc gl) { _bufferID = new uint[n]; GL = gl; fixed (uint* id = _bufferID) { GL.GenVertexArrays(n, id); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public sealed override void Bind(int index) { GL.BindVertexArray(_bufferID[index]); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void BindNull() { GL.BindVertexArray(0); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void SetVertexAttribute(uint index, int vertexLength, Type dataType, bool isNomalized, uint stride, int pointer) { GL.SetVertexAttribute( index, vertexLength, dataType, isNomalized, stride, pointer); } protected sealed override void Dispose(bool disposing) { if (disposing) { GL.DeleteVertexArrays((uint)_bufferID.Length, _bufferID); } } } }