Files
stgsharp/源代码/StgSharp/Graphics/GL/Buffer/VAO.cs
T

60 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
namespace StgSharp.Graphics
{
public unsafe struct VertexArray : IDisposable, IBufferObject
{
internal uint[] _bufferID;
private IglFunc GL;
internal VertexArray(int n, IglFunc glFunc)
{
_bufferID = new uint[n];
GL = glFunc;
fixed (uint* id = _bufferID)
{
GL.GenVertexArrays(n, id);
}
}
public uint this[int n]
{
get
{
return _bufferID[n];
}
}
public void Bind(int index)
{
GL.BindVertexArray(_bufferID[index]);
}
public void Dispose()
{
fixed (uint* id = _bufferID)
{
GL.DeleteVertexArrays(_bufferID.Length, id);
}
}
public void BindNull()
{
GL.BindVertexArray(0);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetVertexAttribute(uint index, int vertexLength, Type dataType, bool isNomalized, int stride, int pointer)
{
GL.SetVertexAttribute(
index, vertexLength, dataType,
isNomalized,
stride, pointer);
}
}
}