Daily update on 20231211 by nitload youmu
This commit is contained in:
@@ -6,54 +6,46 @@ using System.Text;
|
||||
|
||||
namespace StgSharp.Graphics
|
||||
{
|
||||
public partial class Form
|
||||
public unsafe class ElementBuffer : IDisposable, IBufferObject
|
||||
{
|
||||
protected ElementBuffer CreateElementBuffer(int n)
|
||||
uint[] _bufferID;
|
||||
private IglFunc GL;
|
||||
|
||||
internal ElementBuffer(int n, IglFunc glFunc)
|
||||
{
|
||||
return new ElementBuffer(n, GL);
|
||||
_bufferID = new uint[n];
|
||||
GL = glFunc;
|
||||
fixed (uint* id = _bufferID)
|
||||
{
|
||||
GL.GenBuffers(n, id);
|
||||
}
|
||||
}
|
||||
|
||||
protected unsafe class ElementBuffer : IDisposable
|
||||
public uint this[int n]
|
||||
{
|
||||
uint[] _bufferID;
|
||||
private IglFunc GL;
|
||||
|
||||
internal ElementBuffer(int n, IglFunc glFunc)
|
||||
{
|
||||
_bufferID = new uint[n];
|
||||
GL = glFunc;
|
||||
fixed (uint* id = _bufferID)
|
||||
{
|
||||
GL.GenBuffers(n, id);
|
||||
}
|
||||
}
|
||||
|
||||
public uint this[int n]
|
||||
{
|
||||
get { return _bufferID[n]; }
|
||||
}
|
||||
|
||||
public void Bind(int index)
|
||||
{
|
||||
GL.BindBuffer(BufferType.ELEMENT_ARRAY_BUFFER, _bufferID[index]);
|
||||
}
|
||||
|
||||
public void SetValue<T>(int index, T[] bufferArray, BufferUsage usage)
|
||||
where T : struct, IConvertible
|
||||
{
|
||||
GL.BindBuffer(BufferType.ELEMENT_ARRAY_BUFFER, _bufferID[index]);
|
||||
GL.SetBufferData(BufferType.ELEMENT_ARRAY_BUFFER, bufferArray, usage);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
fixed (uint* id = _bufferID)
|
||||
{
|
||||
GL.DeleteBuffers(_bufferID.Length, id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
get { return _bufferID[n]; }
|
||||
}
|
||||
|
||||
public void Bind(int index)
|
||||
{
|
||||
GL.BindBuffer(BufferType.ELEMENT_ARRAY_BUFFER, _bufferID[index]);
|
||||
}
|
||||
|
||||
public void SetValue<T>(int index, T[] bufferArray, BufferUsage usage)
|
||||
where T : struct, IConvertible
|
||||
{
|
||||
GL.BindBuffer(BufferType.ELEMENT_ARRAY_BUFFER, _bufferID[index]);
|
||||
GL.SetBufferData(BufferType.ELEMENT_ARRAY_BUFFER, bufferArray, usage);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
fixed (uint* id = _bufferID)
|
||||
{
|
||||
GL.DeleteBuffers(_bufferID.Length, id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user