use modular initing system rather than calling Init() method.

This commit is contained in:
Youmu Liu
2025-11-11 18:22:28 +08:00
parent 678a846e54
commit 44bf78b937
65 changed files with 1328 additions and 1814 deletions
@@ -30,20 +30,37 @@ using System.Runtime.CompilerServices;
namespace StgSharp.Collections
{
public sealed class NotEnumerableList<T>(int capacity = 4)
public static class LinearBagBuilder
{
public static LinearBag<T> FromSpan<T>(ReadOnlySpan<T> values)
{
if (values.IsEmpty || values.Length == 0) {
return new LinearBag<T>(4);
}
LinearBag<T> bag = new(values.Length);
for (int i = 0; i < values.Length; i++) {
bag.Add(values[i]);
}
return bag;
}
}
[CollectionBuilder(typeof(LinearBagBuilder), nameof(LinearBagBuilder.FromSpan))]
public class LinearBag<T>(int capacity = 4)
{
private T[] _items = new T[capacity];
private int _size = 0;
public T this[int index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => (uint)index >= (uint)_size ? throw new ArgumentOutOfRangeException(nameof(index)) : _items[index];
get => (uint)index >= (uint)Count ? throw new ArgumentOutOfRangeException(nameof(index)) : _items[index];
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set
{
if ((uint)index >= (uint)_size) {
if ((uint)index >= (uint)Count) {
throw new ArgumentOutOfRangeException(nameof(index));
}
@@ -51,31 +68,67 @@ namespace StgSharp.Collections
}
}
public int Count => _size;
public int Capacity => _items.Length;
public int Count { get; private set; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Add(T item)
{
if (_size == _items.Length) {
EnsureCapacity(_size + 1);
if (Count == _items.Length) {
EnsureCapacity(Count + 1);
}
_items[_size++] = item;
_items[Count++] = item;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Span<T> AsSpan()
{
return new Span<T>(_items, 0, _size);
return new Span<T>(_items, 0, Count);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Clear()
{
Array.Clear(_items, 0, Count);
Count = 0;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void FastClear()
{
// 只重置size,不清理数组内容
_size = 0;
Count = 0;
}
public void Remove(T value)
{
for (int i = 0; i < Count; i++)
{
if (_items[i]?.Equals(value) ?? false)
{
RemoveAt(i);
return;
}
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void RemoveAt(int index)
{
if ((uint)index >= (uint)Count) {
throw new ArgumentOutOfRangeException(nameof(index));
}
int last = Count - 1;
if (index != last)
{
_items[index] = _items[last]; // swap back from tail
}
_items[last] = default!; // clear last slot to avoid ref retention
Count = last;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
+18 -18
View File
@@ -2,8 +2,8 @@
// -----------------------------------------------------------------------
// file="KeyEnum"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// AuthorGroup: Nitload
// Copyright (c) Nitload. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -171,22 +171,22 @@ namespace StgSharp
#pragma warning restore CA1027
{
Joystick_1 = Constant.GLFW_JOYSTICK_1,
Joystick_2 = Constant.GLFW_JOYSTICK_2,
Joystick_3 = Constant.GLFW_JOYSTICK_3,
Joystick_4 = Constant.GLFW_JOYSTICK_4,
Joystick_5 = Constant.GLFW_JOYSTICK_5,
Joystick_6 = Constant.GLFW_JOYSTICK_6,
Joystick_7 = Constant.GLFW_JOYSTICK_7,
Joystick_8 = Constant.GLFW_JOYSTICK_8,
Joystick_9 = Constant.GLFW_JOYSTICK_9,
Joystick_10 = Constant.GLFW_JOYSTICK_10,
Joystick_11 = Constant.GLFW_JOYSTICK_11,
Joystick_12 = Constant.GLFW_JOYSTICK_12,
Joystick_13 = Constant.GLFW_JOYSTICK_13,
Joystick_14 = Constant.GLFW_JOYSTICK_14,
Joystick_15 = Constant.GLFW_JOYSTICK_15,
Joystick_16 = Constant.GLFW_JOYSTICK_16,
Joystick_1 = FrameworkConstant.GLFW_JOYSTICK_1,
Joystick_2 = FrameworkConstant.GLFW_JOYSTICK_2,
Joystick_3 = FrameworkConstant.GLFW_JOYSTICK_3,
Joystick_4 = FrameworkConstant.GLFW_JOYSTICK_4,
Joystick_5 = FrameworkConstant.GLFW_JOYSTICK_5,
Joystick_6 = FrameworkConstant.GLFW_JOYSTICK_6,
Joystick_7 = FrameworkConstant.GLFW_JOYSTICK_7,
Joystick_8 = FrameworkConstant.GLFW_JOYSTICK_8,
Joystick_9 = FrameworkConstant.GLFW_JOYSTICK_9,
Joystick_10 = FrameworkConstant.GLFW_JOYSTICK_10,
Joystick_11 = FrameworkConstant.GLFW_JOYSTICK_11,
Joystick_12 = FrameworkConstant.GLFW_JOYSTICK_12,
Joystick_13 = FrameworkConstant.GLFW_JOYSTICK_13,
Joystick_14 = FrameworkConstant.GLFW_JOYSTICK_14,
Joystick_15 = FrameworkConstant.GLFW_JOYSTICK_15,
Joystick_16 = FrameworkConstant.GLFW_JOYSTICK_16,
First = Joystick_1,
Last = Joystick_16
-31
View File
@@ -1,31 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="BehaviorArgs"
// Project: StgSharp
// AuthorGroup: Nitload
// Copyright (c) Nitload. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
namespace StgSharp.Entities
{
public abstract class BehaviorArgs { }
}
-50
View File
@@ -1,50 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="Enemy"
// Project: StgSharp
// AuthorGroup: Nitload
// Copyright (c) Nitload. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
namespace StgSharp.Entities
{
public class Enemy : IEntity
{
internal Launcher<EntityPartical> _awardLauncher;
internal Launcher<EntityPartical> _commonBulletLauncher;
internal Launcher<EntityPartical> _dieBulletLauncher;
public bool _selectalbe;
public Launcher<EntityPartical> AwardLauncher { get; set; }
public Launcher<EntityPartical> CommonBulletLauncher { get; set; }
public Launcher<EntityPartical> DieBulletLauncher { get; set; }
public override void OnRenderFrame()
{
CommonBulletLauncher.Launch();
}
}
}
@@ -1,31 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="EntityPartical"
// Project: StgSharp
// AuthorGroup: Nitload
// Copyright (c) Nitload. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
namespace StgSharp.Entities
{
public abstract class EntityPartical : IEntity { }
}
-90
View File
@@ -1,90 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="IEntity"
// Project: StgSharp
// AuthorGroup: Nitload
// Copyright (c) Nitload. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Geometries;
using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
using System;
using System.Collections.Generic;
namespace StgSharp
{
public abstract class IEntity
{
protected uint _bornTick;
internal Func<int, Vec3> _movHandler;
internal LinkedList<PlainGeometry> _collisionBox;
internal PlainGeometryCollisionSensor<PlainGeometry, PlainGeometry> _collisionSensor;
internal Point _basePoint;
internal Point _pos;
internal Point _position;
internal string _texture;
/// <summary>
/// X position of an enenmy entity
/// </summary>
public float X { get; set; }
/// <summary>
/// Y position of an enemy entity
/// </summary>
public float Y { get; set; }
public LinkedList<PlainGeometry> CollisionBox
{
get => _collisionBox;
set => _collisionBox = value;
}
/// <summary>
/// A sensor used for checking out if a bullet hit a player or something else
/// </summary>
public PlainGeometryCollisionSensor<PlainGeometry, PlainGeometry> CollisionSensor
{
get => _collisionSensor;
set => _collisionSensor = value;
}
public string TextureGL { get; set; }
/// <summary>
/// A 2D vector presenting the position of an enemy entity, position can also be visited
/// by X, Y
/// </summary>
public Vec2 Location { get; }
public abstract void OnRenderFrame();
public void SetLocation(Point p)
{
_pos = p;
}
}
}
-56
View File
@@ -1,56 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="Launcher"
// Project: StgSharp
// AuthorGroup: Nitload
// Copyright (c) Nitload. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Entities;
using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphic;
namespace StgSharp
{
public class Launcher<T> where T: IEntity
{
internal uint[] launchtick; //发射子弹的内部计时
internal Counter<int> _internalParameter; //发射器的内部计时器
internal EntityPartical _bulletSample; //发射的子弹类型
/*
*用于发射其他的实体,主要是子弹 和 掉落物
*/
internal Vec2 _center; //发射器的参考位置,运动轨迹的方程应当基于这个参考点构建
public EntityPartical Bullet
{
get => _bulletSample;
set => _bulletSample = value;
}
internal virtual void Launch() { }
}
}
-41
View File
@@ -1,41 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="Partical"
// Project: StgSharp
// AuthorGroup: Nitload
// Copyright (c) Nitload. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using System;
namespace StgSharp
{
public class Partical : IEntity
{
public override void OnRenderFrame()
{
throw new NotImplementedException();
}
}
}
-38
View File
@@ -1,38 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="Player"
// Project: StgSharp
// AuthorGroup: Nitload
// Copyright (c) Nitload. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
namespace StgSharp
{
public abstract class Player : IEntity
{
internal float _velocity;
public float Velocity => _velocity;
}
}
+2 -1
View File
@@ -44,7 +44,6 @@ namespace StgSharp
private static byte[] _currentHash = [];
private static bool _inited;
private static int _mainThreadID = -1;
public static byte[] CurrentAssemblyHash
{
@@ -73,6 +72,8 @@ namespace StgSharp
internal set => _mainThreadID = value;
}
private static int _mainThreadID { get; set; } = -1;
/// <summary>
/// CustomizeInit an instance of OpenGL program, This method should be called before any
/// other World api.
@@ -1,6 +1,6 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="glClampf"
// file="IStaticModule"
// Project: StgSharp
// AuthorGroup: Nitload
// Copyright (c) Nitload. All rights reserved.
@@ -26,64 +26,59 @@
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Internal
namespace StgSharp
{
/// <summary>
/// OpenGL numeric type. An IEEE-754 floating-point value, clamped to the range [0,1].
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct GLclampf
public interface IStaticModule
{
public float value;
string ModuleName { get; }
public GLclampf(float a)
{
value = a;
}
public static explicit operator float(GLclampf v)
{
return v.value;
}
public static explicit operator GLclampf(float v)
{
return new GLclampf(v);
}
void InitializeModule();
}
/// <summary>
/// OpenGL numeric type. An IEEE-754 double precision floating-point value, clamped to the
/// range [0,1].
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct GLclampd
public class ModuleToInitializeCollection : IEnumerable<IStaticModule>, IStaticModule
{
public double value;
private readonly List<IStaticModule> _modules = [];
public GLclampd(double a)
internal ModuleToInitializeCollection(World.Initializer i)
{
value = a;
_modules.Add(i);
}
public static explicit operator double(GLclampd v)
public IEnumerator<IStaticModule> GetEnumerator()
{
return v.value;
return ((IEnumerable<IStaticModule>)_modules).GetEnumerator();
}
public static explicit operator GLclampd(double v)
public void InitializeModule()
{
return new GLclampd(v);
foreach (IStaticModule module in _modules) {
module.InitializeModule();
}
}
public ModuleToInitializeCollection UseModule<T>() where T: IStaticModule, new()
{
_modules.Add(new T());
return this;
}
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable)_modules).GetEnumerator();
}
void IStaticModule.InitializeModule()
{
throw new NotImplementedException();
}
string IStaticModule.ModuleName => "Module Initializer";
}
}
+8 -14
View File
@@ -25,38 +25,32 @@
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp
{
public static partial class World
{
private static unsafe IntPtr[] monitorsArray = [];
public static unsafe IntPtr[] MonitorsHandleArray
{
get
{
if (monitorsArray == null)
if (MonitorsArray == null)
{
int count = 0;
IntPtr* arrayhandle = GraphicFramework.glfwGetMonitors(&count);
monitorsArray = new IntPtr[count];
Marshal.Copy((IntPtr)arrayhandle, monitorsArray, 0, count);
Marshal.FreeHGlobal((IntPtr)arrayhandle);
IntPtr* arrayHandle = GraphicFramework.glfwGetMonitors(&count);
MonitorsArray = new IntPtr[count];
Marshal.Copy((IntPtr)arrayHandle, MonitorsArray, 0, count);
Marshal.FreeHGlobal((IntPtr)arrayHandle);
}
return monitorsArray;
return MonitorsArray;
}
}
public static nint[] MonitorsArray { get; set; } = [];
public static IntPtr DefaultMonitor => MonitorsHandleArray[0];
}
+37 -19
View File
@@ -65,26 +65,9 @@ namespace StgSharp
_ => 8,
};
public static unsafe void Init()
public static ModuleToInitializeCollection Initialize()
{
mainTimeProvider = new StgSharpTime();
MainTimeProvider.StartProvidingTime();
GraphicFramework.LoadGlfw();
if (GraphicFramework.glfwInit() == 0) {
throw new Exception("Failed to init system graphic environment.");
}
DefaultLog.InternalAppendLog("\n\n\n");
DefaultLog.InternalWriteLog(
$"Program {Assembly.GetEntryAssembly()!.FullName} on {Environment.MachineName} Started.", LogType.Info);
MainThreadID = Environment.CurrentManagedThreadId;
Dialogue.LoadDialogue();
if (Dialogue.NeedShowWhenStartup) {
Dialogue.CreateDialogueProcessIfNotExist();
}
NativeIntrinsic.InitIntrinsicContext();
return new ModuleToInitializeCollection(new Initializer());
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -201,5 +184,40 @@ namespace StgSharp
}
}
internal static unsafe void InternalInitialize()
{
mainTimeProvider = new StgSharpTime();
MainTimeProvider.StartProvidingTime();
GraphicFramework.LoadGlfw();
if (GraphicFramework.glfwInit() == 0) {
throw new Exception("Failed to init system graphic environment.");
}
DefaultLog.InternalAppendLog("\n\n\n");
DefaultLog.InternalWriteLog(
$"Program {Assembly.GetEntryAssembly()!.FullName} on {Environment.MachineName} Started.", LogType.Info);
MainThreadID = System.Environment.CurrentManagedThreadId;
Dialogue.LoadDialogue();
if (Dialogue.NeedShowWhenStartup) {
Dialogue.CreateDialogueProcessIfNotExist();
}
NativeIntrinsic.InitIntrinsicContext();
}
internal class Initializer : IStaticModule
{
public string ModuleName => "StgSharp";
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void InitializeModule()
{
World.InternalInitialize();
}
}
}
}
@@ -46,26 +46,26 @@ namespace StgSharp.Geometries
public virtual Point LocalOrigin
{
get => new Point(coordMat.column3.XYZ);
internal set => coordMat.column3.XYZ = value.Coord;
get => new Point(coordMat.column[3].XYZ);
internal set => coordMat.column[3].XYZ = value.Coord;
}
public virtual Vec3 LocalX
{
get => coordMat.column0.XYZ;
internal set => coordMat.column0.XYZ = value;
get => coordMat.column[3].XYZ;
internal set => coordMat.column[3].XYZ = value;
}
public virtual Vec3 LocalY
{
get => coordMat.column1.XYZ;
internal set => coordMat.column1.XYZ = value;
get => coordMat.column[3].XYZ;
internal set => coordMat.column[3].XYZ = value;
}
public virtual Vec3 LocalZ
{
get => coordMat.column2.XYZ;
set => coordMat.column2.XYZ = value;
get => coordMat.column[3].XYZ;
set => coordMat.column[3].XYZ = value;
}
protected ref Matrix44 CoordMat
@@ -43,15 +43,15 @@ namespace StgSharp.Geometries
{
CoordMat = Matrix44.Unit;
CoordMat.column0 = new Vec4(xAxis, 0);
CoordMat.column1 = new Vec4(yAxis, 0);
CoordMat.column2 = new Vec4(Linear.Normalize(Vec3.Cross(xAxis, yAxis)), 0);
CoordMat.column[0] = new Vec4(xAxis, 0);
CoordMat.column[1] = new Vec4(yAxis, 0);
CoordMat.column[2] = new Vec4(Linear.Normalize(Vec3.Cross(xAxis, yAxis)), 0);
LocalOrigin = origin;
}
public static PlainCoordinate StandardPlainCoordination { get; } = new(
null, new Point(0, 0, 0), new Vec3(1, 0, 0), new Vec3(0, 1, 0));
public static PlainCoordinate StandardPlainCoordination { get; } = new(null, new Point(0, 0, 0),
new Vec3(1, 0, 0), new Vec3(0, 1, 0));
}
}
-336
View File
@@ -1,336 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="Constant"
// Project: StgSharp
// AuthorGroup: Nitload
// Copyright (c) Nitload. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Graphics
{
public static class Constant
{
#region glfw
public const int GLFW_VERSION_MAJOR = 3;
public const int GLFW_VERSION_MINOR = 3;
public const int GLFW_VERSION_REVISION = 8;
public const int GLFW_TRUE = 1;
public const int GLFW_FALSE = 0;
public const int GLFW_RELEASE = 0;
public const int GLFW_PRESS = 1;
public const int GLFW_REPEAT = 2;
public const int GLFW_HAT_CENTERED = 0;
public const int GLFW_HAT_UP = 1;
public const int GLFW_HAT_RIGHT = 2;
public const int GLFW_HAT_DOWN = 4;
public const int GLFW_HAT_LEFT = 8;
public const int GLFW_HAT_RIGHT_UP = GLFW_HAT_RIGHT | GLFW_HAT_UP;
public const int GLFW_HAT_RIGHT_DOWN = GLFW_HAT_RIGHT | GLFW_HAT_DOWN;
public const int GLFW_HAT_LEFT_UP = GLFW_HAT_LEFT | GLFW_HAT_UP;
public const int GLFW_HAT_LEFT_DOWN = GLFW_HAT_LEFT | GLFW_HAT_DOWN;
public const int GLFW_KEY_UNKNOWN = -1;
public const int GLFW_KEY_SPACE = 32;
public const int GLFW_KEY_APOSTROPHE = 39;
public const int GLFW_KEY_COMMA = 44;
public const int GLFW_KEY_MINUS = 45;
public const int GLFW_KEY_PERIOD = 46;
public const int GLFW_KEY_SLASH = 47;
public const int GLFW_KEY_0 = 48;
public const int GLFW_KEY_1 = 49;
public const int GLFW_KEY_2 = 50;
public const int GLFW_KEY_3 = 51;
public const int GLFW_KEY_4 = 52;
public const int GLFW_KEY_5 = 53;
public const int GLFW_KEY_6 = 54;
public const int GLFW_KEY_7 = 55;
public const int GLFW_KEY_8 = 56;
public const int GLFW_KEY_9 = 57;
public const int GLFW_KEY_SEMICOLON = 59;
public const int GLFW_KEY_EQUAL = 61;
public const int GLFW_KEY_A = 65;
public const int GLFW_KEY_B = 66;
public const int GLFW_KEY_C = 67;
public const int GLFW_KEY_D = 68;
public const int GLFW_KEY_E = 69;
public const int GLFW_KEY_F = 70;
public const int GLFW_KEY_G = 71;
public const int GLFW_KEY_H = 72;
public const int GLFW_KEY_I = 73;
public const int GLFW_KEY_J = 74;
public const int GLFW_KEY_K = 75;
public const int GLFW_KEY_L = 76;
public const int GLFW_KEY_M = 77;
public const int GLFW_KEY_N = 78;
public const int GLFW_KEY_O = 79;
public const int GLFW_KEY_P = 80;
public const int GLFW_KEY_Q = 81;
public const int GLFW_KEY_R = 82;
public const int GLFW_KEY_S = 83;
public const int GLFW_KEY_T = 84;
public const int GLFW_KEY_U = 85;
public const int GLFW_KEY_V = 86;
public const int GLFW_KEY_W = 87;
public const int GLFW_KEY_X = 88;
public const int GLFW_KEY_Y = 89;
public const int GLFW_KEY_Z = 90;
public const int GLFW_KEY_LEFT_BRACKET = 91;
public const int GLFW_KEY_BACKSLASH = 92;
public const int GLFW_KEY_RIGHT_BRACKET = 93;
public const int GLFW_KEY_GRAVE_ACCENT = 96;
public const int GLFW_KEY_WORLD_1 = 161;
public const int GLFW_KEY_WORLD_2 = 162;
public const int GLFW_KEY_ESCAPE = 256;
public const int GLFW_KEY_ENTER = 257;
public const int GLFW_KEY_TAB = 258;
public const int GLFW_KEY_BACKSPACE = 259;
public const int GLFW_KEY_INSERT = 260;
public const int GLFW_KEY_DELETE = 261;
public const int GLFW_KEY_RIGHT = 262;
public const int GLFW_KEY_LEFT = 263;
public const int GLFW_KEY_DOWN = 264;
public const int GLFW_KEY_UP = 265;
public const int GLFW_KEY_PAGE_UP = 266;
public const int GLFW_KEY_PAGE_DOWN = 267;
public const int GLFW_KEY_HOME = 268;
public const int GLFW_KEY_END = 269;
public const int GLFW_KEY_CAPS_LOCK = 280;
public const int GLFW_KEY_SCROLL_LOCK = 281;
public const int GLFW_KEY_NUM_LOCK = 282;
public const int GLFW_KEY_PRINT_SCREEN = 283;
public const int GLFW_KEY_PAUSE = 284;
public const int GLFW_KEY_F1 = 290;
public const int GLFW_KEY_F2 = 291;
public const int GLFW_KEY_F3 = 292;
public const int GLFW_KEY_F4 = 293;
public const int GLFW_KEY_F5 = 294;
public const int GLFW_KEY_F6 = 295;
public const int GLFW_KEY_F7 = 296;
public const int GLFW_KEY_F8 = 297;
public const int GLFW_KEY_F9 = 298;
public const int GLFW_KEY_F10 = 299;
public const int GLFW_KEY_F11 = 300;
public const int GLFW_KEY_F12 = 301;
public const int GLFW_KEY_F13 = 302;
public const int GLFW_KEY_F14 = 303;
public const int GLFW_KEY_F15 = 304;
public const int GLFW_KEY_F16 = 305;
public const int GLFW_KEY_F17 = 306;
public const int GLFW_KEY_F18 = 307;
public const int GLFW_KEY_F19 = 308;
public const int GLFW_KEY_F20 = 309;
public const int GLFW_KEY_F21 = 310;
public const int GLFW_KEY_F22 = 311;
public const int GLFW_KEY_F23 = 312;
public const int GLFW_KEY_F24 = 313;
public const int GLFW_KEY_F25 = 314;
public const int GLFW_KEY_KP_0 = 320;
public const int GLFW_KEY_KP_1 = 321;
public const int GLFW_KEY_KP_2 = 322;
public const int GLFW_KEY_KP_3 = 323;
public const int GLFW_KEY_KP_4 = 324;
public const int GLFW_KEY_KP_5 = 325;
public const int GLFW_KEY_KP_6 = 326;
public const int GLFW_KEY_KP_7 = 327;
public const int GLFW_KEY_KP_8 = 328;
public const int GLFW_KEY_KP_9 = 329;
public const int GLFW_KEY_KP_DECIMAL = 330;
public const int GLFW_KEY_KP_DIVIDE = 331;
public const int GLFW_KEY_KP_MULTIPLY = 332;
public const int GLFW_KEY_KP_SUBTRACT = 333;
public const int GLFW_KEY_KP_ADD = 334;
public const int GLFW_KEY_KP_ENTER = 335;
public const int GLFW_KEY_KP_EQUAL = 336;
public const int GLFW_KEY_LEFT_SHIFT = 340;
public const int GLFW_KEY_LEFT_CONTROL = 341;
public const int GLFW_KEY_LEFT_ALT = 342;
public const int GLFW_KEY_LEFT_SUPER = 343;
public const int GLFW_KEY_RIGHT_SHIFT = 344;
public const int GLFW_KEY_RIGHT_CONTROL = 345;
public const int GLFW_KEY_RIGHT_ALT = 346;
public const int GLFW_KEY_RIGHT_SUPER = 347;
public const int GLFW_KEY_MENU = 348;
public const int GLFW_KEY_LAST = GLFW_KEY_MENU;
public const int GLFW_MOD_SHIFT = 0x0001;
public const int GLFW_MOD_CONTROL = 0x0002;
public const int GLFW_MOD_ALT = 0x0004;
public const int GLFW_MOD_SUPER = 0x0008;
public const int GLFW_MOD_CAPS_LOCK = 0x0010;
public const int GLFW_MOD_NUM_LOCK = 0x0020;
public const int GLFW_MOUSE_BUTTON_1 = 0;
public const int GLFW_MOUSE_BUTTON_2 = 1;
public const int GLFW_MOUSE_BUTTON_3 = 2;
public const int GLFW_MOUSE_BUTTON_4 = 3;
public const int GLFW_MOUSE_BUTTON_5 = 4;
public const int GLFW_MOUSE_BUTTON_6 = 5;
public const int GLFW_MOUSE_BUTTON_7 = 6;
public const int GLFW_MOUSE_BUTTON_8 = 7;
public const int GLFW_MOUSE_BUTTON_LAST = GLFW_MOUSE_BUTTON_8;
public const int GLFW_MOUSE_BUTTON_LEFT = GLFW_MOUSE_BUTTON_1;
public const int GLFW_MOUSE_BUTTON_RIGHT = GLFW_MOUSE_BUTTON_2;
public const int GLFW_MOUSE_BUTTON_MIDDLE = GLFW_MOUSE_BUTTON_3;
public const int GLFW_JOYSTICK_1 = 0;
public const int GLFW_JOYSTICK_2 = 1;
public const int GLFW_JOYSTICK_3 = 2;
public const int GLFW_JOYSTICK_4 = 3;
public const int GLFW_JOYSTICK_5 = 4;
public const int GLFW_JOYSTICK_6 = 5;
public const int GLFW_JOYSTICK_7 = 6;
public const int GLFW_JOYSTICK_8 = 7;
public const int GLFW_JOYSTICK_9 = 8;
public const int GLFW_JOYSTICK_10 = 9;
public const int GLFW_JOYSTICK_11 = 10;
public const int GLFW_JOYSTICK_12 = 11;
public const int GLFW_JOYSTICK_13 = 12;
public const int GLFW_JOYSTICK_14 = 13;
public const int GLFW_JOYSTICK_15 = 14;
public const int GLFW_JOYSTICK_16 = 15;
public const int GLFW_JOYSTICK_LAST = GLFW_JOYSTICK_16;
public const int GLFW_GAMEPAD_BUTTON_A = 0;
public const int GLFW_GAMEPAD_BUTTON_B = 1;
public const int GLFW_GAMEPAD_BUTTON_X = 2;
public const int GLFW_GAMEPAD_BUTTON_Y = 3;
public const int GLFW_GAMEPAD_BUTTON_LEFT_BUMPER = 4;
public const int GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER = 5;
public const int GLFW_GAMEPAD_BUTTON_BACK = 6;
public const int GLFW_GAMEPAD_BUTTON_START = 7;
public const int GLFW_GAMEPAD_BUTTON_GUIDE = 8;
public const int GLFW_GAMEPAD_BUTTON_LEFT_THUMB = 9;
public const int GLFW_GAMEPAD_BUTTON_RIGHT_THUMB = 10;
public const int GLFW_GAMEPAD_BUTTON_DPAD_UP = 11;
public const int GLFW_GAMEPAD_BUTTON_DPAD_RIGHT = 12;
public const int GLFW_GAMEPAD_BUTTON_DPAD_DOWN = 13;
public const int GLFW_GAMEPAD_BUTTON_DPAD_LEFT = 14;
public const int GLFW_GAMEPAD_BUTTON_LAST = GLFW_GAMEPAD_BUTTON_DPAD_LEFT;
public const int GLFW_GAMEPAD_BUTTON_CROSS = GLFW_GAMEPAD_BUTTON_A;
public const int GLFW_GAMEPAD_BUTTON_CIRCLE = GLFW_GAMEPAD_BUTTON_B;
public const int GLFW_GAMEPAD_BUTTON_SQUARE = GLFW_GAMEPAD_BUTTON_X;
public const int GLFW_GAMEPAD_BUTTON_TRIANGLE = GLFW_GAMEPAD_BUTTON_Y;
public const int GLFW_GAMEPAD_AXIS_LEFT_X = 0;
public const int GLFW_GAMEPAD_AXIS_LEFT_Y = 1;
public const int GLFW_GAMEPAD_AXIS_RIGHT_X = 2;
public const int GLFW_GAMEPAD_AXIS_RIGHT_Y = 3;
public const int GLFW_GAMEPAD_AXIS_LEFT_TRIGGER = 4;
public const int GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER = 5;
public const int GLFW_GAMEPAD_AXIS_LAST = GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER;
public const int GLFW_NO_ERROR = 0;
public const int GLFW_NOT_INITIALIZED = 0x00010001;
public const int GLFW_NO_CURRENT_CONTEXT = 0x00010002;
public const int GLFW_INVALID_ENUM = 0x00010003;
public const int GLFW_INVALID_VALUE = 0x00010004;
public const int GLFW_OUT_OF_MEMORY = 0x00010005;
public const int GLFW_API_UNAVAILABLE = 0x00010006;
public const int GLFW_VERSION_UNAVAILABLE = 0x00010007;
public const int GLFW_PLATFORM_ERROR = 0x00010008;
public const int GLFW_FORMAT_UNAVAILABLE = 0x00010009;
public const int GLFW_NO_WINDOW_CONTEXT = 0x0001000A;
public const int GLFW_FOCUSED = 0x00020001;
public const int GLFW_ICONIFIED = 0x00020002;
public const int GLFW_RESIZABLE = 0x00020003;
public const int GLFW_VISIBLE = 0x00020004;
public const int GLFW_DECORATED = 0x00020005;
public const int GLFW_AUTO_ICONIFY = 0x00020006;
public const int GLFW_FLOATING = 0x00020007;
public const int GLFW_MAXIMIZED = 0x00020008;
public const int GLFW_CENTER_CURSOR = 0x00020009;
public const int GLFW_TRANSPARENT_FRAMEBUFFER = 0x0002000A;
public const int GLFW_HOVERED = 0x0002000B;
public const int GLFW_FOCUS_ON_SHOW = 0x0002000C;
public const int GLFW_RED_BITS = 0x00021001;
public const int GLFW_GREEN_BITS = 0x00021002;
public const int GLFW_BLUE_BITS = 0x00021003;
public const int GLFW_ALPHA_BITS = 0x00021004;
public const int GLFW_DEPTH_BITS = 0x00021005;
public const int GLFW_STENCIL_BITS = 0x00021006;
public const int GLFW_ACCUM_RED_BITS = 0x00021007;
public const int GLFW_ACCUM_GREEN_BITS = 0x00021008;
public const int GLFW_ACCUM_BLUE_BITS = 0x00021009;
public const int GLFW_ACCUM_ALPHA_BITS = 0x0002100A;
public const int GLFW_AUX_BUFFERS = 0x0002100B;
public const int GLFW_STEREO = 0x0002100C;
public const int GLFW_SAMPLES = 0x0002100D;
public const int GLFW_SRGB_CAPABLE = 0x0002100E;
public const int GLFW_REFRESH_RATE = 0x0002100F;
public const int GLFW_DOUBLEBUFFER = 0x00021010;
public const int GLFW_CLIENT_API = 0x00022001;
public const int GLFW_CONTEXT_VERSION_MAJOR = 0x00022002;
public const int GLFW_CONTEXT_VERSION_MINOR = 0x00022003;
public const int GLFW_CONTEXT_REVISION = 0x00022004;
public const int GLFW_CONTEXT_ROBUSTNESS = 0x00022005;
public const int GLFW_OPENGL_FORWARD_COMPAT = 0x00022006;
public const int GLFW_OPENGL_DEBUG_CONTEXT = 0x00022007;
public const int GLFW_OPENGL_PROFILE = 0x00022008;
public const int GLFW_CONTEXT_RELEASE_BEHAVIOR = 0x00022009;
public const int GLFW_CONTEXT_NO_ERROR = 0x0002200A;
public const int GLFW_CONTEXT_CREATION_API = 0x0002200B;
public const int GLFW_SCALE_TO_MONITOR = 0x0002200C;
public const int GLFW_COCOA_RETINA_FRAMEBUFFER = 0x00023001;
public const int GLFW_COCOA_FRAME_NAME = 0x00023002;
public const int GLFW_COCOA_GRAPHICS_SWITCHING = 0x00023003;
public const int GLFW_X11_CLASS_NAME = 0x00024001;
public const int GLFW_X11_INSTANCE_NAME = 0x00024002;
public const int GLFW_NO_API = 0;
public const int GLFW_OPENGL_API = 0x00030001;
public const int GLFW_OPENGL_ES_API = 0x00030002;
public const int GLFW_NO_ROBUSTNESS = 0;
public const int GLFW_NO_RESET_NOTIFICATION = 0x00031001;
public const int GLFW_LOSE_CONTEXT_ON_RESET = 0x00031002;
public const int GLFW_OPENGL_ANY_PROFILE = 0;
public const int GLFW_OPENGL_CORE_PROFILE = 0x00032001;
public const int GLFW_OPENGL_COMPAT_PROFILE = 0x00032002;
public const int GLFW_CURSOR = 0x00033001;
public const int GLFW_STICKY_KEYS = 0x00033002;
public const int GLFW_STICKY_MOUSE_BUTTONS = 0x00033003;
public const int GLFW_LOCK_KEY_MODS = 0x00033004;
public const int GLFW_RAW_MOUSE_MOTION = 0x00033005;
public const int GLFW_CURSOR_NORMAL = 0x00034001;
public const int GLFW_CURSOR_HIDDEN = 0x00034002;
public const int GLFW_CURSOR_DISABLED = 0x00034003;
public const int GLFW_ANY_RELEASE_BEHAVIOR = 0;
public const int GLFW_RELEASE_BEHAVIOR_FLUSH = 0x00035001;
public const int GLFW_RELEASE_BEHAVIOR_NONE = 0x00035002;
public const int GLFW_NATIVE_CONTEXT_API = 0x00036001;
public const int GLFW_EGL_CONTEXT_API = 0x00036002;
public const int GLFW_OSMESA_CONTEXT_API = 0x00036003;
public const int GLFW_ARROW_CURSOR = 0x00036001;
public const int GLFW_IBEAM_CURSOR = 0x00036002;
public const int GLFW_CROSSHAIR_CURSOR = 0x00036003;
public const int GLFW_HAND_CURSOR = 0x00036004;
public const int GLFW_HRESIZE_CURSOR = 0x00036005;
public const int GLFW_VRESIZE_CURSOR = 0x00036006;
public const int GLFW_CONNECTED = 0x00040001;
public const int GLFW_DISCONNECTED = 0x00040002;
public const int GLFW_JOYSTICK_HAT_BUTTONS = 0x00050001;
public const int GLFW_COCOA_CHDIR_RESOURCES = 0x00051001;
public const int GLFW_COCOA_MENUBAR = 0x00051002;
public const int GLFW_DONT_CARE = -1;
#endregion
}
}
@@ -25,8 +25,7 @@
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Graphics.OpenGL;
using StgSharp.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -0,0 +1,336 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="FrameworkConstant"
// Project: StgSharp
// AuthorGroup: Nitload
// Copyright (c) Nitload. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Graphics
{
public static class FrameworkConstant
{
#region glfw
public const int VERSION_MAJOR = 3;
public const int VERSION_MINOR = 3;
public const int VERSION_REVISION = 8;
public const int TRUE = 1;
public const int FALSE = 0;
public const int RELEASE = 0;
public const int PRESS = 1;
public const int REPEAT = 2;
public const int HAT_CENTERED = 0;
public const int HAT_UP = 1;
public const int HAT_RIGHT = 2;
public const int HAT_DOWN = 4;
public const int HAT_LEFT = 8;
public const int HAT_RIGHT_UP = HAT_RIGHT | HAT_UP;
public const int HAT_RIGHT_DOWN = HAT_RIGHT | HAT_DOWN;
public const int HAT_LEFT_UP = HAT_LEFT | HAT_UP;
public const int HAT_LEFT_DOWN = HAT_LEFT | HAT_DOWN;
public const int KEY_UNKNOWN = -1;
public const int KEY_SPACE = 32;
public const int KEY_APOSTROPHE = 39;
public const int KEY_COMMA = 44;
public const int KEY_MINUS = 45;
public const int KEY_PERIOD = 46;
public const int KEY_SLASH = 47;
public const int KEY_0 = 48;
public const int KEY_1 = 49;
public const int KEY_2 = 50;
public const int KEY_3 = 51;
public const int KEY_4 = 52;
public const int KEY_5 = 53;
public const int KEY_6 = 54;
public const int KEY_7 = 55;
public const int KEY_8 = 56;
public const int KEY_9 = 57;
public const int KEY_SEMICOLON = 59;
public const int KEY_EQUAL = 61;
public const int KEY_A = 65;
public const int KEY_B = 66;
public const int KEY_C = 67;
public const int KEY_D = 68;
public const int KEY_E = 69;
public const int KEY_F = 70;
public const int KEY_G = 71;
public const int KEY_H = 72;
public const int KEY_I = 73;
public const int KEY_J = 74;
public const int KEY_K = 75;
public const int KEY_L = 76;
public const int KEY_M = 77;
public const int KEY_N = 78;
public const int KEY_O = 79;
public const int KEY_P = 80;
public const int KEY_Q = 81;
public const int KEY_R = 82;
public const int KEY_S = 83;
public const int KEY_T = 84;
public const int KEY_U = 85;
public const int KEY_V = 86;
public const int KEY_W = 87;
public const int KEY_X = 88;
public const int KEY_Y = 89;
public const int KEY_Z = 90;
public const int KEY_LEFT_BRACKET = 91;
public const int KEY_BACKSLASH = 92;
public const int KEY_RIGHT_BRACKET = 93;
public const int KEY_GRAVE_ACCENT = 96;
public const int KEY_WORLD_1 = 161;
public const int KEY_WORLD_2 = 162;
public const int KEY_ESCAPE = 256;
public const int KEY_ENTER = 257;
public const int KEY_TAB = 258;
public const int KEY_BACKSPACE = 259;
public const int KEY_INSERT = 260;
public const int KEY_DELETE = 261;
public const int KEY_RIGHT = 262;
public const int KEY_LEFT = 263;
public const int KEY_DOWN = 264;
public const int KEY_UP = 265;
public const int KEY_PAGE_UP = 266;
public const int KEY_PAGE_DOWN = 267;
public const int KEY_HOME = 268;
public const int KEY_END = 269;
public const int KEY_CAPS_LOCK = 280;
public const int KEY_SCROLL_LOCK = 281;
public const int KEY_NUM_LOCK = 282;
public const int KEY_PRINT_SCREEN = 283;
public const int KEY_PAUSE = 284;
public const int KEY_F1 = 290;
public const int KEY_F2 = 291;
public const int KEY_F3 = 292;
public const int KEY_F4 = 293;
public const int KEY_F5 = 294;
public const int KEY_F6 = 295;
public const int KEY_F7 = 296;
public const int KEY_F8 = 297;
public const int KEY_F9 = 298;
public const int KEY_F10 = 299;
public const int KEY_F11 = 300;
public const int KEY_F12 = 301;
public const int KEY_F13 = 302;
public const int KEY_F14 = 303;
public const int KEY_F15 = 304;
public const int KEY_F16 = 305;
public const int KEY_F17 = 306;
public const int KEY_F18 = 307;
public const int KEY_F19 = 308;
public const int KEY_F20 = 309;
public const int KEY_F21 = 310;
public const int KEY_F22 = 311;
public const int KEY_F23 = 312;
public const int KEY_F24 = 313;
public const int KEY_F25 = 314;
public const int KEY_KP_0 = 320;
public const int KEY_KP_1 = 321;
public const int KEY_KP_2 = 322;
public const int KEY_KP_3 = 323;
public const int KEY_KP_4 = 324;
public const int KEY_KP_5 = 325;
public const int KEY_KP_6 = 326;
public const int KEY_KP_7 = 327;
public const int KEY_KP_8 = 328;
public const int KEY_KP_9 = 329;
public const int KEY_KP_DECIMAL = 330;
public const int KEY_KP_DIVIDE = 331;
public const int KEY_KP_MULTIPLY = 332;
public const int KEY_KP_SUBTRACT = 333;
public const int KEY_KP_ADD = 334;
public const int KEY_KP_ENTER = 335;
public const int KEY_KP_EQUAL = 336;
public const int KEY_LEFT_SHIFT = 340;
public const int KEY_LEFT_CONTROL = 341;
public const int KEY_LEFT_ALT = 342;
public const int KEY_LEFT_SUPER = 343;
public const int KEY_RIGHT_SHIFT = 344;
public const int KEY_RIGHT_CONTROL = 345;
public const int KEY_RIGHT_ALT = 346;
public const int KEY_RIGHT_SUPER = 347;
public const int KEY_MENU = 348;
public const int KEY_LAST = KEY_MENU;
public const int MOD_SHIFT = 0x0001;
public const int MOD_CONTROL = 0x0002;
public const int MOD_ALT = 0x0004;
public const int MOD_SUPER = 0x0008;
public const int MOD_CAPS_LOCK = 0x0010;
public const int MOD_NUM_LOCK = 0x0020;
public const int MOUSE_BUTTON_1 = 0;
public const int MOUSE_BUTTON_2 = 1;
public const int MOUSE_BUTTON_3 = 2;
public const int MOUSE_BUTTON_4 = 3;
public const int MOUSE_BUTTON_5 = 4;
public const int MOUSE_BUTTON_6 = 5;
public const int MOUSE_BUTTON_7 = 6;
public const int MOUSE_BUTTON_8 = 7;
public const int MOUSE_BUTTON_LAST = MOUSE_BUTTON_8;
public const int MOUSE_BUTTON_LEFT = MOUSE_BUTTON_1;
public const int MOUSE_BUTTON_RIGHT = MOUSE_BUTTON_2;
public const int MOUSE_BUTTON_MIDDLE = MOUSE_BUTTON_3;
public const int JOYSTICK_1 = 0;
public const int JOYSTICK_2 = 1;
public const int JOYSTICK_3 = 2;
public const int JOYSTICK_4 = 3;
public const int JOYSTICK_5 = 4;
public const int JOYSTICK_6 = 5;
public const int JOYSTICK_7 = 6;
public const int JOYSTICK_8 = 7;
public const int JOYSTICK_9 = 8;
public const int JOYSTICK_10 = 9;
public const int JOYSTICK_11 = 10;
public const int JOYSTICK_12 = 11;
public const int JOYSTICK_13 = 12;
public const int JOYSTICK_14 = 13;
public const int JOYSTICK_15 = 14;
public const int JOYSTICK_16 = 15;
public const int JOYSTICK_LAST = JOYSTICK_16;
public const int GAMEPAD_BUTTON_A = 0;
public const int GAMEPAD_BUTTON_B = 1;
public const int GAMEPAD_BUTTON_X = 2;
public const int GAMEPAD_BUTTON_Y = 3;
public const int GAMEPAD_BUTTON_LEFT_BUMPER = 4;
public const int GAMEPAD_BUTTON_RIGHT_BUMPER = 5;
public const int GAMEPAD_BUTTON_BACK = 6;
public const int GAMEPAD_BUTTON_START = 7;
public const int GAMEPAD_BUTTON_GUIDE = 8;
public const int GAMEPAD_BUTTON_LEFT_THUMB = 9;
public const int GAMEPAD_BUTTON_RIGHT_THUMB = 10;
public const int GAMEPAD_BUTTON_DPAD_UP = 11;
public const int GAMEPAD_BUTTON_DPAD_RIGHT = 12;
public const int GAMEPAD_BUTTON_DPAD_DOWN = 13;
public const int GAMEPAD_BUTTON_DPAD_LEFT = 14;
public const int GAMEPAD_BUTTON_LAST = GAMEPAD_BUTTON_DPAD_LEFT;
public const int GAMEPAD_BUTTON_CROSS = GAMEPAD_BUTTON_A;
public const int GAMEPAD_BUTTON_CIRCLE = GAMEPAD_BUTTON_B;
public const int GAMEPAD_BUTTON_SQUARE = GAMEPAD_BUTTON_X;
public const int GAMEPAD_BUTTON_TRIANGLE = GAMEPAD_BUTTON_Y;
public const int GAMEPAD_AXIS_LEFT_X = 0;
public const int GAMEPAD_AXIS_LEFT_Y = 1;
public const int GAMEPAD_AXIS_RIGHT_X = 2;
public const int GAMEPAD_AXIS_RIGHT_Y = 3;
public const int GAMEPAD_AXIS_LEFT_TRIGGER = 4;
public const int GAMEPAD_AXIS_RIGHT_TRIGGER = 5;
public const int GAMEPAD_AXIS_LAST = GAMEPAD_AXIS_RIGHT_TRIGGER;
public const int NO_ERROR = 0;
public const int NOT_INITIALIZED = 0x00010001;
public const int NO_CURRENT_CONTEXT = 0x00010002;
public const int INVALID_ENUM = 0x00010003;
public const int INVALID_VALUE = 0x00010004;
public const int OUT_OF_MEMORY = 0x00010005;
public const int API_UNAVAILABLE = 0x00010006;
public const int VERSION_UNAVAILABLE = 0x00010007;
public const int PLATFORM_ERROR = 0x00010008;
public const int FORMAT_UNAVAILABLE = 0x00010009;
public const int NO_WINDOW_CONTEXT = 0x0001000A;
public const int FOCUSED = 0x00020001;
public const int ICONIFIED = 0x00020002;
public const int RESIZABLE = 0x00020003;
public const int VISIBLE = 0x00020004;
public const int DECORATED = 0x00020005;
public const int AUTO_ICONIFY = 0x00020006;
public const int FLOATING = 0x00020007;
public const int MAXIMIZED = 0x00020008;
public const int CENTER_CURSOR = 0x00020009;
public const int TRANSPARENT_FRAMEBUFFER = 0x0002000A;
public const int HOVERED = 0x0002000B;
public const int FOCUS_ON_SHOW = 0x0002000C;
public const int RED_BITS = 0x00021001;
public const int GREEN_BITS = 0x00021002;
public const int BLUE_BITS = 0x00021003;
public const int ALPHA_BITS = 0x00021004;
public const int DEPTH_BITS = 0x00021005;
public const int STENCIL_BITS = 0x00021006;
public const int ACCUM_RED_BITS = 0x00021007;
public const int ACCUM_GREEN_BITS = 0x00021008;
public const int ACCUM_BLUE_BITS = 0x00021009;
public const int ACCUM_ALPHA_BITS = 0x0002100A;
public const int AUX_BUFFERS = 0x0002100B;
public const int STEREO = 0x0002100C;
public const int SAMPLES = 0x0002100D;
public const int SRGB_CAPABLE = 0x0002100E;
public const int REFRESH_RATE = 0x0002100F;
public const int DOUBLEBUFFER = 0x00021010;
public const int CLIENT_API = 0x00022001;
public const int CONTEXT_VERSION_MAJOR = 0x00022002;
public const int CONTEXT_VERSION_MINOR = 0x00022003;
public const int CONTEXT_REVISION = 0x00022004;
public const int CONTEXT_ROBUSTNESS = 0x00022005;
public const int OPENGL_FORWARD_COMPAT = 0x00022006;
public const int OPENGL_DEBUG_CONTEXT = 0x00022007;
public const int OPENGL_PROFILE = 0x00022008;
public const int CONTEXT_RELEASE_BEHAVIOR = 0x00022009;
public const int CONTEXT_NO_ERROR = 0x0002200A;
public const int CONTEXT_CREATION_API = 0x0002200B;
public const int SCALE_TO_MONITOR = 0x0002200C;
public const int COCOA_RETINA_FRAMEBUFFER = 0x00023001;
public const int COCOA_FRAME_NAME = 0x00023002;
public const int COCOA_GRAPHICS_SWITCHING = 0x00023003;
public const int X11_CLASS_NAME = 0x00024001;
public const int X11_INSTANCE_NAME = 0x00024002;
public const int NO_API = 0;
public const int OPENGL_API = 0x00030001;
public const int OPENGL_ES_API = 0x00030002;
public const int NO_ROBUSTNESS = 0;
public const int NO_RESET_NOTIFICATION = 0x00031001;
public const int LOSE_CONTEXT_ON_RESET = 0x00031002;
public const int OPENGL_ANY_PROFILE = 0;
public const int OPENGL_CORE_PROFILE = 0x00032001;
public const int OPENGL_COMPAT_PROFILE = 0x00032002;
public const int CURSOR = 0x00033001;
public const int STICKY_KEYS = 0x00033002;
public const int STICKY_MOUSE_BUTTONS = 0x00033003;
public const int LOCK_KEY_MODS = 0x00033004;
public const int RAW_MOUSE_MOTION = 0x00033005;
public const int CURSOR_NORMAL = 0x00034001;
public const int CURSOR_HIDDEN = 0x00034002;
public const int CURSOR_DISABLED = 0x00034003;
public const int ANY_RELEASE_BEHAVIOR = 0;
public const int RELEASE_BEHAVIOR_FLUSH = 0x00035001;
public const int RELEASE_BEHAVIOR_NONE = 0x00035002;
public const int NATIVE_CONTEXT_API = 0x00036001;
public const int EGL_CONTEXT_API = 0x00036002;
public const int OSMESA_CONTEXT_API = 0x00036003;
public const int ARROW_CURSOR = 0x00036001;
public const int IBEAM_CURSOR = 0x00036002;
public const int CROSSHAIR_CURSOR = 0x00036003;
public const int HAND_CURSOR = 0x00036004;
public const int HRESIZE_CURSOR = 0x00036005;
public const int VRESIZE_CURSOR = 0x00036006;
public const int CONNECTED = 0x00040001;
public const int DISCONNECTED = 0x00040002;
public const int JOYSTICK_HAT_BUTTONS = 0x00050001;
public const int COCOA_CHDIR_RESOURCES = 0x00051001;
public const int COCOA_MENUBAR = 0x00051002;
public const int DONT_CARE = -1;
#endregion
}
}
+6 -16
View File
@@ -26,18 +26,9 @@
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Graphics.OpenGL;
using StgSharp.Internal;
using StgSharp.Mathematics;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Graphics
{
@@ -56,13 +47,14 @@ namespace StgSharp.Graphics
internal Image(ImageInfo information)
{
_rawInfo = information;
_data = Array.Empty<byte>();
_data = [];
// int length = _rawInfo.width * _rawInfo.height * _rawInfo.channel;
}
public (int width, int height) Size
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => (_rawInfo.Width, _rawInfo.Height);
}
@@ -175,7 +167,10 @@ namespace StgSharp.Graphics
return _data;
}
public Image ProvideImage() => this;
public Image ProvideImage()
{
return this;
}
internal static Image FromMemory(ImageInfo info, byte[] data, int operationCount)
{
@@ -193,9 +188,4 @@ namespace StgSharp.Graphics
}
}
}
namespace StgSharp.Graphics.OpenGL
{
public static partial class GlHelper { }
}
+3 -3
View File
@@ -90,9 +90,9 @@ namespace StgSharp.Graphics
public override int GetHashCode()
{
int hash = 17;
hash = hash * 17 + width;
hash = hash * 17 + height;
hash = hash * 17 + (int)channel;
hash = (hash * 17) + width;
hash = (hash * 17) + height;
hash = (hash * 17) + (int)channel;
return hash;
}
@@ -26,6 +26,7 @@
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Collections;
using StgSharp.Graphics;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
@@ -25,8 +25,7 @@
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Graphics.OpenGL;
using StgSharp.Graphics;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -25,8 +25,7 @@
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Graphics.OpenGL;
using StgSharp.Graphics;
using System;
using System.Collections.Generic;
using System.Security.Principal;
@@ -25,6 +25,7 @@
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Graphics;
using StgSharp.HighPerformance;
using System;
@@ -25,6 +25,7 @@
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Graphics;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
@@ -25,6 +25,7 @@
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Graphics;
using StgSharp.Mathematics;
using StgSharp.Mathematics.Numeric;
@@ -26,6 +26,7 @@
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp;
using StgSharp.Graphics;
using StgSharp.Internal;
using System;
@@ -25,6 +25,7 @@
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Graphics;
using StgSharp.Mathematics.Graphic;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
@@ -1,41 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="glAPICalling"
// Project: StgSharp
// AuthorGroup: Nitload
// Copyright (c) Nitload. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Graphics.OpenGL
{
[AttributeUsage(AttributeTargets.Method)]
public sealed class OpenGLAPICallingAttribute : Attribute
{
public OpenGLAPICallingAttribute() { }
}
}
+157 -157
View File
@@ -65,7 +65,7 @@ namespace StgSharp.Graphics.OpenGL
#region glapi
internal unsafe delegate*<uint, GLfixed, void> glAccumxOES;
internal unsafe delegate*<uint, GlFixed, void> glAccumxOES;
internal unsafe delegate*<uint, ulong, uint, bool> glAcquireKeyedMutexWin32EXT;
internal unsafe delegate*<uint, void> glActiveProgramEXT;
internal unsafe delegate*<uint, uint, void> glActiveShaderProgram;
@@ -76,7 +76,7 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, uint, uint, uint, uint, uint, void> glAlphaFragmentOp1ATI;
internal unsafe delegate*<uint, uint, uint, uint, uint, uint, uint, uint, uint, void> glAlphaFragmentOp2ATI;
internal unsafe delegate*<uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, void> glAlphaFragmentOp3ATI;
internal unsafe delegate*<uint, GLfixed, void> glAlphaFuncxOES;
internal unsafe delegate*<uint, GlFixed, void> glAlphaFuncxOES;
internal unsafe delegate*<uint, void> glAlphaToCoverageDitherControlNV;
internal unsafe delegate*<void> glApplyFramebufferAttachmentCMAAINTEL;
internal unsafe delegate*<uint, void> glApplyTextureEXT;
@@ -165,12 +165,12 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<short, short, short, void> glBinormal3sEXT;
internal unsafe delegate*<short*, void> glBinormal3svEXT;
internal unsafe delegate*<uint, uint, void*, void> glBinormalPointerEXT;
internal unsafe delegate*<uint, uint, GLfixed, GLfixed, GLfixed, GLfixed, byte*, void> glBitmapxOES;
internal unsafe delegate*<uint, uint, GlFixed, GlFixed, GlFixed, GlFixed, byte*, void> glBitmapxOES;
internal unsafe delegate*<void> glBlendBarrierKHR;
internal unsafe delegate*<void> glBlendBarrierNV;
internal unsafe delegate*<float, float, float, float, void> glBlendColor;
internal unsafe delegate*<float, float, float, float, void> glBlendColorEXT;
internal unsafe delegate*<GLfixed, GLfixed, GLfixed, GLfixed, void> glBlendColorxOES;
internal unsafe delegate*<GlFixed, GlFixed, GlFixed, GlFixed, void> glBlendColorxOES;
internal unsafe delegate*<uint, void> glBlendEquation;
internal unsafe delegate*<uint, void> glBlendEquationEXT;
internal unsafe delegate*<uint, uint, void> glBlendEquationIndexedAMD;
@@ -217,7 +217,7 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, uint, void> glClampColor;
internal unsafe delegate*<uint, uint, void> glClampColorARB;
internal unsafe delegate*<uint, void> glClear;
internal unsafe delegate*<GLfixed, GLfixed, GLfixed, GLfixed, void> glClearAccumxOES;
internal unsafe delegate*<GlFixed, GlFixed, GlFixed, GlFixed, void> glClearAccumxOES;
internal unsafe delegate*<uint, uint, uint, uint, void*, void> glClearBufferData;
internal unsafe delegate*<uint, uint, IntPtr, UIntPtr, uint, uint, void*, void> glClearBufferSubData;
internal unsafe delegate*<uint, int, float, int, void> glClearBufferfi;
@@ -227,12 +227,12 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<float, float, float, float, void> glClearColor;
internal unsafe delegate*<int, int, int, int, void> glClearColorIiEXT;
internal unsafe delegate*<uint, uint, uint, uint, void> glClearColorIuiEXT;
internal unsafe delegate*<GLfixed, GLfixed, GLfixed, GLfixed, void> glClearColorxOES;
internal unsafe delegate*<GlFixed, GlFixed, GlFixed, GlFixed, void> glClearColorxOES;
internal unsafe delegate*<double, void> glClearDepth;
internal unsafe delegate*<double, void> glClearDepthdNV;
internal unsafe delegate*<float, void> glClearDepthf;
internal unsafe delegate*<GLclampf, void> glClearDepthfOES;
internal unsafe delegate*<GLfixed, void> glClearDepthxOES;
internal unsafe delegate*<GlClampF, void> glClearDepthfOES;
internal unsafe delegate*<GlFixed, void> glClearDepthxOES;
internal unsafe delegate*<uint, uint, uint, uint, void*, void> glClearNamedBufferData;
internal unsafe delegate*<uint, uint, uint, uint, void*, void> glClearNamedBufferDataEXT;
internal unsafe delegate*<uint, uint, IntPtr, UIntPtr, uint, uint, void*, void> glClearNamedBufferSubData;
@@ -251,23 +251,23 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<GLsync, uint, ulong, uint> glClientWaitSync;
internal unsafe delegate*<uint, uint, void> glClipControl;
internal unsafe delegate*<uint, float*, void> glClipPlanefOES;
internal unsafe delegate*<uint, GLfixed*, void> glClipPlanexOES;
internal unsafe delegate*<uint, GlFixed*, void> glClipPlanexOES;
internal unsafe delegate*<float, float, float, float, float, float, void> glColor3fVertex3fSUN;
internal unsafe delegate*<float*, float*, void> glColor3fVertex3fvSUN;
internal unsafe delegate*<glHalfNV, glHalfNV, glHalfNV, void> glColor3hNV;
internal unsafe delegate*<glHalfNV*, void> glColor3hvNV;
internal unsafe delegate*<GLfixed, GLfixed, GLfixed, void> glColor3xOES;
internal unsafe delegate*<GLfixed*, void> glColor3xvOES;
internal unsafe delegate*<glHalfNv, glHalfNv, glHalfNv, void> glColor3hNV;
internal unsafe delegate*<glHalfNv*, void> glColor3hvNV;
internal unsafe delegate*<GlFixed, GlFixed, GlFixed, void> glColor3xOES;
internal unsafe delegate*<GlFixed*, void> glColor3xvOES;
internal unsafe delegate*<float, float, float, float, float, float, float, float, float, float, void> glColor4fNormal3fVertex3fSUN;
internal unsafe delegate*<float*, float*, float*, void> glColor4fNormal3fVertex3fvSUN;
internal unsafe delegate*<glHalfNV, glHalfNV, glHalfNV, glHalfNV, void> glColor4hNV;
internal unsafe delegate*<glHalfNV*, void> glColor4hvNV;
internal unsafe delegate*<glHalfNv, glHalfNv, glHalfNv, glHalfNv, void> glColor4hNV;
internal unsafe delegate*<glHalfNv*, void> glColor4hvNV;
internal unsafe delegate*<byte, byte, byte, byte, float, float, void> glColor4ubVertex2fSUN;
internal unsafe delegate*<byte*, float*, void> glColor4ubVertex2fvSUN;
internal unsafe delegate*<byte, byte, byte, byte, float, float, float, void> glColor4ubVertex3fSUN;
internal unsafe delegate*<byte*, float*, void> glColor4ubVertex3fvSUN;
internal unsafe delegate*<GLfixed, GLfixed, GLfixed, GLfixed, void> glColor4xOES;
internal unsafe delegate*<GLfixed*, void> glColor4xvOES;
internal unsafe delegate*<GlFixed, GlFixed, GlFixed, GlFixed, void> glColor4xOES;
internal unsafe delegate*<GlFixed*, void> glColor4xvOES;
internal unsafe delegate*<int, uint, uint, void> glColorFormatNV;
internal unsafe delegate*<uint, uint, uint, uint, uint, uint, uint, void> glColorFragmentOp1ATI;
internal unsafe delegate*<uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, void> glColorFragmentOp2ATI;
@@ -330,8 +330,8 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, uint, float*, void> glConvolutionParameterfvEXT;
internal unsafe delegate*<uint, uint, int, void> glConvolutionParameteriEXT;
internal unsafe delegate*<uint, uint, int*, void> glConvolutionParameterivEXT;
internal unsafe delegate*<uint, uint, GLfixed, void> glConvolutionParameterxOES;
internal unsafe delegate*<uint, uint, GLfixed*, void> glConvolutionParameterxvOES;
internal unsafe delegate*<uint, uint, GlFixed, void> glConvolutionParameterxOES;
internal unsafe delegate*<uint, uint, GlFixed*, void> glConvolutionParameterxvOES;
internal unsafe delegate*<uint, uint, IntPtr, IntPtr, UIntPtr, void> glCopyBufferSubData;
internal unsafe delegate*<uint, uint, int, int, uint, void> glCopyColorSubTableEXT;
internal unsafe delegate*<uint, uint, int, int, uint, void> glCopyColorTableSGI;
@@ -446,7 +446,7 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<int, uint*, void> glDeleteVertexArrays;
internal unsafe delegate*<uint, uint*, void> glDeleteVertexArraysAPPLE;
internal unsafe delegate*<uint, void> glDeleteVertexShaderEXT;
internal unsafe delegate*<GLclampd, GLclampd, void> glDepthBoundsEXT;
internal unsafe delegate*<GlClampD, GlClampD, void> glDepthBoundsEXT;
internal unsafe delegate*<double, double, void> glDepthBoundsdNV;
internal unsafe delegate*<uint, void> glDepthFunc;
internal unsafe delegate*<bool, void> glDepthMask;
@@ -457,8 +457,8 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, double, double, void> glDepthRangeIndexeddNV;
internal unsafe delegate*<double, double, void> glDepthRangedNV;
internal unsafe delegate*<float, float, void> glDepthRangef;
internal unsafe delegate*<GLclampf, GLclampf, void> glDepthRangefOES;
internal unsafe delegate*<GLfixed, GLfixed, void> glDepthRangexOES;
internal unsafe delegate*<GlClampF, GlClampF, void> glDepthRangefOES;
internal unsafe delegate*<GlFixed, GlFixed, void> glDepthRangexOES;
internal unsafe delegate*<glHandleARB, glHandleARB, void> glDetachObjectARB;
internal unsafe delegate*<uint, uint, void> glDetachShader;
internal unsafe delegate*<uint, uint, float*, void> glDetailTexFuncSGIS;
@@ -552,15 +552,15 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<void> glEndTransformFeedbackNV;
internal unsafe delegate*<void> glEndVertexShaderEXT;
internal unsafe delegate*<uint, void> glEndVideoCaptureNV;
internal unsafe delegate*<GLfixed, void> glEvalCoord1xOES;
internal unsafe delegate*<GLfixed*, void> glEvalCoord1xvOES;
internal unsafe delegate*<GLfixed, GLfixed, void> glEvalCoord2xOES;
internal unsafe delegate*<GLfixed*, void> glEvalCoord2xvOES;
internal unsafe delegate*<GlFixed, void> glEvalCoord1xOES;
internal unsafe delegate*<GlFixed*, void> glEvalCoord1xvOES;
internal unsafe delegate*<GlFixed, GlFixed, void> glEvalCoord2xOES;
internal unsafe delegate*<GlFixed*, void> glEvalCoord2xvOES;
internal unsafe delegate*<uint, uint, void> glEvalMapsNV;
internal unsafe delegate*<void> glEvaluateDepthValuesARB;
internal unsafe delegate*<uint, uint, float*, void> glExecuteProgramNV;
internal unsafe delegate*<uint, uint, uint, void> glExtractComponentEXT;
internal unsafe delegate*<uint, uint, GLfixed*, void> glFeedbackBufferxOES;
internal unsafe delegate*<uint, uint, GlFixed*, void> glFeedbackBufferxOES;
internal unsafe delegate*<uint, uint, GLsync> glFenceSync;
internal unsafe delegate*<uint, uint, uint, uint, void> glFinalCombinerInputNV;
internal unsafe delegate*<void> glFinish;
@@ -586,11 +586,11 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<double*, void> glFogCoorddvEXT;
internal unsafe delegate*<float, void> glFogCoordfEXT;
internal unsafe delegate*<float*, void> glFogCoordfvEXT;
internal unsafe delegate*<glHalfNV, void> glFogCoordhNV;
internal unsafe delegate*<glHalfNV*, void> glFogCoordhvNV;
internal unsafe delegate*<glHalfNv, void> glFogCoordhNV;
internal unsafe delegate*<glHalfNv*, void> glFogCoordhvNV;
internal unsafe delegate*<uint, float*, void> glFogFuncSGIS;
internal unsafe delegate*<uint, GLfixed, void> glFogxOES;
internal unsafe delegate*<uint, GLfixed*, void> glFogxvOES;
internal unsafe delegate*<uint, GlFixed, void> glFogxOES;
internal unsafe delegate*<uint, GlFixed*, void> glFogxvOES;
internal unsafe delegate*<uint, uint, void> glFragmentColorMaterialSGIX;
internal unsafe delegate*<uint, void> glFragmentCoverageColorNV;
internal unsafe delegate*<uint, float, void> glFragmentLightModelfSGIX;
@@ -636,7 +636,7 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, void> glFreeObjectBufferATI;
internal unsafe delegate*<uint, void> glFrontFace;
internal unsafe delegate*<float, float, float, float, float, float, void> glFrustumfOES;
internal unsafe delegate*<GLfixed, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed, void> glFrustumxOES;
internal unsafe delegate*<GlFixed, GlFixed, GlFixed, GlFixed, GlFixed, GlFixed, void> glFrustumxOES;
internal unsafe delegate*<uint, uint> glGenAsyncMarkersSGIX;
internal unsafe delegate*<int, uint*, void> glGenBuffers;
internal unsafe delegate*<uint, uint*, void> glGenBuffersARB;
@@ -703,7 +703,7 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, IntPtr, UIntPtr, void*, void> glGetBufferSubData;
internal unsafe delegate*<uint, IntPtr, UIntPtr, void*, void> glGetBufferSubDataARB;
internal unsafe delegate*<uint, float*, void> glGetClipPlanefOES;
internal unsafe delegate*<uint, GLfixed*, void> glGetClipPlanexOES;
internal unsafe delegate*<uint, GlFixed*, void> glGetClipPlanexOES;
internal unsafe delegate*<uint, uint, uint, void*, void> glGetColorTableEXT;
internal unsafe delegate*<uint, uint, float*, void> glGetColorTableParameterfvEXT;
internal unsafe delegate*<uint, uint, float*, void> glGetColorTableParameterfvSGI;
@@ -725,7 +725,7 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, uint, uint, void*, void> glGetConvolutionFilterEXT;
internal unsafe delegate*<uint, uint, float*, void> glGetConvolutionParameterfvEXT;
internal unsafe delegate*<uint, uint, int*, void> glGetConvolutionParameterivEXT;
internal unsafe delegate*<uint, uint, GLfixed*, void> glGetConvolutionParameterxvOES;
internal unsafe delegate*<uint, uint, GlFixed*, void> glGetConvolutionParameterxvOES;
internal unsafe delegate*<uint, float*, void> glGetCoverageModulationTableNV;
internal unsafe delegate*<uint, uint, uint*, uint*, uint*, uint*, uint*, byte*, uint> glGetDebugMessageLog;
internal unsafe delegate*<uint, uint, uint*, uint*, uint*, uint*, byte*, uint> glGetDebugMessageLogAMD;
@@ -740,7 +740,7 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, uint, float*, void> glGetFinalCombinerInputParameterfvNV;
internal unsafe delegate*<uint, uint, int*, void> glGetFinalCombinerInputParameterivNV;
internal unsafe delegate*<uint*, void> glGetFirstPerfQueryIdINTEL;
internal unsafe delegate*<uint, GLfixed*, void> glGetFixedvOES;
internal unsafe delegate*<uint, GlFixed*, void> glGetFixedvOES;
internal unsafe delegate*<uint, uint, float*, void> glGetFloatIndexedvEXT;
internal unsafe delegate*<uint, uint, float*, void> glGetFloati_v;
internal unsafe delegate*<uint, uint, float*, void> glGetFloati_vEXT;
@@ -765,7 +765,7 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, bool, uint, uint, void*, void> glGetHistogramEXT;
internal unsafe delegate*<uint, uint, float*, void> glGetHistogramParameterfvEXT;
internal unsafe delegate*<uint, uint, int*, void> glGetHistogramParameterivEXT;
internal unsafe delegate*<uint, uint, GLfixed*, void> glGetHistogramParameterxvOES;
internal unsafe delegate*<uint, uint, GlFixed*, void> glGetHistogramParameterxvOES;
internal unsafe delegate*<uint, int, bool, int, uint, ulong> glGetImageHandleARB;
internal unsafe delegate*<uint, int, bool, int, uint, ulong> glGetImageHandleNV;
internal unsafe delegate*<uint, uint, float*, void> glGetImageTransformParameterfvHP;
@@ -785,7 +785,7 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, uint, bool*, void> glGetInvariantBooleanvEXT;
internal unsafe delegate*<uint, uint, float*, void> glGetInvariantFloatvEXT;
internal unsafe delegate*<uint, uint, int*, void> glGetInvariantIntegervEXT;
internal unsafe delegate*<uint, uint, GLfixed*, void> glGetLightxOES;
internal unsafe delegate*<uint, uint, GlFixed*, void> glGetLightxOES;
internal unsafe delegate*<uint, uint, float*, void> glGetListParameterfvSGIX;
internal unsafe delegate*<uint, uint, int*, void> glGetListParameterivSGIX;
internal unsafe delegate*<uint, uint, bool*, void> glGetLocalConstantBooleanvEXT;
@@ -796,8 +796,8 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, uint, uint, uint, uint, bool, void*, void> glGetMapControlPointsNV;
internal unsafe delegate*<uint, uint, float*, void> glGetMapParameterfvNV;
internal unsafe delegate*<uint, uint, int*, void> glGetMapParameterivNV;
internal unsafe delegate*<uint, uint, GLfixed*, void> glGetMapxvOES;
internal unsafe delegate*<uint, uint, GLfixed, void> glGetMaterialxOES;
internal unsafe delegate*<uint, uint, GlFixed*, void> glGetMapxvOES;
internal unsafe delegate*<uint, uint, GlFixed, void> glGetMaterialxOES;
internal unsafe delegate*<uint, uint, int, uint, uint*, void> glGetMemoryObjectDetachedResourcesuivNV;
internal unsafe delegate*<uint, uint, int*, void> glGetMemoryObjectParameterivEXT;
internal unsafe delegate*<uint, bool, uint, uint, void*, void> glGetMinmaxEXT;
@@ -870,7 +870,7 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, uint, uint, void*, uint*, void> glGetPerfQueryDataINTEL;
internal unsafe delegate*<byte*, uint*, void> glGetPerfQueryIdByNameINTEL;
internal unsafe delegate*<uint, uint, byte*, uint*, uint*, uint*, uint*, void> glGetPerfQueryInfoINTEL;
internal unsafe delegate*<uint, int, GLfixed*, void> glGetPixelMapxv;
internal unsafe delegate*<uint, int, GlFixed*, void> glGetPixelMapxv;
internal unsafe delegate*<uint, float*, void> glGetPixelTexGenParameterfvSGIS;
internal unsafe delegate*<uint, int*, void> glGetPixelTexGenParameterivSGIS;
internal unsafe delegate*<uint, uint, float*, void> glGetPixelTransformParameterfvEXT;
@@ -949,13 +949,13 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<GLsync, uint, uint, uint*, int*, void> glGetSynciv;
internal unsafe delegate*<uint, float*, void> glGetTexBumpParameterfvATI;
internal unsafe delegate*<uint, int*, void> glGetTexBumpParameterivATI;
internal unsafe delegate*<uint, uint, GLfixed*, void> glGetTexEnvxvOES;
internal unsafe delegate*<uint, uint, GlFixed*, void> glGetTexEnvxvOES;
internal unsafe delegate*<uint, uint, float*, void> glGetTexFilterFuncSGIS;
internal unsafe delegate*<uint, uint, GLfixed*, void> glGetTexGenxvOES;
internal unsafe delegate*<uint, uint, GlFixed*, void> glGetTexGenxvOES;
internal unsafe delegate*<uint, int, uint, uint, void*, void> glGetTexImage;
internal unsafe delegate*<uint, int, uint, float*, void> glGetTexLevelParameterfv;
internal unsafe delegate*<uint, int, uint, int*, void> glGetTexLevelParameteriv;
internal unsafe delegate*<uint, int, uint, GLfixed*, void> glGetTexLevelParameterxvOES;
internal unsafe delegate*<uint, int, uint, GlFixed*, void> glGetTexLevelParameterxvOES;
internal unsafe delegate*<uint, uint, int*, void> glGetTexParameterIiv;
internal unsafe delegate*<uint, uint, int*, void> glGetTexParameterIivEXT;
internal unsafe delegate*<uint, uint, uint*, void> glGetTexParameterIuiv;
@@ -963,7 +963,7 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, uint, void**, void> glGetTexParameterPointervAPPLE;
internal unsafe delegate*<uint, uint, float*, void> glGetTexParameterfv;
internal unsafe delegate*<uint, uint, int*, void> glGetTexParameteriv;
internal unsafe delegate*<uint, uint, GLfixed*, void> glGetTexParameterxvOES;
internal unsafe delegate*<uint, uint, GlFixed*, void> glGetTexParameterxvOES;
internal unsafe delegate*<uint, ulong> glGetTextureHandleARB;
internal unsafe delegate*<uint, ulong> glGetTextureHandleNV;
internal unsafe delegate*<uint, int, uint, uint, uint, void*, void> glGetTextureImage;
@@ -1094,12 +1094,12 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, uint, void*, void> glImportSemaphoreWin32NameEXT;
internal unsafe delegate*<uint, IntPtr, uint, GLsync> glImportSyncEXT;
internal unsafe delegate*<uint, uint, void> glIndexFormatNV;
internal unsafe delegate*<uint, GLclampf, void> glIndexFuncEXT;
internal unsafe delegate*<uint, GlClampF, void> glIndexFuncEXT;
internal unsafe delegate*<uint, uint, void> glIndexMaterialEXT;
internal unsafe delegate*<uint, uint, uint, void*, void> glIndexPointerEXT;
internal unsafe delegate*<uint, int, void**, int, void> glIndexPointerListIBM;
internal unsafe delegate*<GLfixed, void> glIndexxOES;
internal unsafe delegate*<GLfixed*, void> glIndexxvOES;
internal unsafe delegate*<GlFixed, void> glIndexxOES;
internal unsafe delegate*<GlFixed*, void> glIndexxvOES;
internal unsafe delegate*<uint, uint, uint, void> glInsertComponentEXT;
internal unsafe delegate*<uint, byte*, void> glInsertEventMarkerEXT;
internal unsafe delegate*<uint, int*, void> glInstrumentsBufferSGIX;
@@ -1163,12 +1163,12 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, uint, IntPtr, UIntPtr, void*, void> glLGPUNamedBufferSubDataNVX;
internal unsafe delegate*<uint, uint, uint, byte*, void> glLabelObjectEXT;
internal unsafe delegate*<uint, int, void> glLightEnviSGIX;
internal unsafe delegate*<uint, GLfixed, void> glLightModelxOES;
internal unsafe delegate*<uint, GLfixed*, void> glLightModelxvOES;
internal unsafe delegate*<uint, uint, GLfixed, void> glLightxOES;
internal unsafe delegate*<uint, uint, GLfixed*, void> glLightxvOES;
internal unsafe delegate*<uint, GlFixed, void> glLightModelxOES;
internal unsafe delegate*<uint, GlFixed*, void> glLightModelxvOES;
internal unsafe delegate*<uint, uint, GlFixed, void> glLightxOES;
internal unsafe delegate*<uint, uint, GlFixed*, void> glLightxvOES;
internal unsafe delegate*<float, void> glLineWidth;
internal unsafe delegate*<GLfixed, void> glLineWidthxOES;
internal unsafe delegate*<GlFixed, void> glLineWidthxOES;
internal unsafe delegate*<uint, void> glLinkProgram;
internal unsafe delegate*<glHandleARB, void> glLinkProgramARB;
internal unsafe delegate*<uint, uint, void**, uint*, uint*, uint*, uint, void> glListDrawCommandsStatesClientNV;
@@ -1177,11 +1177,11 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, uint, int, void> glListParameteriSGIX;
internal unsafe delegate*<uint, uint, int*, void> glListParameterivSGIX;
internal unsafe delegate*<uint, void> glLoadIdentityDeformationMapSGIX;
internal unsafe delegate*<GLfixed*, void> glLoadMatrixxOES;
internal unsafe delegate*<GlFixed*, void> glLoadMatrixxOES;
internal unsafe delegate*<uint, uint, uint, byte*, void> glLoadProgramNV;
internal unsafe delegate*<double*, void> glLoadTransposeMatrixdARB;
internal unsafe delegate*<float*, void> glLoadTransposeMatrixfARB;
internal unsafe delegate*<GLfixed*, void> glLoadTransposeMatrixxOES;
internal unsafe delegate*<GlFixed*, void> glLoadTransposeMatrixxOES;
internal unsafe delegate*<int, uint, void> glLockArraysEXT;
internal unsafe delegate*<uint, void> glLogicOp;
internal unsafe delegate*<uint, void> glMakeBufferNonResidentNV;
@@ -1196,14 +1196,14 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<ulong, void> glMakeTextureHandleNonResidentNV;
internal unsafe delegate*<ulong, void> glMakeTextureHandleResidentARB;
internal unsafe delegate*<ulong, void> glMakeTextureHandleResidentNV;
internal unsafe delegate*<uint, GLfixed, GLfixed, int, int, GLfixed, void> glMap1xOES;
internal unsafe delegate*<uint, GLfixed, GLfixed, int, int, GLfixed, GLfixed, int, int, GLfixed, void> glMap2xOES;
internal unsafe delegate*<uint, GlFixed, GlFixed, int, int, GlFixed, void> glMap1xOES;
internal unsafe delegate*<uint, GlFixed, GlFixed, int, int, GlFixed, GlFixed, int, int, GlFixed, void> glMap2xOES;
internal unsafe delegate*<uint, uint, void*> glMapBuffer;
internal unsafe delegate*<uint, uint, void*> glMapBufferARB;
internal unsafe delegate*<uint, IntPtr, UIntPtr, uint, void*> glMapBufferRange;
internal unsafe delegate*<uint, uint, uint, uint, uint, int, int, bool, void*, void> glMapControlPointsNV;
internal unsafe delegate*<int, GLfixed, GLfixed, void> glMapGrid1xOES;
internal unsafe delegate*<int, GLfixed, GLfixed, GLfixed, GLfixed, void> glMapGrid2xOES;
internal unsafe delegate*<int, GlFixed, GlFixed, void> glMapGrid1xOES;
internal unsafe delegate*<int, GlFixed, GlFixed, GlFixed, GlFixed, void> glMapGrid2xOES;
internal unsafe delegate*<uint, uint, void*> glMapNamedBuffer;
internal unsafe delegate*<uint, uint, void*> glMapNamedBufferEXT;
internal unsafe delegate*<uint, IntPtr, UIntPtr, uint, void*> glMapNamedBufferRange;
@@ -1216,8 +1216,8 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, uint, float, float, int, int, float*, void> glMapVertexAttrib1fAPPLE;
internal unsafe delegate*<uint, uint, double, double, int, int, double, double, int, int, double*, void> glMapVertexAttrib2dAPPLE;
internal unsafe delegate*<uint, uint, float, float, int, int, float, float, int, int, float*, void> glMapVertexAttrib2fAPPLE;
internal unsafe delegate*<uint, uint, GLfixed, void> glMaterialxOES;
internal unsafe delegate*<uint, uint, GLfixed*, void> glMaterialxvOES;
internal unsafe delegate*<uint, uint, GlFixed, void> glMaterialxOES;
internal unsafe delegate*<uint, uint, GlFixed*, void> glMaterialxvOES;
internal unsafe delegate*<uint, double, double, double, double, double, double, void> glMatrixFrustumEXT;
internal unsafe delegate*<int, uint, uint, void*, void> glMatrixIndexPointerARB;
internal unsafe delegate*<int, byte*, void> glMatrixIndexubvARB;
@@ -1256,10 +1256,10 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<float, void> glMinSampleShading;
internal unsafe delegate*<float, void> glMinSampleShadingARB;
internal unsafe delegate*<uint, uint, bool, void> glMinmaxEXT;
internal unsafe delegate*<GLfixed*, void> glMultMatrixxOES;
internal unsafe delegate*<GlFixed*, void> glMultMatrixxOES;
internal unsafe delegate*<double*, void> glMultTransposeMatrixdARB;
internal unsafe delegate*<float*, void> glMultTransposeMatrixfARB;
internal unsafe delegate*<GLfixed*, void> glMultTransposeMatrixxOES;
internal unsafe delegate*<GlFixed*, void> glMultTransposeMatrixxOES;
internal unsafe delegate*<uint, int*, uint*, uint, void> glMultiDrawArrays;
internal unsafe delegate*<uint, int*, uint*, uint, void> glMultiDrawArraysEXT;
internal unsafe delegate*<uint, void*, uint, uint, void> glMultiDrawArraysIndirect;
@@ -1290,56 +1290,56 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, double*, void> glMultiTexCoord1dvARB;
internal unsafe delegate*<uint, float, void> glMultiTexCoord1fARB;
internal unsafe delegate*<uint, float*, void> glMultiTexCoord1fvARB;
internal unsafe delegate*<uint, glHalfNV, void> glMultiTexCoord1hNV;
internal unsafe delegate*<uint, glHalfNV*, void> glMultiTexCoord1hvNV;
internal unsafe delegate*<uint, glHalfNv, void> glMultiTexCoord1hNV;
internal unsafe delegate*<uint, glHalfNv*, void> glMultiTexCoord1hvNV;
internal unsafe delegate*<uint, int, void> glMultiTexCoord1iARB;
internal unsafe delegate*<uint, int*, void> glMultiTexCoord1ivARB;
internal unsafe delegate*<uint, short, void> glMultiTexCoord1sARB;
internal unsafe delegate*<uint, short*, void> glMultiTexCoord1svARB;
internal unsafe delegate*<uint, GLfixed, void> glMultiTexCoord1xOES;
internal unsafe delegate*<uint, GLfixed*, void> glMultiTexCoord1xvOES;
internal unsafe delegate*<uint, GlFixed, void> glMultiTexCoord1xOES;
internal unsafe delegate*<uint, GlFixed*, void> glMultiTexCoord1xvOES;
internal unsafe delegate*<uint, sbyte, sbyte, void> glMultiTexCoord2bOES;
internal unsafe delegate*<uint, sbyte*, void> glMultiTexCoord2bvOES;
internal unsafe delegate*<uint, double, double, void> glMultiTexCoord2dARB;
internal unsafe delegate*<uint, double*, void> glMultiTexCoord2dvARB;
internal unsafe delegate*<uint, float, float, void> glMultiTexCoord2fARB;
internal unsafe delegate*<uint, float*, void> glMultiTexCoord2fvARB;
internal unsafe delegate*<uint, glHalfNV, glHalfNV, void> glMultiTexCoord2hNV;
internal unsafe delegate*<uint, glHalfNV*, void> glMultiTexCoord2hvNV;
internal unsafe delegate*<uint, glHalfNv, glHalfNv, void> glMultiTexCoord2hNV;
internal unsafe delegate*<uint, glHalfNv*, void> glMultiTexCoord2hvNV;
internal unsafe delegate*<uint, int, int, void> glMultiTexCoord2iARB;
internal unsafe delegate*<uint, int*, void> glMultiTexCoord2ivARB;
internal unsafe delegate*<uint, short, short, void> glMultiTexCoord2sARB;
internal unsafe delegate*<uint, short*, void> glMultiTexCoord2svARB;
internal unsafe delegate*<uint, GLfixed, GLfixed, void> glMultiTexCoord2xOES;
internal unsafe delegate*<uint, GLfixed*, void> glMultiTexCoord2xvOES;
internal unsafe delegate*<uint, GlFixed, GlFixed, void> glMultiTexCoord2xOES;
internal unsafe delegate*<uint, GlFixed*, void> glMultiTexCoord2xvOES;
internal unsafe delegate*<uint, sbyte, sbyte, sbyte, void> glMultiTexCoord3bOES;
internal unsafe delegate*<uint, sbyte*, void> glMultiTexCoord3bvOES;
internal unsafe delegate*<uint, double, double, double, void> glMultiTexCoord3dARB;
internal unsafe delegate*<uint, double*, void> glMultiTexCoord3dvARB;
internal unsafe delegate*<uint, float, float, float, void> glMultiTexCoord3fARB;
internal unsafe delegate*<uint, float*, void> glMultiTexCoord3fvARB;
internal unsafe delegate*<uint, glHalfNV, glHalfNV, glHalfNV, void> glMultiTexCoord3hNV;
internal unsafe delegate*<uint, glHalfNV*, void> glMultiTexCoord3hvNV;
internal unsafe delegate*<uint, glHalfNv, glHalfNv, glHalfNv, void> glMultiTexCoord3hNV;
internal unsafe delegate*<uint, glHalfNv*, void> glMultiTexCoord3hvNV;
internal unsafe delegate*<uint, int, int, int, void> glMultiTexCoord3iARB;
internal unsafe delegate*<uint, int*, void> glMultiTexCoord3ivARB;
internal unsafe delegate*<uint, short, short, short, void> glMultiTexCoord3sARB;
internal unsafe delegate*<uint, short*, void> glMultiTexCoord3svARB;
internal unsafe delegate*<uint, GLfixed, GLfixed, GLfixed, void> glMultiTexCoord3xOES;
internal unsafe delegate*<uint, GLfixed*, void> glMultiTexCoord3xvOES;
internal unsafe delegate*<uint, GlFixed, GlFixed, GlFixed, void> glMultiTexCoord3xOES;
internal unsafe delegate*<uint, GlFixed*, void> glMultiTexCoord3xvOES;
internal unsafe delegate*<uint, sbyte, sbyte, sbyte, sbyte, void> glMultiTexCoord4bOES;
internal unsafe delegate*<uint, sbyte*, void> glMultiTexCoord4bvOES;
internal unsafe delegate*<uint, double, double, double, double, void> glMultiTexCoord4dARB;
internal unsafe delegate*<uint, double*, void> glMultiTexCoord4dvARB;
internal unsafe delegate*<uint, float, float, float, float, void> glMultiTexCoord4fARB;
internal unsafe delegate*<uint, float*, void> glMultiTexCoord4fvARB;
internal unsafe delegate*<uint, glHalfNV, glHalfNV, glHalfNV, glHalfNV, void> glMultiTexCoord4hNV;
internal unsafe delegate*<uint, glHalfNV*, void> glMultiTexCoord4hvNV;
internal unsafe delegate*<uint, glHalfNv, glHalfNv, glHalfNv, glHalfNv, void> glMultiTexCoord4hNV;
internal unsafe delegate*<uint, glHalfNv*, void> glMultiTexCoord4hvNV;
internal unsafe delegate*<uint, int, int, int, int, void> glMultiTexCoord4iARB;
internal unsafe delegate*<uint, int*, void> glMultiTexCoord4ivARB;
internal unsafe delegate*<uint, short, short, short, short, void> glMultiTexCoord4sARB;
internal unsafe delegate*<uint, short*, void> glMultiTexCoord4svARB;
internal unsafe delegate*<uint, GLfixed, GLfixed, GLfixed, GLfixed, void> glMultiTexCoord4xOES;
internal unsafe delegate*<uint, GLfixed*, void> glMultiTexCoord4xvOES;
internal unsafe delegate*<uint, GlFixed, GlFixed, GlFixed, GlFixed, void> glMultiTexCoord4xOES;
internal unsafe delegate*<uint, GlFixed*, void> glMultiTexCoord4xvOES;
internal unsafe delegate*<uint, int, uint, uint, void*, void> glMultiTexCoordPointerEXT;
internal unsafe delegate*<uint, uint, uint, float, void> glMultiTexEnvfEXT;
internal unsafe delegate*<uint, uint, uint, float*, void> glMultiTexEnvfvEXT;
@@ -1431,10 +1431,10 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, void*, uint, uint> glNewObjectBufferATI;
internal unsafe delegate*<float, float, float, float, float, float, void> glNormal3fVertex3fSUN;
internal unsafe delegate*<float*, float*, void> glNormal3fVertex3fvSUN;
internal unsafe delegate*<glHalfNV, glHalfNV, glHalfNV, void> glNormal3hNV;
internal unsafe delegate*<glHalfNV*, void> glNormal3hvNV;
internal unsafe delegate*<GLfixed, GLfixed, GLfixed, void> glNormal3xOES;
internal unsafe delegate*<GLfixed*, void> glNormal3xvOES;
internal unsafe delegate*<glHalfNv, glHalfNv, glHalfNv, void> glNormal3hNV;
internal unsafe delegate*<glHalfNv*, void> glNormal3hvNV;
internal unsafe delegate*<GlFixed, GlFixed, GlFixed, void> glNormal3xOES;
internal unsafe delegate*<GlFixed*, void> glNormal3xvOES;
internal unsafe delegate*<uint, uint, void> glNormalFormatNV;
internal unsafe delegate*<uint, uint, uint, void*, void> glNormalPointerEXT;
internal unsafe delegate*<uint, int, void**, int, void> glNormalPointerListIBM;
@@ -1454,11 +1454,11 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, uint, uint, uint> glObjectPurgeableAPPLE;
internal unsafe delegate*<uint, uint, uint, uint> glObjectUnpurgeableAPPLE;
internal unsafe delegate*<float, float, float, float, float, float, void> glOrthofOES;
internal unsafe delegate*<GLfixed, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed, void> glOrthoxOES;
internal unsafe delegate*<GlFixed, GlFixed, GlFixed, GlFixed, GlFixed, GlFixed, void> glOrthoxOES;
internal unsafe delegate*<uint, float, void> glPNTrianglesfATI;
internal unsafe delegate*<uint, int, void> glPNTrianglesiATI;
internal unsafe delegate*<uint, uint, uint, void> glPassTexCoordATI;
internal unsafe delegate*<GLfixed, void> glPassThroughxOES;
internal unsafe delegate*<GlFixed, void> glPassThroughxOES;
internal unsafe delegate*<uint, float*, void> glPatchParameterfv;
internal unsafe delegate*<uint, int, void> glPatchParameteri;
internal unsafe delegate*<uint, uint, byte*, uint, uint, void*, void> glPathCommandsNV;
@@ -1482,21 +1482,21 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<void> glPauseTransformFeedback;
internal unsafe delegate*<void> glPauseTransformFeedbackNV;
internal unsafe delegate*<uint, uint, void*, void> glPixelDataRangeNV;
internal unsafe delegate*<uint, int, GLfixed*, void> glPixelMapx;
internal unsafe delegate*<uint, int, GlFixed*, void> glPixelMapx;
internal unsafe delegate*<uint, float, void> glPixelStoref;
internal unsafe delegate*<uint, int, void> glPixelStorei;
internal unsafe delegate*<uint, GLfixed, void> glPixelStorex;
internal unsafe delegate*<uint, GlFixed, void> glPixelStorex;
internal unsafe delegate*<uint, float, void> glPixelTexGenParameterfSGIS;
internal unsafe delegate*<uint, float*, void> glPixelTexGenParameterfvSGIS;
internal unsafe delegate*<uint, int, void> glPixelTexGenParameteriSGIS;
internal unsafe delegate*<uint, int*, void> glPixelTexGenParameterivSGIS;
internal unsafe delegate*<uint, void> glPixelTexGenSGIX;
internal unsafe delegate*<uint, GLfixed, void> glPixelTransferxOES;
internal unsafe delegate*<uint, GlFixed, void> glPixelTransferxOES;
internal unsafe delegate*<uint, uint, float, void> glPixelTransformParameterfEXT;
internal unsafe delegate*<uint, uint, float*, void> glPixelTransformParameterfvEXT;
internal unsafe delegate*<uint, uint, int, void> glPixelTransformParameteriEXT;
internal unsafe delegate*<uint, uint, int*, void> glPixelTransformParameterivEXT;
internal unsafe delegate*<GLfixed, GLfixed, void> glPixelZoomxOES;
internal unsafe delegate*<GlFixed, GlFixed, void> glPixelZoomxOES;
internal unsafe delegate*<uint, uint, uint, float, float*, float*, float*, float*, bool> glPointAlongPathNV;
internal unsafe delegate*<uint, float, void> glPointParameterf;
internal unsafe delegate*<uint, float, void> glPointParameterfARB;
@@ -1510,9 +1510,9 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, int, void> glPointParameteriNV;
internal unsafe delegate*<uint, int*, void> glPointParameteriv;
internal unsafe delegate*<uint, int*, void> glPointParameterivNV;
internal unsafe delegate*<uint, GLfixed*, void> glPointParameterxvOES;
internal unsafe delegate*<uint, GlFixed*, void> glPointParameterxvOES;
internal unsafe delegate*<float, void> glPointSize;
internal unsafe delegate*<GLfixed, void> glPointSizexOES;
internal unsafe delegate*<GlFixed, void> glPointSizexOES;
internal unsafe delegate*<uint*, int> glPollAsyncSGIX;
internal unsafe delegate*<int*, int> glPollInstrumentsSGIX;
internal unsafe delegate*<uint, uint, void> glPolygonMode;
@@ -1520,7 +1520,7 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<float, float, float, void> glPolygonOffsetClamp;
internal unsafe delegate*<float, float, float, void> glPolygonOffsetClampEXT;
internal unsafe delegate*<float, float, void> glPolygonOffsetEXT;
internal unsafe delegate*<GLfixed, GLfixed, void> glPolygonOffsetxOES;
internal unsafe delegate*<GlFixed, GlFixed, void> glPolygonOffsetxOES;
internal unsafe delegate*<void> glPopDebugGroup;
internal unsafe delegate*<void> glPopGroupMarkerEXT;
internal unsafe delegate*<uint, ulong, uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, uint, void> glPresentFrameDualFillNV;
@@ -1529,8 +1529,8 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, void> glPrimitiveRestartIndex;
internal unsafe delegate*<uint, void> glPrimitiveRestartIndexNV;
internal unsafe delegate*<void> glPrimitiveRestartNV;
internal unsafe delegate*<uint, uint*, GLclampf*, void> glPrioritizeTexturesEXT;
internal unsafe delegate*<uint, uint*, GLfixed*, void> glPrioritizeTexturesxOES;
internal unsafe delegate*<uint, uint*, GlClampF*, void> glPrioritizeTexturesEXT;
internal unsafe delegate*<uint, uint*, GlFixed*, void> glPrioritizeTexturesxOES;
internal unsafe delegate*<uint, uint, void*, uint, void> glProgramBinary;
internal unsafe delegate*<uint, uint, uint, uint, int*, void> glProgramBufferParametersIivNV;
internal unsafe delegate*<uint, uint, uint, uint, uint*, void> glProgramBufferParametersIuivNV;
@@ -1718,24 +1718,24 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, uint, uint, byte*, void> glPushDebugGroup;
internal unsafe delegate*<uint, byte*, void> glPushGroupMarkerEXT;
internal unsafe delegate*<uint, uint, void> glQueryCounter;
internal unsafe delegate*<GLfixed*, int*, uint> glQueryMatrixxOES;
internal unsafe delegate*<GlFixed*, int*, uint> glQueryMatrixxOES;
internal unsafe delegate*<uint, uint, uint, uint, void> glQueryObjectParameteruiAMD;
internal unsafe delegate*<uint, int, uint, int*, int> glQueryResourceNV;
internal unsafe delegate*<int, byte*, void> glQueryResourceTagNV;
internal unsafe delegate*<GLfixed, GLfixed, void> glRasterPos2xOES;
internal unsafe delegate*<GLfixed*, void> glRasterPos2xvOES;
internal unsafe delegate*<GLfixed, GLfixed, GLfixed, void> glRasterPos3xOES;
internal unsafe delegate*<GLfixed*, void> glRasterPos3xvOES;
internal unsafe delegate*<GLfixed, GLfixed, GLfixed, GLfixed, void> glRasterPos4xOES;
internal unsafe delegate*<GLfixed*, void> glRasterPos4xvOES;
internal unsafe delegate*<GlFixed, GlFixed, void> glRasterPos2xOES;
internal unsafe delegate*<GlFixed*, void> glRasterPos2xvOES;
internal unsafe delegate*<GlFixed, GlFixed, GlFixed, void> glRasterPos3xOES;
internal unsafe delegate*<GlFixed*, void> glRasterPos3xvOES;
internal unsafe delegate*<GlFixed, GlFixed, GlFixed, GlFixed, void> glRasterPos4xOES;
internal unsafe delegate*<GlFixed*, void> glRasterPos4xvOES;
internal unsafe delegate*<uint, bool, void> glRasterSamplesEXT;
internal unsafe delegate*<uint, void> glReadBuffer;
internal unsafe delegate*<int, void> glReadInstrumentsSGIX;
internal unsafe delegate*<int, int, int, int, uint, uint, void*, void> glReadPixels;
internal unsafe delegate*<int, int, int, int, uint, uint, uint, void*, void> glReadnPixels;
internal unsafe delegate*<int, int, int, int, uint, uint, uint, void*, void> glReadnPixelsARB;
internal unsafe delegate*<GLfixed, GLfixed, GLfixed, GLfixed, void> glRectxOES;
internal unsafe delegate*<GLfixed*, GLfixed*, void> glRectxvOES;
internal unsafe delegate*<GlFixed, GlFixed, GlFixed, GlFixed, void> glRectxOES;
internal unsafe delegate*<GlFixed*, GlFixed*, void> glRectxvOES;
internal unsafe delegate*<double*, void> glReferencePlaneSGIX;
internal unsafe delegate*<uint, ulong, bool> glReleaseKeyedMutexWin32EXT;
internal unsafe delegate*<void> glReleaseShaderCompiler;
@@ -1777,13 +1777,13 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<void> glResolveDepthValuesNV;
internal unsafe delegate*<void> glResumeTransformFeedback;
internal unsafe delegate*<void> glResumeTransformFeedbackNV;
internal unsafe delegate*<GLfixed, GLfixed, GLfixed, GLfixed, void> glRotatexOES;
internal unsafe delegate*<GlFixed, GlFixed, GlFixed, GlFixed, void> glRotatexOES;
internal unsafe delegate*<float, bool, void> glSampleCoverage;
internal unsafe delegate*<float, bool, void> glSampleCoverageARB;
internal unsafe delegate*<uint, uint, uint, void> glSampleMapATI;
internal unsafe delegate*<GLclampf, bool, void> glSampleMaskEXT;
internal unsafe delegate*<GlClampF, bool, void> glSampleMaskEXT;
internal unsafe delegate*<uint, uint, void> glSampleMaskIndexedNV;
internal unsafe delegate*<GLclampf, bool, void> glSampleMaskSGIS;
internal unsafe delegate*<GlClampF, bool, void> glSampleMaskSGIS;
internal unsafe delegate*<uint, uint, void> glSampleMaski;
internal unsafe delegate*<uint, void> glSamplePatternEXT;
internal unsafe delegate*<uint, void> glSamplePatternSGIS;
@@ -1793,7 +1793,7 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, uint, float*, void> glSamplerParameterfv;
internal unsafe delegate*<uint, uint, int, void> glSamplerParameteri;
internal unsafe delegate*<uint, uint, int*, void> glSamplerParameteriv;
internal unsafe delegate*<GLfixed, GLfixed, GLfixed, void> glScalexOES;
internal unsafe delegate*<GlFixed, GlFixed, GlFixed, void> glScalexOES;
internal unsafe delegate*<int, int, uint, uint, void> glScissor;
internal unsafe delegate*<uint, uint, int*, void> glScissorArrayv;
internal unsafe delegate*<uint, uint, int*, void> glScissorExclusiveArrayvNV;
@@ -1806,8 +1806,8 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<double*, void> glSecondaryColor3dvEXT;
internal unsafe delegate*<float, float, float, void> glSecondaryColor3fEXT;
internal unsafe delegate*<float*, void> glSecondaryColor3fvEXT;
internal unsafe delegate*<glHalfNV, glHalfNV, glHalfNV, void> glSecondaryColor3hNV;
internal unsafe delegate*<glHalfNV*, void> glSecondaryColor3hvNV;
internal unsafe delegate*<glHalfNv, glHalfNv, glHalfNv, void> glSecondaryColor3hNV;
internal unsafe delegate*<glHalfNv*, void> glSecondaryColor3hvNV;
internal unsafe delegate*<int, int, int, void> glSecondaryColor3iEXT;
internal unsafe delegate*<int*, void> glSecondaryColor3ivEXT;
internal unsafe delegate*<short, short, short, void> glSecondaryColor3sEXT;
@@ -1905,10 +1905,10 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, int*, void> glTexBumpParameterivATI;
internal unsafe delegate*<sbyte, void> glTexCoord1bOES;
internal unsafe delegate*<sbyte*, void> glTexCoord1bvOES;
internal unsafe delegate*<glHalfNV, void> glTexCoord1hNV;
internal unsafe delegate*<glHalfNV*, void> glTexCoord1hvNV;
internal unsafe delegate*<GLfixed, void> glTexCoord1xOES;
internal unsafe delegate*<GLfixed*, void> glTexCoord1xvOES;
internal unsafe delegate*<glHalfNv, void> glTexCoord1hNV;
internal unsafe delegate*<glHalfNv*, void> glTexCoord1hvNV;
internal unsafe delegate*<GlFixed, void> glTexCoord1xOES;
internal unsafe delegate*<GlFixed*, void> glTexCoord1xvOES;
internal unsafe delegate*<sbyte, sbyte, void> glTexCoord2bOES;
internal unsafe delegate*<sbyte*, void> glTexCoord2bvOES;
internal unsafe delegate*<float, float, float, float, float, float, float, float, void> glTexCoord2fColor3fVertex3fSUN;
@@ -1921,35 +1921,35 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<float*, float*, float*, void> glTexCoord2fNormal3fVertex3fvSUN;
internal unsafe delegate*<float, float, float, float, float, void> glTexCoord2fVertex3fSUN;
internal unsafe delegate*<float*, float*, void> glTexCoord2fVertex3fvSUN;
internal unsafe delegate*<glHalfNV, glHalfNV, void> glTexCoord2hNV;
internal unsafe delegate*<glHalfNV*, void> glTexCoord2hvNV;
internal unsafe delegate*<GLfixed, GLfixed, void> glTexCoord2xOES;
internal unsafe delegate*<GLfixed*, void> glTexCoord2xvOES;
internal unsafe delegate*<glHalfNv, glHalfNv, void> glTexCoord2hNV;
internal unsafe delegate*<glHalfNv*, void> glTexCoord2hvNV;
internal unsafe delegate*<GlFixed, GlFixed, void> glTexCoord2xOES;
internal unsafe delegate*<GlFixed*, void> glTexCoord2xvOES;
internal unsafe delegate*<sbyte, sbyte, sbyte, void> glTexCoord3bOES;
internal unsafe delegate*<sbyte*, void> glTexCoord3bvOES;
internal unsafe delegate*<glHalfNV, glHalfNV, glHalfNV, void> glTexCoord3hNV;
internal unsafe delegate*<glHalfNV*, void> glTexCoord3hvNV;
internal unsafe delegate*<GLfixed, GLfixed, GLfixed, void> glTexCoord3xOES;
internal unsafe delegate*<GLfixed*, void> glTexCoord3xvOES;
internal unsafe delegate*<glHalfNv, glHalfNv, glHalfNv, void> glTexCoord3hNV;
internal unsafe delegate*<glHalfNv*, void> glTexCoord3hvNV;
internal unsafe delegate*<GlFixed, GlFixed, GlFixed, void> glTexCoord3xOES;
internal unsafe delegate*<GlFixed*, void> glTexCoord3xvOES;
internal unsafe delegate*<sbyte, sbyte, sbyte, sbyte, void> glTexCoord4bOES;
internal unsafe delegate*<sbyte*, void> glTexCoord4bvOES;
internal unsafe delegate*<float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, void> glTexCoord4fColor4fNormal3fVertex4fSUN;
internal unsafe delegate*<float*, float*, float*, float*, void> glTexCoord4fColor4fNormal3fVertex4fvSUN;
internal unsafe delegate*<float, float, float, float, float, float, float, float, void> glTexCoord4fVertex4fSUN;
internal unsafe delegate*<float*, float*, void> glTexCoord4fVertex4fvSUN;
internal unsafe delegate*<glHalfNV, glHalfNV, glHalfNV, glHalfNV, void> glTexCoord4hNV;
internal unsafe delegate*<glHalfNV*, void> glTexCoord4hvNV;
internal unsafe delegate*<GLfixed, GLfixed, GLfixed, GLfixed, void> glTexCoord4xOES;
internal unsafe delegate*<GLfixed*, void> glTexCoord4xvOES;
internal unsafe delegate*<glHalfNv, glHalfNv, glHalfNv, glHalfNv, void> glTexCoord4hNV;
internal unsafe delegate*<glHalfNv*, void> glTexCoord4hvNV;
internal unsafe delegate*<GlFixed, GlFixed, GlFixed, GlFixed, void> glTexCoord4xOES;
internal unsafe delegate*<GlFixed*, void> glTexCoord4xvOES;
internal unsafe delegate*<int, uint, uint, void> glTexCoordFormatNV;
internal unsafe delegate*<int, uint, uint, uint, void*, void> glTexCoordPointerEXT;
internal unsafe delegate*<int, uint, int, void**, int, void> glTexCoordPointerListIBM;
internal unsafe delegate*<int, uint, void**, void> glTexCoordPointervINTEL;
internal unsafe delegate*<uint, uint, GLfixed, void> glTexEnvxOES;
internal unsafe delegate*<uint, uint, GLfixed*, void> glTexEnvxvOES;
internal unsafe delegate*<uint, uint, GlFixed, void> glTexEnvxOES;
internal unsafe delegate*<uint, uint, GlFixed*, void> glTexEnvxvOES;
internal unsafe delegate*<uint, uint, uint, float*, void> glTexFilterFuncSGIS;
internal unsafe delegate*<uint, uint, GLfixed, void> glTexGenxOES;
internal unsafe delegate*<uint, uint, GLfixed*, void> glTexGenxvOES;
internal unsafe delegate*<uint, uint, GlFixed, void> glTexGenxOES;
internal unsafe delegate*<uint, uint, GlFixed*, void> glTexGenxvOES;
internal unsafe delegate*<uint, int, int, uint, int, uint, uint, void*, void> glTexImage1D;
internal unsafe delegate*<uint, int, uint, uint, uint, int, uint, uint, void*, void> glTexImage2D;
internal unsafe delegate*<uint, uint, uint, uint, uint, bool, void> glTexImage2DMultisample;
@@ -1969,8 +1969,8 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, uint, float*, void> glTexParameterfv;
internal unsafe delegate*<uint, uint, int, void> glTexParameteri;
internal unsafe delegate*<uint, uint, int*, void> glTexParameteriv;
internal unsafe delegate*<uint, uint, GLfixed, void> glTexParameterxOES;
internal unsafe delegate*<uint, uint, GLfixed*, void> glTexParameterxvOES;
internal unsafe delegate*<uint, uint, GlFixed, void> glTexParameterxOES;
internal unsafe delegate*<uint, uint, GlFixed*, void> glTexParameterxvOES;
internal unsafe delegate*<uint, uint, void> glTexRenderbufferNV;
internal unsafe delegate*<uint, uint, uint, uint, void> glTexStorage1D;
internal unsafe delegate*<uint, uint, uint, uint, void> glTexStorage1DEXT;
@@ -2059,7 +2059,7 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, uint, byte*, byte*, uint, void> glTransformFeedbackVaryingsEXT;
internal unsafe delegate*<uint, uint, int*, uint, void> glTransformFeedbackVaryingsNV;
internal unsafe delegate*<uint, uint, uint, float*, void> glTransformPathNV;
internal unsafe delegate*<GLfixed, GLfixed, GLfixed, void> glTranslatexOES;
internal unsafe delegate*<GlFixed, GlFixed, GlFixed, void> glTranslatexOES;
internal unsafe delegate*<int, double, void> glUniform1d;
internal unsafe delegate*<int, uint, double*, void> glUniform1dv;
internal unsafe delegate*<int, float, void> glUniform1f;
@@ -2217,22 +2217,22 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, ushort*, void> glVariantusvEXT;
internal unsafe delegate*<sbyte, sbyte, void> glVertex2bOES;
internal unsafe delegate*<sbyte*, void> glVertex2bvOES;
internal unsafe delegate*<glHalfNV, glHalfNV, void> glVertex2hNV;
internal unsafe delegate*<glHalfNV*, void> glVertex2hvNV;
internal unsafe delegate*<GLfixed, void> glVertex2xOES;
internal unsafe delegate*<GLfixed*, void> glVertex2xvOES;
internal unsafe delegate*<glHalfNv, glHalfNv, void> glVertex2hNV;
internal unsafe delegate*<glHalfNv*, void> glVertex2hvNV;
internal unsafe delegate*<GlFixed, void> glVertex2xOES;
internal unsafe delegate*<GlFixed*, void> glVertex2xvOES;
internal unsafe delegate*<sbyte, sbyte, sbyte, void> glVertex3bOES;
internal unsafe delegate*<sbyte*, void> glVertex3bvOES;
internal unsafe delegate*<glHalfNV, glHalfNV, glHalfNV, void> glVertex3hNV;
internal unsafe delegate*<glHalfNV*, void> glVertex3hvNV;
internal unsafe delegate*<GLfixed, GLfixed, void> glVertex3xOES;
internal unsafe delegate*<GLfixed*, void> glVertex3xvOES;
internal unsafe delegate*<glHalfNv, glHalfNv, glHalfNv, void> glVertex3hNV;
internal unsafe delegate*<glHalfNv*, void> glVertex3hvNV;
internal unsafe delegate*<GlFixed, GlFixed, void> glVertex3xOES;
internal unsafe delegate*<GlFixed*, void> glVertex3xvOES;
internal unsafe delegate*<sbyte, sbyte, sbyte, sbyte, void> glVertex4bOES;
internal unsafe delegate*<sbyte*, void> glVertex4bvOES;
internal unsafe delegate*<glHalfNV, glHalfNV, glHalfNV, glHalfNV, void> glVertex4hNV;
internal unsafe delegate*<glHalfNV*, void> glVertex4hvNV;
internal unsafe delegate*<GLfixed, GLfixed, GLfixed, void> glVertex4xOES;
internal unsafe delegate*<GLfixed*, void> glVertex4xvOES;
internal unsafe delegate*<glHalfNv, glHalfNv, glHalfNv, glHalfNv, void> glVertex4hNV;
internal unsafe delegate*<glHalfNv*, void> glVertex4hvNV;
internal unsafe delegate*<GlFixed, GlFixed, GlFixed, void> glVertex4xOES;
internal unsafe delegate*<GlFixed*, void> glVertex4xvOES;
internal unsafe delegate*<uint, uint, uint, void> glVertexArrayAttribBinding;
internal unsafe delegate*<uint, uint, int, uint, bool, uint, void> glVertexArrayAttribFormat;
internal unsafe delegate*<uint, uint, int, uint, uint, void> glVertexArrayAttribIFormat;
@@ -2275,8 +2275,8 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, float*, void> glVertexAttrib1fv;
internal unsafe delegate*<uint, float*, void> glVertexAttrib1fvARB;
internal unsafe delegate*<uint, float*, void> glVertexAttrib1fvNV;
internal unsafe delegate*<uint, glHalfNV, void> glVertexAttrib1hNV;
internal unsafe delegate*<uint, glHalfNV*, void> glVertexAttrib1hvNV;
internal unsafe delegate*<uint, glHalfNv, void> glVertexAttrib1hNV;
internal unsafe delegate*<uint, glHalfNv*, void> glVertexAttrib1hvNV;
internal unsafe delegate*<uint, short, void> glVertexAttrib1s;
internal unsafe delegate*<uint, short, void> glVertexAttrib1sARB;
internal unsafe delegate*<uint, short, void> glVertexAttrib1sNV;
@@ -2295,8 +2295,8 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, float*, void> glVertexAttrib2fv;
internal unsafe delegate*<uint, float*, void> glVertexAttrib2fvARB;
internal unsafe delegate*<uint, float*, void> glVertexAttrib2fvNV;
internal unsafe delegate*<uint, glHalfNV, glHalfNV, void> glVertexAttrib2hNV;
internal unsafe delegate*<uint, glHalfNV*, void> glVertexAttrib2hvNV;
internal unsafe delegate*<uint, glHalfNv, glHalfNv, void> glVertexAttrib2hNV;
internal unsafe delegate*<uint, glHalfNv*, void> glVertexAttrib2hvNV;
internal unsafe delegate*<uint, short, short, void> glVertexAttrib2s;
internal unsafe delegate*<uint, short, short, void> glVertexAttrib2sARB;
internal unsafe delegate*<uint, short, short, void> glVertexAttrib2sNV;
@@ -2315,8 +2315,8 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, float*, void> glVertexAttrib3fv;
internal unsafe delegate*<uint, float*, void> glVertexAttrib3fvARB;
internal unsafe delegate*<uint, float*, void> glVertexAttrib3fvNV;
internal unsafe delegate*<uint, glHalfNV, glHalfNV, glHalfNV, void> glVertexAttrib3hNV;
internal unsafe delegate*<uint, glHalfNV*, void> glVertexAttrib3hvNV;
internal unsafe delegate*<uint, glHalfNv, glHalfNv, glHalfNv, void> glVertexAttrib3hNV;
internal unsafe delegate*<uint, glHalfNv*, void> glVertexAttrib3hvNV;
internal unsafe delegate*<uint, short, short, short, void> glVertexAttrib3s;
internal unsafe delegate*<uint, short, short, short, void> glVertexAttrib3sARB;
internal unsafe delegate*<uint, short, short, short, void> glVertexAttrib3sNV;
@@ -2351,8 +2351,8 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, float*, void> glVertexAttrib4fv;
internal unsafe delegate*<uint, float*, void> glVertexAttrib4fvARB;
internal unsafe delegate*<uint, float*, void> glVertexAttrib4fvNV;
internal unsafe delegate*<uint, glHalfNV, glHalfNV, glHalfNV, glHalfNV, void> glVertexAttrib4hNV;
internal unsafe delegate*<uint, glHalfNV*, void> glVertexAttrib4hvNV;
internal unsafe delegate*<uint, glHalfNv, glHalfNv, glHalfNv, glHalfNv, void> glVertexAttrib4hNV;
internal unsafe delegate*<uint, glHalfNv*, void> glVertexAttrib4hvNV;
internal unsafe delegate*<uint, int*, void> glVertexAttrib4iv;
internal unsafe delegate*<uint, int*, void> glVertexAttrib4ivARB;
internal unsafe delegate*<uint, short, short, short, short, void> glVertexAttrib4s;
@@ -2471,19 +2471,19 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<uint, int, uint, uint, void*, void> glVertexAttribPointerNV;
internal unsafe delegate*<uint, uint, double*, void> glVertexAttribs1dvNV;
internal unsafe delegate*<uint, uint, float*, void> glVertexAttribs1fvNV;
internal unsafe delegate*<uint, uint, glHalfNV*, void> glVertexAttribs1hvNV;
internal unsafe delegate*<uint, uint, glHalfNv*, void> glVertexAttribs1hvNV;
internal unsafe delegate*<uint, uint, short*, void> glVertexAttribs1svNV;
internal unsafe delegate*<uint, uint, double*, void> glVertexAttribs2dvNV;
internal unsafe delegate*<uint, uint, float*, void> glVertexAttribs2fvNV;
internal unsafe delegate*<uint, uint, glHalfNV*, void> glVertexAttribs2hvNV;
internal unsafe delegate*<uint, uint, glHalfNv*, void> glVertexAttribs2hvNV;
internal unsafe delegate*<uint, uint, short*, void> glVertexAttribs2svNV;
internal unsafe delegate*<uint, uint, double*, void> glVertexAttribs3dvNV;
internal unsafe delegate*<uint, uint, float*, void> glVertexAttribs3fvNV;
internal unsafe delegate*<uint, uint, glHalfNV*, void> glVertexAttribs3hvNV;
internal unsafe delegate*<uint, uint, glHalfNv*, void> glVertexAttribs3hvNV;
internal unsafe delegate*<uint, uint, short*, void> glVertexAttribs3svNV;
internal unsafe delegate*<uint, uint, double*, void> glVertexAttribs4dvNV;
internal unsafe delegate*<uint, uint, float*, void> glVertexAttribs4fvNV;
internal unsafe delegate*<uint, uint, glHalfNV*, void> glVertexAttribs4hvNV;
internal unsafe delegate*<uint, uint, glHalfNv*, void> glVertexAttribs4hvNV;
internal unsafe delegate*<uint, uint, short*, void> glVertexAttribs4svNV;
internal unsafe delegate*<uint, uint, byte*, void> glVertexAttribs4ubvNV;
internal unsafe delegate*<uint, uint, void> glVertexBindingDivisor;
@@ -2529,8 +2529,8 @@ namespace StgSharp.Graphics.OpenGL
internal unsafe delegate*<int, uint, uint, void*, void> glVertexWeightPointerEXT;
internal unsafe delegate*<float, void> glVertexWeightfEXT;
internal unsafe delegate*<float*, void> glVertexWeightfvEXT;
internal unsafe delegate*<glHalfNV, void> glVertexWeighthNV;
internal unsafe delegate*<glHalfNV*, void> glVertexWeighthvNV;
internal unsafe delegate*<glHalfNv, void> glVertexWeighthNV;
internal unsafe delegate*<glHalfNv*, void> glVertexWeighthvNV;
internal unsafe delegate*<uint, uint*, ulong*, uint> glVideoCaptureNV;
internal unsafe delegate*<uint, uint, uint, double*, void> glVideoCaptureStreamParameterdvNV;
internal unsafe delegate*<uint, uint, uint, float*, void> glVideoCaptureStreamParameterfvNV;
+1 -1
View File
@@ -72,7 +72,7 @@ namespace StgSharp.Graphics.OpenGL
IncompleteDrawBuffer = glConst.FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER, // GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER
IncompleteReadBuffer = glConst.FRAMEBUFFER_INCOMPLETE_READ_BUFFER, // GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER
Unsupported = glConst.FRAMEBUFFER_UNSUPPORTED, // GL_FRAMEBUFFER_UNSUPPORTED
IncompleteMultisample = glConst.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE, // GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE
IncompleteMultiSample = glConst.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE, // GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE
IncompleteLayerTargets = glConst.FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS // GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS
}
@@ -30,24 +30,26 @@ using StgSharp;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
namespace StgSharp.Graphics.OpenGL
{
public partial class OpenGLFunction
{
private Lazy<int> textureUnitCountGetter;
private Lazy<ConcurrentQueue<TextureUnit>> unusedTextureImageUintInitilizing;
private readonly int textureUnitCountGetter;
public int TextureUnitCount
{
get => textureUnitCountGetter.Value;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => textureUnitCountGetter;
}
private ConcurrentQueue<TextureUnit> UnusedTextureImageUint
{
get => unusedTextureImageUintInitilizing.Value;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get;
} = [];
internal void ReturnAvailableUnit(IEnumerable<TextureUnit> source)
{
+53 -82
View File
@@ -26,6 +26,7 @@
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Graphics;
using StgSharp.Graphics;
using StgSharp.Internal;
using StgSharp.Mathematics;
using StgSharp.Mathematics.Numeric;
@@ -46,32 +47,32 @@ namespace StgSharp.Graphics.OpenGL
public unsafe partial class OpenGLFunction
{
private static Dictionary<IntPtr, OpenGLFunction> contextToGLMap = new Dictionary<IntPtr, OpenGLFunction>(
);
private static ThreadLocal<OpenGLFunction> _currentGL = new ThreadLocal<OpenGLFunction>();
private static readonly Dictionary<IntPtr, OpenGLFunction> contextToGLMap = [];
private static readonly ThreadLocal<OpenGLFunction> _currentGL = new ThreadLocal<OpenGLFunction>();
private OpenglContext* _context;
private Lazy<int> _attachmentColorRange;
private OpenGLFunction()
{
textureUnitCountGetter = new Lazy<int>(
() => GetMaskInteger(glConst.MAX_TEXTURE_IMAGE_UNITS));
unusedTextureImageUintInitilizing = new Lazy<ConcurrentQueue<TextureUnit>>(
InitializeUnusedTextureImageUint);
textureUnitCountGetter = glConst.MAX_TEXTURE_IMAGE_UNITS;
UnusedTextureImageUint = [];
_attachmentColorRange = new Lazy<int>(
() => { return GetMaskInteger((uint)glConst.MAX_COLOR_ATTACHMENTS); });
}
public int AttachmentColorRange
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => _attachmentColorRange.Value;
}
public static OpenGLFunction CurrentGL
{
get { return _currentGL.Value; }
internal set { _currentGL.Value = value; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => _currentGL.Value!;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal set => _currentGL.Value = value;
}
internal IntPtr ContextHandle => (IntPtr)_context;
@@ -122,7 +123,7 @@ namespace StgSharp.Graphics.OpenGL
/// <summary>
/// Bind a frame BufferHandle to a frame BufferHandle target Same function as <see ///
/// href="https://docs._gl/gl3/glBindFramebuffer"> glBindFramebuffer </see>.
/// href="https://docs._gl/gl3/glBindFramebuffer">glBindFramebuffer</see>.
/// </summary>
/// <param _label="target">
/// The frame BufferHandle target of the binding operation.
@@ -200,8 +201,8 @@ namespace StgSharp.Graphics.OpenGL
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void CombineFrameBufferRenderBuffer(FrameBufferAttachment attachment, GlHandle rboHandle)
{
Context.glFramebufferRenderbuffer(
glConst.FRAMEBUFFER, (uint)attachment, glConst.RENDERBUFFER, rboHandle.Value);
Context.glFramebufferRenderbuffer(glConst.FRAMEBUFFER, (uint)attachment, glConst.RENDERBUFFER,
rboHandle.Value);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -213,13 +214,13 @@ namespace StgSharp.Graphics.OpenGL
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe GlHandle CreateGraphicProgram()
{
return GlHandle.Alloc(Context.glCreateProgram());
return GlHandle.Create(Context.glCreateProgram());
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public GlHandle CreateProgram()
{
return GlHandle.Alloc(Context.glCreateProgram());
return GlHandle.Create(Context.glCreateProgram());
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -245,7 +246,7 @@ namespace StgSharp.Graphics.OpenGL
uint error = Context.glGetError();
throw new InvalidOperationException($"Failed in creating shader: {error}");
}
ret[i] = GlHandle.Alloc(id);
ret[i] = GlHandle.Create(id);
}
return ret;
}
@@ -273,9 +274,8 @@ namespace StgSharp.Graphics.OpenGL
/// <summary>
/// Delete a render BufferHandle object Very simlilar function as <see ///
/// href="https://docs.gl/gl3/glDeleteRenderbuffers"> glDeleteRenderbuffers </see>. The
/// only deifference is that this mehtod can only delete one renderbuffer at the same
/// time.
/// href="https://docs.gl/gl3/glDeleteRenderbuffers">glDeleteRenderbuffers</see>. The only
/// deifference is that this mehtod can only delete one renderbuffer at the same time.
/// </summary>
/// <param _label="bufferHandle">
/// Handle to BufferHandle to delete.
@@ -369,8 +369,7 @@ namespace StgSharp.Graphics.OpenGL
GlHandle textureHandle,
int level)
{
Context.glFramebufferTexture2D(
(uint)target, attachment, (uint)texTarget, textureHandle.Value, level);
Context.glFramebufferTexture2D((uint)target, attachment, (uint)texTarget, textureHandle.Value, level);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -446,8 +445,7 @@ namespace StgSharp.Graphics.OpenGL
public string GetShaderStatus(Shader s, int index, int key)
{
IntPtr sptr = IntPtr.Zero;
if (GraphicFramework.glCheckShaderStatus(ref Context, s.handle[index].Value, key,
ref sptr) == 0) {
if (GraphicFramework.glCheckShaderStatus(ref Context, s.handle[index].Value, key, ref sptr) == 0) {
return Marshal.PtrToStringAnsi(sptr);
}
return string.Empty;
@@ -462,13 +460,9 @@ namespace StgSharp.Graphics.OpenGL
T[] dataStream)
where T: unmanaged,INumber<T>
{
#pragma warning disable CS8500
fixed (T* tptr = dataStream)
{
Context.glGetTexImage((uint)target, level, (uint)channel, (uint)channelLayout,
tptr);
fixed (T* tptr = dataStream) {
Context.glGetTexImage((uint)target, level, (uint)channel, (uint)channelLayout, tptr);
}
#pragma warning restore CS8500
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -495,7 +489,7 @@ namespace StgSharp.Graphics.OpenGL
throw new UniformEmptyReferenceException(nameof(program), name);
}
#endif
return GlHandle.SignedAlloc(ret);
return GlHandle.CreateSigned(ret);
}
}
@@ -546,8 +540,8 @@ namespace StgSharp.Graphics.OpenGL
ref byte[] stream)
{
fixed (byte* bptr = stream) {
Context.glReadPixels
(beginPosition.X, beginPosition.Y, size.width, size.height, (uint)format, (uint)dataType, bptr);
Context.glReadPixels(beginPosition.X, beginPosition.Y, size.width, size.height, (uint)format,
(uint)dataType, bptr);
}
}
@@ -562,8 +556,8 @@ namespace StgSharp.Graphics.OpenGL
throw new GlArrayFormatException(dataType, "i.PixelArray");
}
fixed (byte* bptr = pixels) {
Context.glReadPixels
(beginPosition.X, beginPosition.Y, i.Width, i.Height, (uint)format, (uint)dataType, bptr);
Context.glReadPixels(beginPosition.X, beginPosition.Y, i.Width, i.Height, (uint)format, (uint)dataType,
bptr);
}
i.PixelUpdateCount++;
}
@@ -573,9 +567,9 @@ namespace StgSharp.Graphics.OpenGL
where T: unmanaged,INumber<T>
{
int size = Marshal.SizeOf<T>();
#pragma warning disable CS8500
T* p = &bufferData;
#pragma warning restore CS8500
Context.glBufferData((uint)bufferType, (IntPtr)size, (IntPtr)p, (uint)usage);
}
@@ -587,12 +581,9 @@ namespace StgSharp.Graphics.OpenGL
if (bufferArray == null) {
return;
}
#pragma warning disable CS8500
fixed (void* bufferPtr = bufferArray)
#pragma warning restore CS8500
{
Context.glBufferData((uint)bufferType, (IntPtr)size, (IntPtr)bufferPtr,
(uint)usage);
fixed (void* bufferPtr = bufferArray) {
Context.glBufferData((uint)bufferType, (IntPtr)size, (IntPtr)bufferPtr, (uint)usage);
}
}
@@ -604,12 +595,9 @@ namespace StgSharp.Graphics.OpenGL
if (bufferSpan == null) {
return;
}
#pragma warning disable CS8500
fixed (void* bufferPtr = bufferSpan)
#pragma warning restore CS8500
{
Context.glBufferData((uint)bufferType, (IntPtr)size, (IntPtr)bufferPtr,
(uint)usage);
fixed (void* bufferPtr = bufferSpan) {
Context.glBufferData((uint)bufferType, (IntPtr)size, (IntPtr)bufferPtr, (uint)usage);
}
}
@@ -622,12 +610,9 @@ namespace StgSharp.Graphics.OpenGL
return;
}
#pragma warning disable CS8500
fixed (void* bufferPtr = bufferArray)
#pragma warning restore CS8500
{
Context.glBufferData((uint)bufferType, (IntPtr)size, (IntPtr)bufferPtr,
(uint)usage);
fixed (void* bufferPtr = bufferArray) {
Context.glBufferData((uint)bufferType, (IntPtr)size, (IntPtr)bufferPtr, (uint)usage);
}
}
@@ -636,12 +621,9 @@ namespace StgSharp.Graphics.OpenGL
where T: unmanaged, IUnmanagedVector<T>
{
int size = bufferSpan.Length * Marshal.SizeOf(typeof(T));
#pragma warning disable CS8500
fixed (void* bufferPtr = bufferSpan)
#pragma warning restore CS8500
{
Context.glBufferData((uint)bufferType, (IntPtr)size, (IntPtr)bufferPtr,
(uint)usage);
fixed (void* bufferPtr = bufferSpan) {
Context.glBufferData((uint)bufferType, (IntPtr)size, (IntPtr)bufferPtr, (uint)usage);
}
}
@@ -653,12 +635,8 @@ namespace StgSharp.Graphics.OpenGL
if (bufferArray == null) {
return;
}
#pragma warning disable CS8500
fixed (void* bufferPtr = bufferArray)
#pragma warning restore CS8500
{
Context.glBufferData((uint)bufferType, (IntPtr)size, (IntPtr)bufferPtr,
(uint)usage);
fixed (void* bufferPtr = bufferArray) {
Context.glBufferData((uint)bufferType, (IntPtr)size, (IntPtr)bufferPtr, (uint)usage);
}
}
@@ -667,8 +645,7 @@ namespace StgSharp.Graphics.OpenGL
RenderBufferInternalFormat internalFormat,
(int width, int height) size)
{
Context.glRenderbufferStorage(
glConst.RENDERBUFFER, (uint)internalFormat, size.width, size.height);
Context.glRenderbufferStorage(glConst.RENDERBUFFER, (uint)internalFormat, size.width, size.height);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -676,8 +653,8 @@ namespace StgSharp.Graphics.OpenGL
RenderBufferInternalFormat internalFormat,
(uint width, uint height) size)
{
Context.glRenderbufferStorage(
glConst.RENDERBUFFER, (uint)internalFormat, (int)size.width, (int)size.height);
Context.glRenderbufferStorage(glConst.RENDERBUFFER, (uint)internalFormat, (int)size.width,
(int)size.height);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -700,14 +677,12 @@ namespace StgSharp.Graphics.OpenGL
T[] pixels)
where T: unmanaged, INumber<T>
{
#pragma warning disable CS8500
fixed (T* tptr = pixels)
{
T* ptr = ((pixels == null) || (pixels.Length == 0)) ? (T*)IntPtr.Zero : tptr;
Context.glTexImage2D
((uint)target, level, (uint)sourceChannel, width, height, 0, (uint)targetChannel, (uint)type, tptr);
Context.glTexImage2D((uint)target, level, (uint)sourceChannel, width, height, 0, (uint)targetChannel,
(uint)type, tptr);
}
#pragma warning restore CS8500
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -722,13 +697,10 @@ namespace StgSharp.Graphics.OpenGL
Span<T> pixelSpan)
where T: unmanaged, INumber<T>
{
#pragma warning disable CS8500
fixed (T* tptr = pixelSpan)
{
Context.glTexImage2D
((uint)target, level, (uint)sourceChannel, width, height, 0, (uint)targetChannel, (uint)type, tptr);
fixed (T* tPtr = pixelSpan) {
Context.glTexImage2D((uint)target, level, (uint)sourceChannel, width, height, 0, (uint)targetChannel,
(uint)type, tPtr);
}
#pragma warning restore CS8500
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -768,8 +740,7 @@ namespace StgSharp.Graphics.OpenGL
internal static OpenGLFunction BuildGlFunctionPackage(IntPtr handle)
{
OpenGLFunction pack;
if (contextToGLMap.TryGetValue(handle, out pack)) {
if (contextToGLMap.TryGetValue(handle, out OpenGLFunction pack)) {
return pack;
}
pack = new OpenGLFunction
@@ -782,7 +753,7 @@ namespace StgSharp.Graphics.OpenGL
~OpenGLFunction()
{
contextToGLMap.Remove(ContextHandle);
_ = contextToGLMap.Remove(ContextHandle);
}
}
@@ -1,69 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="glHalfNV"
// Project: StgSharp
// AuthorGroup: Nitload
// Copyright (c) Nitload. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Graphics.OpenGL
{
[StructLayout(LayoutKind.Explicit, Size = 16)]
public struct glHalfNV
{
[FieldOffset(0)] public short binary;
public glHalfNV(short bin)
{
binary = bin;
}
public static glHalfNV FromInt16(short x)
{
return new glHalfNV(x);
}
public static short ToInt16(glHalfNV half)
{
return half.binary;
}
public static explicit operator glHalfNV(short x)
{
return new glHalfNV(x);
}
public static explicit operator short(glHalfNV x)
{
return x.binary;
}
}
}
+3 -2
View File
@@ -48,6 +48,7 @@ namespace StgSharp.Graphics.OpenGL
public static GlHandle Zero
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => new GlHandle
{
Value = 0
@@ -55,7 +56,7 @@ namespace StgSharp.Graphics.OpenGL
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static GlHandle Alloc(uint value)
public static GlHandle Create(uint value)
{
return new GlHandle
{
@@ -64,7 +65,7 @@ namespace StgSharp.Graphics.OpenGL
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static GlHandle SignedAlloc(int value)
public static GlHandle CreateSigned(int value)
{
return new GlHandle
{
@@ -39,7 +39,7 @@ namespace StgSharp.Graphics.OpenGL
{
private static ConcurrentDictionary<Thread, glRender> threadLocalIndex
= new ConcurrentDictionary<Thread, glRender>();
= new();
private readonly SynchronizationContext mainThreadContext = SynchronizationContext.Current;
}
+47 -27
View File
@@ -35,40 +35,60 @@ namespace StgSharp.Internal.OpenGL
{
internal delegate void GLVULKANPROCNV();
public unsafe struct glHandleARB
public unsafe struct glHandleARB(IntPtr value) { }
/// <summary>
/// OpenGL numeric type. An IEEE-754 floating-point value, clamped to the range [0,1].
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct GlClampF
{
private dynamic value;
public float value;
public unsafe glHandleARB(dynamic value)
public GlClampF(float a)
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
if (value.GetType().Name != "Uint32")
{
goto errorLog;
}
this.value = value;
} else
{
if (value.GetType().Name != "IntPtr")
{
goto errorLog;
}
this.value = value;
}
errorLog:
{
DefaultLog.InternalWriteLog(
$"{value.GetType().Name} does not match definination of GLhandlARB on OS {Environment.OSVersion.Platform} ",
LogType.Error);
}
value = a;
}
public static implicit operator uint(glHandleARB value)
}
[StructLayout(LayoutKind.Explicit, Size = 16)]
public struct glHalfNv(Half bin)
{
[FieldOffset(0)] public Half binary = bin;
public float ToSingle()
{
return (uint)value;
return (float)binary;
}
}
[StructLayout(LayoutKind.Explicit, Size = 8)]
public struct GlFixed
{
[FieldOffset(0)] public int All;
[FieldOffset(0)] public short Decimals;
[FieldOffset(4)] public short Integer;
}
/// <summary>
/// OpenGL numeric type. An IEEE-754 double precision floating-point value, clamped to the
/// range [0,1].
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct GlClampD
{
public double value;
public GlClampD(double a)
{
value = a;
}
}
@@ -25,6 +25,7 @@
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Graphics;
using StgSharp.Graphics.OpenGL;
using System;
@@ -29,6 +29,7 @@ using StgSharp.Mathematics.Graphic;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
namespace StgSharp.Graphics
{
@@ -46,11 +47,13 @@ namespace StgSharp.Graphics
public ref Vec2 this[int index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => ref _texCoord[index];
}
public Span<Vec2> TextureCoordinate
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => new Span<Vec2>(_texCoord);
}
-7
View File
@@ -25,15 +25,8 @@
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Graphics;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
#if Windows
// using Windows.Win32;
@@ -30,6 +30,7 @@ using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -39,22 +40,19 @@ namespace StgSharp.Threading
public class FrameworkSyncContext : SynchronizationContext
{
private static readonly FrameworkSyncContext _mainThreadContext = new FrameworkSyncContext();
private readonly BlockingCollection<SendOrPostCallback> _syncContexts = new BlockingCollection<SendOrPostCallback>(
);
private readonly BlockingCollection<SendOrPostCallback> _syncContexts = [];
private readonly Thread _mainThread = Thread.CurrentThread;
public FrameworkSyncContext()
{
_syncContexts = new BlockingCollection<SendOrPostCallback>();
_mainThread = Thread.CurrentThread;
}
public static FrameworkSyncContext MainThreadContext
{
get => _mainThreadContext;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get;
} = new FrameworkSyncContext();
public override void Post(SendOrPostCallback d, object state)
{
+1 -1
View File
@@ -70,7 +70,7 @@ namespace StgSharp.HighPerformance
public void BroadCastFrom<T>(T value) where T: unmanaged, INumber<T>
{
Vec = Vector128.CreateScalarUnsafe(value).As<T, float>();
Vec = Vector128.Create<T>(value).AsSingle();
}
public override readonly bool Equals([NotNullWhen(true)] object obj)
+1 -1
View File
@@ -52,7 +52,7 @@ namespace StgSharp.HighPerformance
public void BroadCastFrom<T>(T value) where T: unmanaged, INumber<T>
{
Vec = Vector256.CreateScalarUnsafe(value).As<T, float>();
Vec = Vector256.Create(value).AsSingle();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
+1 -1
View File
@@ -51,7 +51,7 @@ namespace StgSharp.HighPerformance
public void BroadCastFrom<T>(T value) where T: unmanaged, INumber<T>
{
Vec = Vector512.CreateScalarUnsafe(value).As<T, float>();
Vec = Vector512.Create(value).AsSingle();
}
public ref T Member<T>(int index) where T: unmanaged, INumber<T>
+8 -1
View File
@@ -28,6 +28,7 @@
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
namespace StgSharp.HighPerformance
{
@@ -37,6 +38,7 @@ namespace StgSharp.HighPerformance
[FieldOffset(0)] private fixed byte buffer[8];
[FieldOffset(0)] private ulong value;
[FieldOffset(0)] private Vector64<float> vec;
public M64()
{
@@ -49,12 +51,17 @@ namespace StgSharp.HighPerformance
return ref Unsafe.As<byte, T>(ref buffer[0]);
}
public void BroadCastFrom<T>(T value) where T: unmanaged, INumber<T>
{
vec = Vector64.Create(value).AsSingle();
}
public override bool Equals(object obj)
{
return obj is M64 m64 && this == m64;
}
public override int GetHashCode()
public override readonly int GetHashCode()
{
return value.GetHashCode();
}
+15 -1
View File
@@ -32,10 +32,23 @@ using System.Text;
namespace StgSharp.Internal
{
public class GraphicModule : IStaticModule
{
public string ModuleName => "Graphic";
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void InitializeModule()
{
GraphicFramework.LoadGlfw();
}
}
internal static unsafe partial class GraphicFramework
{
private static readonly GLFWFunction _glfw = new GLFWFunction();
private static GLFWFunction _glfw ;
public static GLFWFunction glfwContext => _glfw;
@@ -44,6 +57,7 @@ namespace StgSharp.Internal
internal static unsafe void LoadGlfw()
{
_glfw = new GLFWFunction();
fixed (GLFWFunction* func = &_glfw) {
glfwLoadLibrary(func);
}
+4 -4
View File
@@ -287,8 +287,8 @@ namespace StgSharp.Internal
private IntPtr cursor; // _GLFWcursor* cursor;
// glfwVideomode videoMode; // 根据GLFWvidmode的定义转换
private IntPtr monitor; // _GLFWmonitor* monitor;
public fixed byte keys[Constant.GLFW_KEY_LAST + 1];
public fixed byte mouseButtons[Constant.GLFW_MOUSE_BUTTON_LAST + 1];
public fixed byte keys[FrameworkConstant.GLFW_KEY_LAST + 1];
public fixed byte mouseButtons[FrameworkConstant.GLFW_MOUSE_BUTTON_LAST + 1];
// _GLFWcontext viewPortDisplay; // 根据_GLFWcontext的定义转换
@@ -497,8 +497,8 @@ namespace StgSharp.Internal
internal unsafe struct GLFWlibrary
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = Constant.GLFW_JOYSTICK_LAST + 1)]
private GLFWjoystick[] joysticks = new GLFWjoystick[Constant.GLFW_JOYSTICK_LAST + 1];
[MarshalAs(UnmanagedType.ByValArray, SizeConst = FrameworkConstant.GLFW_JOYSTICK_LAST + 1)]
private GLFWjoystick[] joysticks = new GLFWjoystick[FrameworkConstant.GLFW_JOYSTICK_LAST + 1];
private GLFWallocator allocator;
+18 -16
View File
@@ -79,7 +79,7 @@ namespace StgSharp.Mathematics.Graphic
return _lookAt;
}
Matrix44 move = Matrix44.Unit;
move.column3.vec -= cameraAtt.column3.vec;
move.column[3].vec -= cameraAtt.column[3].vec;
_lookAt = rotationAtt.Transpose * move;
_isLookAtAvailable = true;
return _lookAt;
@@ -120,19 +120,19 @@ namespace StgSharp.Mathematics.Graphic
public void MoveNear(float distance)
{
cameraAtt.column3.Z -= distance;
cameraAtt.column[3].Z -= distance;
_isLookAtAvailable = false;
}
public void MoveRight(float distance)
{
cameraAtt.column3.X -= distance;
cameraAtt.column[3].X -= distance;
_isLookAtAvailable = false;
}
public void MoveUp(float distance)
{
cameraAtt.column3.Y -= distance;
cameraAtt.column[3].Y -= distance;
_isLookAtAvailable = false;
}
@@ -145,7 +145,9 @@ namespace StgSharp.Mathematics.Graphic
public void SetViewDirection(Vec3 position, Vec3 target, Vec3 up)
{
Vec3 direction = position - target;
if ((position.reg == cameraAtt.column3.reg) && (this.up == up) && (cameraAtt.column2.reg == direction.reg)) {
if ((position.reg == cameraAtt.column[3].reg) &&
(this.up == up) &&
(cameraAtt.column[3].reg == direction.reg)) {
return;
}
if (direction.GetLength() == 0)
@@ -165,10 +167,10 @@ namespace StgSharp.Mathematics.Graphic
Vec3 right = Linear.Orthogonalize(Linear.Cross(up, direction));
cameraAtt.column0.reg = right.reg;
cameraAtt.column1.reg = up.reg;
cameraAtt.column2.reg = direction.reg;
cameraAtt.column3.reg = position.reg;
cameraAtt.column[0].reg = right.reg;
cameraAtt.column[1].reg = up.reg;
cameraAtt.column[2].reg = direction.reg;
cameraAtt.column[3].reg = position.reg;
InternalPitch();
InternalRow();
@@ -186,13 +188,13 @@ namespace StgSharp.Mathematics.Graphic
width = Scaler.Abs(GeometryScaler.Tan(fovRadius / 2) * near * 2),
height = width * size.Y / size.X;
_projection.column0.X = 2 * near / width;
_projection.column1.Y = 2 * near / height;
_projection.column2.X = 2 * offsetX / width;
_projection.column2.Y = 2 * offsetY / height;
_projection.column2.Z = (far + near) / (near - far);
_projection.column2.W = -1;
_projection.column3.Z = 2 * near * far / (near - far);
_projection.column[0].X = 2 * near / width;
_projection.column[1].Y = 2 * near / height;
_projection.column[2].X = 2 * offsetX / width;
_projection.column[2].Y = 2 * offsetY / height;
_projection.column[2].Z = (far + near) / (near - far);
_projection.column[2].W = -1;
_projection.column[3].Z = 2 * near * far / (near - far);
}
public void Test(params Vec4[] vec)
@@ -41,13 +41,10 @@ namespace StgSharp.Mathematics.Graphic
{
[FieldOffset(2 * 64 * sizeof(float))] internal bool isTransposed;
[FieldOffset(0 * sizeof(float))] internal Column column;
[FieldOffset(0)] internal ColumnSet4 mat;
[FieldOffset(16 * sizeof(float))] internal ColumnSet4 transpose;
[FieldOffset(0 * sizeof(float))] internal Vec4 column0;
[FieldOffset(4 * sizeof(float))] internal Vec4 column1;
[FieldOffset(8 * sizeof(float))] internal Vec4 column2;
[FieldOffset(12 * sizeof(float))] internal Vec4 column3;
internal Matrix44(ColumnSet4 mat)
{
@@ -273,11 +270,18 @@ namespace StgSharp.Mathematics.Graphic
IEnumerator<Vec4> IEnumerable<Vec4>.GetEnumerator()
{
ref Vec4 col0 = ref column0;
for (int i = 0; i < 4; i++) {
yield return Unsafe.Add(ref col0, i);
yield return column[i];
}
}
[InlineArray(4)]
internal struct Column
{
private Vec4 value;
}
}
}
+1 -1
View File
@@ -38,7 +38,7 @@ namespace StgSharp.Mathematics.Graphic
{
[CollectionBuilder(builderType:typeof(Vec4), methodName: nameof(Vec4.FromSpan))]
[StructLayout(LayoutKind.Explicit, Size = 16, Pack = 16)]
public unsafe struct Vec4 : IEquatable<Vec4>, IUnmanagedVector<Vec4, float>
public unsafe struct Vec4 : IEquatable<Vec4>, IUnmanagedVector<Vec4>
{
[FieldOffset(0)] internal unsafe fixed float num[4];
@@ -1,81 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="PlainGeometryCollisionSensor"
// Project: StgSharp
// AuthorGroup: Nitload
// Copyright (c) Nitload. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Geometries;
using System;
using System.Runtime.CompilerServices;
namespace StgSharp
{
public class CollisionEventArgs : EventArgs
{
public CollisionEventArgs(IGeometry target, IGeometry boarder)
{
Target = target;
Boarder = boarder;
}
public IGeometry Target { get; set; }
public IGeometry Boarder { get; set; }
}
public class PlainGeometryCollisionSensor<TBoarder, TTarget> where TBoarder: IGeometry where TTarget: IGeometry
{
internal EventHandler<CollisionEventArgs> _rule;
internal PlainGeometry _boarder;
internal PlainGeometry _target;
public event EventHandler<CollisionEventArgs> Rule
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
add => _rule += value;
remove
{
if (value == null) {
return;
}
#pragma warning disable CS8601
_rule -= value;
#pragma warning restore CS8601
}
}
public PlainGeometry boarder => _boarder;
public PlainGeometry target
{
get => _target;
set => _target = value;
}
}
}
-59
View File
@@ -1,59 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StateMachine"
// Project: StgSharp
// AuthorGroup: Nitload
// Copyright (c) Nitload. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp
{
public interface IStateMachine<T> where T: Enum
{
public T LastStableState { get; }
public bool TryEnterState();
public bool TryExitState();
public bool TrySwitchState();
}
public interface IStateMachineWithSwitchSpan<TState, TSpan> : IStateMachine<TState> where TState: Enum
{
public bool IsInStabelState { get; }
public TState NextStableState { get; }
public bool TrySwitchState();
}
}
+17 -12
View File
@@ -27,6 +27,7 @@
// -----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
namespace StgSharp.Timing
@@ -53,24 +54,31 @@ namespace StgSharp.Timing
public virtual bool IsComplete
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => _timeProvider.CurrentSecond > _ending;
}
public Func<float, float> TimeRelatedCalculation
{
get { return _timeRelatedCalculation; }
set { _timeRelatedCalculation = value; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => _timeRelatedCalculation;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set => _timeRelatedCalculation = value;
}
public static TimeFunction One
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => new TimeFunctionOne();
}
public TimeSpanProvider TimeSpanProvider
{
get { return _timeProvider; }
set { _timeProvider = value; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => _timeProvider;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set => _timeProvider = value;
}
public virtual float Calculate()
@@ -96,7 +104,7 @@ namespace StgSharp.Timing
return new TimeFunction(_timeProvider, func, range);
}
public void Reset()
public virtual void Reset()
{
float range = _ending - _beginning;
_beginning = _timeProvider.CurrentSecond;
@@ -117,10 +125,7 @@ namespace StgSharp.Timing
internal TimeFunctionOne() : base() { }
public override bool IsComplete
{
get => true;
}
public override bool IsComplete => true;
public override float Calculate()
{
@@ -138,9 +143,9 @@ namespace StgSharp.Timing
}
#pragma warning disable CA1822
public new void Reset()
public override void Reset()
{
}
#pragma warning restore CA1822
{ }
}
}
+16 -23
View File
@@ -25,6 +25,7 @@
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Collections;
using StgSharp.Timing;
using System;
@@ -48,7 +49,7 @@ namespace StgSharp
public sealed class StgSharpTime : TimeSourceProviderBase
{
private static List<TimeSpanProvider> subscriberList = [];
private static readonly LinearBag<TimeSpanProvider> _subscribers = new();
private static long accuracy;
private static readonly Stopwatch mainProvider = new();
private static Thread timeProvideThread;
@@ -65,21 +66,21 @@ namespace StgSharp
mainProvider.Start();
// speed test
long totalMS, internalFrequncy = Stopwatch.Frequency;
long totalMS, internalFrequency = Stopwatch.Frequency;
for (int i = 0; i < 100; i++)
{
totalMS = mainProvider.ElapsedTicks / (internalFrequncy / (1000L * 1000L));
totalMS = mainProvider.ElapsedTicks / (internalFrequency / (1000L * 1000L));
for (int t = 0; t < 10; t++)
{
if (totalMS < 1000) {
subscriberList.Add(
_subscribers.Add(
new TimeSpanProvider(100L, TimeSpanProvider.DefaultProvider));
}
}
}
mainProvider.Stop();
subscriberList.Clear();
totalMS = mainProvider.ElapsedTicks / (internalFrequncy / (1000L * 1000L)) / 100L;
_subscribers.Clear();
totalMS = mainProvider.ElapsedTicks / (internalFrequency / (1000L * 1000L)) / 100L;
accuracy = totalMS * 2 / 3;
mainProvider.Reset();
timeProvideThread = new Thread(new ThreadStart(ProvideTime));
@@ -102,44 +103,36 @@ namespace StgSharp
protected sealed override void AddSubscriberUnsynced(TimeSpanProvider subscriber)
{
subscriberList.Add(subscriber);
_subscribers.Add(subscriber);
}
protected sealed override void RemoveSubscriberUnsynced(TimeSpanProvider subscriber)
{
_ = subscriberList.Remove(subscriber);
_subscribers.Remove(subscriber);
}
private void ProvideTime()
{
long totalMS, internalFrequncy = Stopwatch.Frequency;
long totalMS, internalFrequency = Stopwatch.Frequency;
lock (mainProvider) {
mainProvider.Restart();
}
while (mainProvider.IsRunning)
{
totalMS = mainProvider.ElapsedTicks / (internalFrequncy / (1000L * 1000L));
if (subscriberList.Count == 0)
totalMS = mainProvider.ElapsedTicks / (internalFrequency / (1000L * 1000L));
if (_subscribers.Count == 0)
{
continue;
}
lock (SubscribeLock)
{
List<TimeSpanProvider> toRemoveList = [];
foreach (TimeSpanProvider subscriber in subscriberList)
for (int i = 0; i < _subscribers.Count; i++)
{
if (!subscriber.CheckTime(totalMS))
if (!_subscribers[i].CheckTime(totalMS))
{
toRemoveList.Add(subscriber);
_subscribers.RemoveAt(i);
DefaultLog.InternalWriteLog(
$"Time subscriber {subscriber} is to be removed.", LogType.Info);
}
;
}
if (toRemoveList.Count != 0)
{
foreach (TimeSpanProvider subscriber in toRemoveList) {
_ = subscriberList.Remove(subscriber);
$"Time subscriber {_subscribers[i]} is to be removed.", LogType.Info);
}
}
}
+3 -5
View File
@@ -36,20 +36,18 @@ namespace StgSharp.Timing
public abstract class TimeSourceProviderBase
{
private readonly object _subscriberLock = new();
protected object SubscribeLock => _subscriberLock;
protected object SubscribeLock { get; } = new();
public void AddSubscriber(TimeSpanProvider subscriber)
{
lock (_subscriberLock) {
lock (SubscribeLock) {
AddSubscriberUnsynced(subscriber);
}
}
public void RemoveSubscriber(TimeSpanProvider subscriber)
{
lock (_subscriberLock) {
lock (SubscribeLock) {
RemoveSubscriberUnsynced(subscriber);
}
}
+16 -12
View File
@@ -30,6 +30,7 @@ using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
@@ -43,11 +44,10 @@ namespace StgSharp.Timing
private bool _subscribed;
private ConcurrentQueue<TimeSpanAwaitingToken> _tokenToAdd = new ConcurrentQueue<TimeSpanAwaitingToken>(
);
private ConcurrentQueue<TimeSpanAwaitingToken> _tokenToQuit;
private Counter<int> timeSpanCount = new Counter<int>(-1, 1, 1);
private HashSet<TimeSpanAwaitingToken> _awaitingTokens;
private readonly ConcurrentQueue<TimeSpanAwaitingToken> _tokenToAdd = new();
private readonly ConcurrentQueue<TimeSpanAwaitingToken> _tokenToQuit;
private Counter<int> timeSpanCount = new(-1, 1, 1);
private readonly HashSet<TimeSpanAwaitingToken> _awaitingTokens;
private long _maxSpanCount;
private long _spanBegin;
private readonly long _spanLength;
@@ -71,7 +71,7 @@ namespace StgSharp.Timing
_maxSpanCount = int.MaxValue;
provider.AddSubscriber(this);
_subscribed = true;
_awaitingTokens = new HashSet<TimeSpanAwaitingToken>();
_awaitingTokens = [];
_tokenToQuit = new ConcurrentQueue<TimeSpanAwaitingToken>();
}
@@ -94,7 +94,7 @@ namespace StgSharp.Timing
_maxSpanCount = long.MaxValue;
provider.AddSubscriber(this);
_subscribed = true;
_awaitingTokens = new HashSet<TimeSpanAwaitingToken>();
_awaitingTokens = [];
_tokenToQuit = new ConcurrentQueue<TimeSpanAwaitingToken>();
}
@@ -128,21 +128,25 @@ namespace StgSharp.Timing
public double SpanLength
{
get => (_spanLength * 1.0) / (1000L * 1000L);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => _spanLength * 1.0 / (1000L * 1000L);
}
public float CurrentSecond
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => timeSpanCount.Value * SpanLengthLowPrecession;
}
public float SpanLengthLowPrecession
{
get => (_spanLength * 1.0f) / (1000 * 1000);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => _spanLength * 1.0f / (1000 * 1000);
}
public int CurrentSpan
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => timeSpanCount.Value;
}
@@ -153,7 +157,7 @@ namespace StgSharp.Timing
public TimeSpanAwaitingToken ParticipantSpanAwaiting(int count)
{
TimeSpanAwaitingToken token = new TimeSpanAwaitingToken(this, count);
TimeSpanAwaitingToken token = new(this, count);
_tokenToAdd.Enqueue(token);
return token;
}
@@ -165,7 +169,7 @@ namespace StgSharp.Timing
public void StopSpanProviding()
{
Interlocked.Exchange(ref _maxSpanCount, 0);
_ = Interlocked.Exchange(ref _maxSpanCount, 0);
}
public void SubscribeToTimeSource(TimeSourceProviderBase serviceHandler)
@@ -207,7 +211,7 @@ namespace StgSharp.Timing
{
if (item.AwaitingSemaphoreSlim.CurrentCount == 0)
{
item.AwaitingSemaphoreSlim.Release();
_ = item.AwaitingSemaphoreSlim.Release();
item.Refresh();
} else
{
@@ -106,8 +106,8 @@ namespace StgSharp.Mathematics.Numeric
}
MatrixParallel.ReturnParallelResources(ref pool);
}
MatrixParallelHandle taskGroup = MatrixParallel.PublicTask(left.GetColumnEnumeration(),
(delegate*<MatrixKernel<float>*, MatrixKernel<float>*, MatrixKernel<float>*, void>)NativeIntrinsic.Intrinsic.f32_add);
MatrixParallelHandle taskGroup = MatrixParallel.PublicNoAnswerTask(left.GetColumnEnumeration(), scaler,
(delegate* unmanaged[Cdecl]<MatrixKernel<float>*, ScalarPacket*, void>)NativeIntrinsic.Intrinsic.f32_add);
MatrixParallel.LaunchParallel(taskGroup, SleepMode.DeepSleep);
/*
@@ -2,8 +2,8 @@
// -----------------------------------------------------------------------
// file="MatrixComputeModel"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// AuthorGroup: Nitload
// Copyright (c) Nitload. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -25,6 +25,7 @@
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.HighPerformance;
using System;
using System.Runtime.CompilerServices;
@@ -40,6 +40,27 @@ namespace StgSharp.Mathematics.Numeric
public static partial class MatrixParallel
{
public static unsafe MatrixParallelHandle PublicNoAnswerTask<T>(
MatrixSegmentEnumeration<T> source,
ScalarPacket* additional,
delegate* unmanaged[Cdecl]<MatrixKernel<T>*, ScalarPacket*, void> computeHandle)
where T: unmanaged, INumber<T>
{
MatrixParallelTaskPackage<T>* package = MatrixParallelFactory.CreateBaseTask<T>();
package->Scalar = additional;
package->Right = source.Source;
package->RightPrimOffset = source.PrimOffset;
package->RightPrimStride = source.PrimStride;
package->RightSecOffset = source.SecondaryOffset;
package->RightSecStride = source.SecondaryStride;
package->PrimCount = source.PrimSize;
package->SecCount = source.SecondarySize;
package->ElementSize = sizeof(T);
package->ComputeHandle = (nint)computeHandle;
package->ComputeMode = 6; // no ans
return PublicTaskPrivate(package);
}
public static unsafe MatrixParallelHandle PublicTask<T>(
MatrixSegmentEnumeration<T> source,
MatrixSegmentEnumeration<T> ans,
+10 -10
View File
@@ -59,7 +59,16 @@ namespace StgSharp.Mathematics.Numeric
Monitor.Exit(_lock);
}
public static void Init()
public static void LaunchParallel(MatrixParallelHandle handle, SleepMode afterWork)
{
RemainThreadCount = _threads.Count;
_AfterWork = (ThreadPriority)afterWork;
foreach (MatrixParallelWrap w in handle.Wraps) {
w.SchedulerReset.Set();
}
}
internal static void Init()
{
if (IsInitialized) {
return;
@@ -79,14 +88,5 @@ namespace StgSharp.Mathematics.Numeric
IsInitialized = true;
}
public static void LaunchParallel(MatrixParallelHandle handle, SleepMode afterWork)
{
RemainThreadCount = _threads.Count;
_AfterWork = (ThreadPriority)afterWork;
foreach (MatrixParallelWrap w in handle.Wraps) {
w.SchedulerReset.Set();
}
}
}
}
@@ -1,9 +1,9 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="MatrixParallelHandle"
// file="MatrixParallelPool"
// Project: StgSharp
// AuthorGroup: Nitload
// Copyright (c) Nitload. All rights reserved.
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -25,181 +25,153 @@
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.HighPerformance;
using StgSharp.Collections;
using System;
using System.Numerics;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Mathematics.Numeric
{
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct MatrixParallelTaskPackageNonGeneric
public struct MatrixParallelHandle : IDisposable
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void Copy(
MatrixParallelTaskPackageNonGeneric* source,
MatrixParallelTaskPackageNonGeneric* target)
private static readonly (int a, int b)[] LookupTable = [ (1, 1), // 7
(0, 2), // 8 (no non-zero solution)
(3, 0), // 9 (no non-zero solution)
(2, 1), // 10
(1, 2), // 11
(0, 3), // 12 (no non-zero solution)
(3, 1), // 13
(2, 2), // 14
(1, 3), // 15
(4, 1), // 16
(3, 2), // 17
(2, 3), // 18
(1, 4), // 19
(4, 2), // 20
];
private MatrixParallelThread[] _threads;
private bool _disposed = false;
private CapacityFixedStack<MatrixParallelWrap> _wraps;
internal MatrixParallelHandle(MatrixParallelThread[] threadArray)
{
Buffer.MemoryCopy(source, target, sizeof(MatrixParallelTaskPackageNonGeneric),
sizeof(MatrixParallelTaskPackageNonGeneric));
_threads = threadArray;
IsMultithread = threadArray.Length > 1;
SliceToWraps();
}
#region source
// Group 1: Left/Right matrix kernel base address
public IntPtr Left; // 8
public IntPtr Right; // 8
#endregion
#region ans
// Group 2: Result kernel base address + reserved
public IntPtr Result; // 8
public int ElementSize;
public int ReservedPtr0; // 4 (extension/reserved)
#endregion
#region left enum
public int LeftPrimOffset; // 4
public int LeftPrimStride; // 4
public int LeftSecOffset; // 4
public int LeftSecStride; // 4
#endregion
#region right enum
public int RightPrimOffset; // 4
public int RightPrimStride; // 4
public int RightSecOffset; // 4
public int RightSecStride; // 4
#endregion
#region ans enum
public int ResultPrimOffset; // 4
public int ResultPrimStride; // 4
public int ResultSecOffset; // 4
public int ResultSecStride; // 4
#endregion
#region scalar/compute
public ScalarPacket* Scalar; // 8
public IntPtr ComputeHandle; // 8
#endregion
#region global profile
public int PrimCount; // 4
public int ComputeMode; // 4
public int SecCount; // 4
private int ReservedInt0; // 4
#endregion
#region count offset
public int PrimTileOffset; // 4
public int SecTileOffset; // 4
public int PrimCountInTile; // 4
public int SecCountInTile; // 4
#endregion
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct MatrixParallelTaskPackage<T> where T: unmanaged, INumber<T>
{
public MatrixParallelTaskPackage()
public ReadOnlySpan<MatrixParallelThread> Threads
{
Unsafe.SkipInit(out this);
get
{
if (_disposed) {
throw new ObjectDisposedException(typeof(MatrixParallelHandle).Name);
}
return _threads;
}
}
internal IEnumerable<MatrixParallelWrap> Wraps
{
get
{
if (_disposed) {
throw new ObjectDisposedException(typeof(MatrixParallelHandle).Name);
}
return _wraps;
}
}
internal ReadOnlySpan<MatrixParallelThread> ThreadsUnsafe
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => _threads;
}
private bool IsMultithread { get; init; }
public void Dispose()
{
if (_disposed) {
return;
}
MatrixParallel.ReturnParallelResources(ref _threads);
_disposed = true;
}
public MatrixParallelThread GetLeader()
{
Threads[0].Role = 2;
return Threads[0];
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void Copy(MatrixParallelTaskPackage<T>* source, MatrixParallelTaskPackage<T>* target)
private static (int count_3, int count_4) FastDecompose(int c)
{
Buffer.MemoryCopy(source, target, sizeof(MatrixParallelTaskPackage<T>),
sizeof(MatrixParallelTaskPackage<T>));
/*
* Thread wrapping to accelerate matrix operations by dividing threads into groups (pool).
* For M pool, each containing an average of N threads, we satisfy the condition M * N = T - 4,
* where T is the total thread _count of the CPU. Typically, for modern consumer CPUs, T is around 16.
* For simplicity, let M * N = 16.
*
* The total time complexity for publishing tasks is O(M + N):
* - O(M) accounts for distributing tasks across M pool.
* - O(N) accounts for threads within each wrap fetching tasks from the wrap queue.
*
* Using the inequality Sqrt(M * N) <= (M + N) / 2 (derived from the arithmetic-geometric mean inequality),
* the optimal configuration occurs when M = N. For M * N = 16, this gives M = N = 4.
*
* To ensure compatibility across a wide range of CPU architectures,
* we allow each wrap to contain either 3 or 4 threads, providing flexibility while maintaining efficiency.
*/
if (c < 7)
{
return (0, 0);
}
int t = c - 7;
int k = t / 14;
int d = t % 14;
(int a0, int b0) = LookupTable[d];
return (a0 + (2 * k), b0 + (2 * k));
}
#region source
private void SliceToWraps()
{
if (_disposed) {
throw new ObjectDisposedException(typeof(MatrixParallelHandle).Name);
}
if (_wraps is not null) {
return;
}
int count = _threads.Length;
if (count < 6)
{
MatrixParallelWrap wrap = new MatrixParallelWrap(_threads, 0, count);
_wraps = [ wrap ];
}
(int c3,int c4) = FastDecompose(_threads.Length);
_wraps = new(c3 + c4);
int begin = 0;
for (int i = 0; i < c3; i++)
{
_wraps.Push(new MatrixParallelWrap(_threads, begin, 3));
begin += 3;
}
for (int i = 0; i < c4; i++)
{
_wraps.Push(new MatrixParallelWrap(_threads, begin, 4));
begin += 4;
}
}
// Group 1: Left/Right matrix kernel base address
public MatrixKernel<T>* Left; // 8
public MatrixKernel<T>* Right; // 8
#endregion
#region ans
// Group 2: Result kernel base address + reserved
public MatrixKernel<T>* Result; // 8
public int ElementSize = sizeof(T);
public int ReservedPtr0; // 4 (extension/reserved)
#endregion
#region left enum
public int LeftPrimOffset; // 4
public int LeftPrimStride; // 4
public int LeftSecOffset; // 4
public int LeftSecStride; // 4
#endregion
#region right enum
public int RightPrimOffset; // 4
public int RightPrimStride; // 4
public int RightSecOffset; // 4
public int RightSecStride; // 4
#endregion
#region ans enum
public int ResultPrimOffset; // 4
public int ResultPrimStride; // 4
public int ResultSecOffset; // 4
public int ResultSecStride; // 4
#endregion
#region scalar/compute
public ScalarPacket* Scalar; // 8
public IntPtr ComputeHandle; // 8
#endregion
#region global profile
public int PrimCount; // 4
public int ComputeMode; // 4
public int SecCount; // 4
private readonly int ReservedInt0; // 4
#endregion
#region count offset
public int PrimTileOffset; // 4
public int SecTileOffset; // 4
public int PrimColumnCountInTile; // 4
public int SecColumnCountInTile; // 4
#endregion
}
}
}
@@ -1,177 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="MatrixParallelPool"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Collections;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Mathematics.Numeric
{
public struct MatrixParallelHandle : IDisposable
{
private static readonly (int a, int b)[] LookupTable = [ (1, 1), // 7
(0, 2), // 8 (no non-zero solution)
(3, 0), // 9 (no non-zero solution)
(2, 1), // 10
(1, 2), // 11
(0, 3), // 12 (no non-zero solution)
(3, 1), // 13
(2, 2), // 14
(1, 3), // 15
(4, 1), // 16
(3, 2), // 17
(2, 3), // 18
(1, 4), // 19
(4, 2), // 20
];
private MatrixParallelThread[] _threads;
private bool _disposed = false;
private CapacityFixedStack<MatrixParallelWrap> _wraps;
internal MatrixParallelHandle(MatrixParallelThread[] threadArray)
{
_threads = threadArray;
IsMultithread = threadArray.Length > 1;
SliceToWraps();
}
public ReadOnlySpan<MatrixParallelThread> Threads
{
get
{
if (_disposed) {
throw new ObjectDisposedException(typeof(MatrixParallelHandle).Name);
}
return _threads;
}
}
internal IEnumerable<MatrixParallelWrap> Wraps
{
get
{
if (_disposed) {
throw new ObjectDisposedException(typeof(MatrixParallelHandle).Name);
}
return _wraps;
}
}
internal ReadOnlySpan<MatrixParallelThread> ThreadsUnsafe
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => _threads;
}
private bool IsMultithread { get; init; }
public void Dispose()
{
if (_disposed) {
return;
}
MatrixParallel.ReturnParallelResources(ref _threads);
_disposed = true;
}
public MatrixParallelThread GetLeader()
{
Threads[0].Role = 2;
return Threads[0];
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static (int count_3, int count_4) FastDecompose(int c)
{
/*
* Thread wrapping to accelerate matrix operations by dividing threads into groups (pool).
* For M pool, each containing an average of N threads, we satisfy the condition M * N = T - 4,
* where T is the total thread _count of the CPU. Typically, for modern consumer CPUs, T is around 16.
* For simplicity, let M * N = 16.
*
* The total time complexity for publishing tasks is O(M + N):
* - O(M) accounts for distributing tasks across M pool.
* - O(N) accounts for threads within each wrap fetching tasks from the wrap queue.
*
* Using the inequality Sqrt(M * N) <= (M + N) / 2 (derived from the arithmetic-geometric mean inequality),
* the optimal configuration occurs when M = N. For M * N = 16, this gives M = N = 4.
*
* To ensure compatibility across a wide range of CPU architectures,
* we allow each wrap to contain either 3 or 4 threads, providing flexibility while maintaining efficiency.
*/
if (c < 7)
{
return (0, 0);
}
int t = c - 7;
int k = t / 14;
int d = t % 14;
(int a0, int b0) = LookupTable[d];
return (a0 + (2 * k), b0 + (2 * k));
}
private void SliceToWraps()
{
if (_disposed) {
throw new ObjectDisposedException(typeof(MatrixParallelHandle).Name);
}
if (_wraps is not null) {
return;
}
int count = _threads.Length;
if (count < 6)
{
MatrixParallelWrap wrap = new MatrixParallelWrap(_threads, 0, count);
_wraps = [ wrap ];
}
(int c3,int c4) = FastDecompose(_threads.Length);
_wraps = new(c3 + c4);
int begin = 0;
for (int i = 0; i < c3; i++)
{
_wraps.Push(new MatrixParallelWrap(_threads, begin, 3));
begin += 3;
}
for (int i = 0; i < c4; i++)
{
_wraps.Push(new MatrixParallelWrap(_threads, begin, 4));
begin += 4;
}
}
}
}
@@ -0,0 +1,205 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="MatrixParallelHandle"
// Project: StgSharp
// AuthorGroup: Nitload
// Copyright (c) Nitload. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.HighPerformance;
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace StgSharp.Mathematics.Numeric
{
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct MatrixParallelTaskPackageNonGeneric
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void Copy(
MatrixParallelTaskPackageNonGeneric* source,
MatrixParallelTaskPackageNonGeneric* target)
{
Buffer.MemoryCopy(source, target, sizeof(MatrixParallelTaskPackageNonGeneric),
sizeof(MatrixParallelTaskPackageNonGeneric));
}
#region source
// Group 1: Left/Right matrix kernel base address
public IntPtr Left; // 8
public IntPtr Right; // 8
#endregion
#region ans
// Group 2: Result kernel base address + reserved
public IntPtr Result; // 8
public int ElementSize;
public int ReservedPtr0; // 4 (extension/reserved)
#endregion
#region left enum
public int LeftPrimOffset; // 4
public int LeftPrimStride; // 4
public int LeftSecOffset; // 4
public int LeftSecStride; // 4
#endregion
#region right enum
public int RightPrimOffset; // 4
public int RightPrimStride; // 4
public int RightSecOffset; // 4
public int RightSecStride; // 4
#endregion
#region ans enum
public int ResultPrimOffset; // 4
public int ResultPrimStride; // 4
public int ResultSecOffset; // 4
public int ResultSecStride; // 4
#endregion
#region scalar/compute
public ScalarPacket* Scalar; // 8
public IntPtr ComputeHandle; // 8
#endregion
#region global profile
public int PrimCount; // 4
public int ComputeMode; // 4
public int SecCount; // 4
private int ReservedInt0; // 4
#endregion
#region count offset
public int PrimTileOffset; // 4
public int SecTileOffset; // 4
public int PrimCountInTile; // 4
public int SecCountInTile; // 4
#endregion
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct MatrixParallelTaskPackage<T> where T: unmanaged, INumber<T>
{
public MatrixParallelTaskPackage()
{
Unsafe.SkipInit(out this);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void Copy(MatrixParallelTaskPackage<T>* source, MatrixParallelTaskPackage<T>* target)
{
Buffer.MemoryCopy(source, target, sizeof(MatrixParallelTaskPackage<T>),
sizeof(MatrixParallelTaskPackage<T>));
}
#region source
// Group 1: Left/Right matrix kernel base address
public MatrixKernel<T>* Left; // 8
public MatrixKernel<T>* Right; // 8
#endregion
#region ans
// Group 2: Result kernel base address + reserved
public MatrixKernel<T>* Result; // 8
public int ElementSize = sizeof(T);
public int ReservedPtr0; // 4 (extension/reserved)
#endregion
#region left enum
public int LeftPrimOffset; // 4
public int LeftPrimStride; // 4
public int LeftSecOffset; // 4
public int LeftSecStride; // 4
#endregion
#region right enum
public int RightPrimOffset; // 4
public int RightPrimStride; // 4
public int RightSecOffset; // 4
public int RightSecStride; // 4
#endregion
#region ans enum
public int ResultPrimOffset; // 4
public int ResultPrimStride; // 4
public int ResultSecOffset; // 4
public int ResultSecStride; // 4
#endregion
#region scalar/compute
public ScalarPacket* Scalar; // 8
public IntPtr ComputeHandle; // 8
#endregion
#region global profile
public int PrimCount; // 4
public int ComputeMode; // 4
public int SecCount; // 4
private readonly int ReservedInt0; // 4
#endregion
#region count offset
public int PrimTileOffset; // 4
public int SecTileOffset; // 4
public int PrimColumnCountInTile; // 4
public int SecColumnCountInTile; // 4
#endregion
}
}
@@ -1,6 +1,6 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="GLfixed"
// file="NumericalModule"
// Project: StgSharp
// AuthorGroup: Nitload
// Copyright (c) Nitload. All rights reserved.
@@ -28,19 +28,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Internal
namespace StgSharp.Mathematics.Numeric
{
[StructLayout(LayoutKind.Explicit, Size = 8)]
public struct GLfixed
public class NumericalModule : IStaticModule
{
[FieldOffset(0)] public int All;
[FieldOffset(0)] public short Decimals;
[FieldOffset(4)] public short Inertger;
public string ModuleName => "Math.Numerical";
public void InitializeModule()
{
MatrixParallel.Init();
}
}
}
+25 -17
View File
@@ -2,8 +2,8 @@
// -----------------------------------------------------------------------
// file="Partical"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// AuthorGroup: Nitload
// Copyright (c) Nitload. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -25,6 +25,7 @@
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Common.Graphics;
using StgSharp.Controls;
using StgSharp.Geometries;
using StgSharp.Graphics;
@@ -122,9 +123,8 @@ namespace StgSharp
/**/
GL.TextureImage2d<byte>(
Texture2DTarget.Texture2D, 0, ImageChannel.WithAlphaChannel, (uint)Width, (uint)Height,
ImageChannel.WithAlphaChannel, PixelChannelLayout.Byte, null);
GL.TextureImage2d<byte>(Texture2DTarget.Texture2D, 0, ImageChannel.WithAlphaChannel, (uint)Width,
(uint)Height, ImageChannel.WithAlphaChannel, PixelChannelLayout.Byte, null);
/**/
// GL.Assert(false);
@@ -164,9 +164,8 @@ namespace StgSharp
// GL.ClearError();
// Console.Write($"Size set to {Height},{Width}");
// Console.WriteLine($"Image resized to {i.Height} {i.Width}");
GL.GetTextureImage(
Texture2DTarget.Texture2D, 0, ImageChannel.WithAlphaChannel,
PixelChannelLayout.Byte, i.PixelBuffer);
GL.GetTextureImage(Texture2DTarget.Texture2D, 0, ImageChannel.WithAlphaChannel, PixelChannelLayout.Byte,
i.PixelBuffer);
/*
for (int num = 0; num < i.PixelBuffer.Length; num+=10000)
{
@@ -287,7 +286,19 @@ namespace StgSharp
vbo.Unbind();
GL.BindVertexArray(GlHandle.Zero);
NativeCameraViewTarget([ 0f, 0f, -100f ], [ 0f, 0f, 0f ], [ 0f, 1f, 0f ]);
NativeCameraViewTarget([
0f,
0f,
-100f
], [
0f,
0f,
0f
], [
0f,
1f,
0f
]);
NativeCameraViewRange(new Degree(1.5f), Vec2.Zero, (50, 50));
NativeCameraUniform(s, "Camera");
@@ -301,15 +312,13 @@ namespace StgSharp
// GL.Assert(true);
t = CreateTexture(1);
t.Bind2D(0);
GL.TextureImage2d<byte>(
Texture2DTarget.Texture2D, 0, ImageChannel.WithAlphaChannel, (uint)Width, (uint)Height,
ImageChannel.WithAlphaChannel, PixelChannelLayout.Byte, null!);
GL.TextureImage2d<byte>(Texture2DTarget.Texture2D, 0, ImageChannel.WithAlphaChannel, (uint)Width,
(uint)Height, ImageChannel.WithAlphaChannel, PixelChannelLayout.Byte, null!);
t.Set2dWrapProperty(0, TextureWrap.Repeat, TextureWrap.Repeat);
t.Set2dFilterProperty(0, TextureFilter.Linear, TextureFilter.Linear);
// GL.Assert(true);
GL.FrameBufferTexture2d(
FrameBufferTarget.All, glAttachment.Color(0), Texture2DTarget.Texture2D, t[0], 0);
GL.FrameBufferTexture2d(FrameBufferTarget.All, glAttachment.Color(0), Texture2DTarget.Texture2D, t[0], 0);
GL.SetRenderBufferStorage(RenderBufferInternalFormat.Depth24_Stencil8, this.Size);
GL.CombineFrameBufferRenderBuffer(FrameBufferAttachment.DepthAndStencil, rbo[0]);
@@ -360,9 +369,8 @@ namespace StgSharp
// GL.Assert(true);
autoT = CreateAutoTexture(4);
autoT.DefaultTextureProperty = new TextureProperty(
TextureFilter.Nearest, TextureFilter.Nearest, TextureWrap.Repeat,
TextureWrap.Repeat);
autoT.DefaultTextureProperty = new TextureProperty(TextureFilter.Nearest, TextureFilter.Nearest,
TextureWrap.Repeat, TextureWrap.Repeat);
f_t = CreateTexture(1);
f_t.Bind2D(0);