daily update on 20240207 by nitload youmu
This commit is contained in:
@@ -21,20 +21,57 @@ namespace System
|
||||
public unsafe struct glHandle
|
||||
{
|
||||
internal uint* valuePtr;
|
||||
internal glHandleSet source;
|
||||
|
||||
public glHandle()
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
internal glHandle(uint* val)
|
||||
public static glHandle Alloc(uint value)
|
||||
{
|
||||
glHandle ret = default;
|
||||
ret.source = new glHandleSet(1);
|
||||
*ret.valuePtr = value;
|
||||
return ret;
|
||||
}
|
||||
|
||||
internal glHandle(uint* val, glHandleSet set)
|
||||
{
|
||||
source = set;
|
||||
valuePtr = val;
|
||||
}
|
||||
|
||||
public IntPtr Handle
|
||||
{
|
||||
get
|
||||
{
|
||||
if (source.handle == (uint*)0)
|
||||
{
|
||||
throw new InvalidOperationException($"Handle set {nameof(source)} is not pinned.");
|
||||
}
|
||||
return (IntPtr)valuePtr;
|
||||
}
|
||||
}
|
||||
|
||||
public uint Value
|
||||
{
|
||||
get { return *valuePtr; }
|
||||
get
|
||||
{
|
||||
if (source.handle == (uint*)0)
|
||||
{
|
||||
throw new InvalidOperationException($"Handle set {nameof(source)} is not pinned.");
|
||||
}
|
||||
return *valuePtr;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (source.handle == (uint*)0)
|
||||
{
|
||||
throw new InvalidOperationException($"Handle set {nameof(source)} is not pinned.");
|
||||
}
|
||||
*valuePtr = value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -56,10 +93,11 @@ namespace System
|
||||
{
|
||||
throw new IndexOutOfRangeException();
|
||||
}
|
||||
return new glHandle(handle + index);
|
||||
return new glHandle(handle + index, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetValue(int index, uint value)
|
||||
{
|
||||
@@ -85,6 +123,7 @@ namespace System
|
||||
}
|
||||
GCHandle h = GCHandle.FromIntPtr((IntPtr)handle);
|
||||
h.Free();
|
||||
handle = (uint*)0;
|
||||
}
|
||||
|
||||
public void Pin()
|
||||
|
||||
Reference in New Issue
Block a user