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
+45 -29
View File
@@ -1,50 +1,66 @@
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
namespace StgSharp.Graphics
{
internal unsafe struct VertexArray : IDisposable
public partial class Form
{
internal uint[] _bufferID;
public VertexArray(int n)
protected VertexArray CreateVertexArray(int n)
{
_bufferID = new uint[n];
fixed (uint* id = _bufferID)
return new VertexArray(n, GL);
}
protected unsafe struct VertexArray : IDisposable
{
internal uint[] _bufferID;
private IglFunc GL;
internal VertexArray(int n, IglFunc glFunc)
{
GL.gl.GenVertexArrays(n, id);
_bufferID = new uint[n];
GL = glFunc;
fixed (uint* id = _bufferID)
{
GL.GenVertexArrays(n, id);
}
}
}
public uint this[int n]
{
get
public uint this[int n]
{
return _bufferID[n];
get
{
return _bufferID[n];
}
}
}
public void Bind(int index)
{
GL.gl.BindVertexArray(_bufferID[index]);
}
public void Dispose()
{
fixed (uint* id = _bufferID)
public void Bind(int index)
{
GL.gl.DeleteVertexArrays(_bufferID.Length, id);
GL.BindVertexArray(_bufferID[index]);
}
}
public void Dispose()
{
fixed (uint* id = _bufferID)
{
GL.DeleteVertexArrays(_bufferID.Length, id);
}
}
public void SetVertexAttribute(uint index, int vertexLength, Type dataType, bool isNomalized, int stride, int pointer)
{
GL.gl.VertexAttribPointer(
index, vertexLength, InternalIO.GLtype[dataType],
isNomalized,
stride, (void*)pointer);
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);
}
}
}
}