daily update on 20240209 by nitload youmu
This commit is contained in:
@@ -13,6 +13,37 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace System
|
||||
{
|
||||
public unsafe struct glSHandle
|
||||
{
|
||||
internal int* valuePtr;
|
||||
internal glHandleSet source;
|
||||
|
||||
public static glSHandle Zero
|
||||
{
|
||||
get { return Alloc(1); }
|
||||
}
|
||||
|
||||
public static glSHandle Alloc(int value)
|
||||
{
|
||||
glSHandle ret = default;
|
||||
ret.source = new glHandleSet(1);
|
||||
ret.valuePtr = (int*)ret.source.handle;
|
||||
*ret.valuePtr = (int)value;
|
||||
return ret;
|
||||
}
|
||||
|
||||
internal int DirectValue
|
||||
{
|
||||
get { return *valuePtr; }
|
||||
}
|
||||
|
||||
internal glSHandle(int* val, glHandleSet set)
|
||||
{
|
||||
source = set;
|
||||
valuePtr = val;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A handle to an OpenGL object,
|
||||
/// must be indexed from a <see cref="glHandleSet"/>.
|
||||
@@ -23,6 +54,11 @@ namespace System
|
||||
internal uint* valuePtr;
|
||||
internal glHandleSet source;
|
||||
|
||||
public static glHandle Zero
|
||||
{
|
||||
get { return Alloc(0); }
|
||||
}
|
||||
|
||||
public glHandle()
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
@@ -32,6 +68,7 @@ namespace System
|
||||
{
|
||||
glHandle ret = default;
|
||||
ret.source = new glHandleSet(1);
|
||||
ret.valuePtr = ret.source.handle;
|
||||
*ret.valuePtr = value;
|
||||
return ret;
|
||||
}
|
||||
@@ -54,6 +91,14 @@ namespace System
|
||||
}
|
||||
}
|
||||
|
||||
internal uint DirectValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return *valuePtr;
|
||||
}
|
||||
}
|
||||
|
||||
public uint Value
|
||||
{
|
||||
get
|
||||
@@ -73,7 +118,6 @@ namespace System
|
||||
*valuePtr = value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -85,6 +129,22 @@ namespace System
|
||||
internal int length;
|
||||
internal uint* handle;
|
||||
|
||||
public static void Copy(in glHandleSet source, glHandleSet target)
|
||||
{
|
||||
if (source == null || target == null)
|
||||
{
|
||||
throw new NullReferenceException();
|
||||
}
|
||||
if (source.length != target.length)
|
||||
{
|
||||
throw new Exception($"Lengths of {nameof(source)} and {nameof(target)} are not equal.");
|
||||
}
|
||||
for (int i = 0; i < source.length; i++)
|
||||
{
|
||||
target._value[i] = source._value[i];
|
||||
}
|
||||
}
|
||||
|
||||
public glHandle this[int index]
|
||||
{
|
||||
get
|
||||
@@ -97,6 +157,17 @@ namespace System
|
||||
}
|
||||
}
|
||||
|
||||
public glSHandle this[uint index]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (index > length)
|
||||
{
|
||||
throw new IndexOutOfRangeException();
|
||||
}
|
||||
return new glSHandle((int*)handle + index, this);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetValue(int index, uint value)
|
||||
|
||||
Reference in New Issue
Block a user