Daily update on 20231211 by nitload youmu

This commit is contained in:
Nitload
2023-12-12 03:17:16 +08:00
parent ab85c1a9fe
commit f97fb137ba
100 changed files with 2699 additions and 3191 deletions
+35 -43
View File
@@ -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);
}
}
}
}