using StgSharp.Math; using System; using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; namespace StgSharp.Graphics { /// /// A collecion of handle to Element Buffer Object in OpenGL. /// Each value indexed from instance of this class this /// is the only handle to one Element Buffer Object. /// public unsafe class ElementBuffer : BufferObjectBase { internal ElementBuffer(int n, IglFunc gl) { GL = gl; _bufferHandle = GL.GenBuffers(n); } public override sealed void Bind(int index) { GL.BindBuffer(BufferType.ELEMENT_ARRAY_BUFFER, _bufferHandle[index]); } public void SetValue(int index, T[] bufferArray, BufferUsage usage) where T : struct, IConvertible { GL.BindBuffer(BufferType.ELEMENT_ARRAY_BUFFER, _bufferHandle[index]); GL.SetBufferData(BufferType.ELEMENT_ARRAY_BUFFER, bufferArray, usage); } protected override sealed void Dispose(bool disposing) { if (disposing) { GL.DeleteBuffers(_bufferHandle); _bufferHandle.Release(); } } } }