daily uodate on 20231208 by nitload youmu, preparation for multi thread rendering

This commit is contained in:
Nitload
2023-12-08 05:36:04 +08:00
parent ae804553ce
commit ab85c1a9fe
297 changed files with 157896 additions and 5170 deletions
+41 -33
View File
@@ -6,46 +6,54 @@ using System.Text;
namespace StgSharp.Graphics
{
internal unsafe class ElementBuffer : IDisposable
public partial class Form
{
uint[] _bufferID;
public ElementBuffer(int n)
protected ElementBuffer CreateElementBuffer(int n)
{
_bufferID = new uint[n];
fixed (uint* id = _bufferID)
return new ElementBuffer(n, GL);
}
protected unsafe class ElementBuffer : IDisposable
{
uint[] _bufferID;
private IglFunc GL;
internal ElementBuffer(int n, IglFunc glFunc)
{
GL.gl.GenBuffers(n, id);
_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.gl.BindBuffer(GLconst.ELEMENT_ARRAY_BUFFER, _bufferID[index]);
}
public void SetData<T>(int index, T[] bufferArray, BufferUsage usage)
where T : struct, IConvertible
{
GL.gl.BindBuffer(GLconst.ELEMENT_ARRAY_BUFFER, _bufferID[index]);
GL.SetBufferData(BufferType.ELEMENT_ARRAY_BUFFER, bufferArray, usage);
}
public void Dispose()
{
fixed (uint* id = _bufferID)
public uint this[int n]
{
GL.gl.DeleteBuffers(1, 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);
}
}
}
}
}