From e1ec761e83957eb2b7f0368bf74d0df5fb6d3435 Mon Sep 17 00:00:00 2001
From: Youmu Liu <105042599+Nitload-NSI@users.noreply.github.com>
Date: Mon, 27 Oct 2025 19:59:12 +0800
Subject: [PATCH] [Internal] Seperate InternalIO into different static classes.
[Matrix] Fix logic error of compute model.
---
.../Right Margin Line/Right Margin Line.xml | 2 +
.../Editor/Formatting/Wrapping.CSharp.xml | 36 +
.../Right Margin Line/Right Margin Line.xml | 6 +
.../Collections/StringHashMultiplexer.cs | 8 +-
StgSharp.Common/Environment/GlobalSetting.cs | 4 +-
StgSharp.Common/Environment/Monitors.cs | 2 +-
StgSharp.Common/Environment/Platform.cs | 27 +-
.../Geometries/PlainGeometry/Parallelogram.cs | 7 +-
StgSharp.Common/Graphics/Constant.cs | 336 ++++
StgSharp.Common/Graphics/Image.cs | 9 +-
.../Graphics/OpenGL/ShaderEdit/Shader.cs | 8 +-
...iManagerConst.cs => glApiManager.Const.cs} | 0
.../Graphics/OpenGL/glApiManager.Load.cs | 1538 ++++++++++++++++
.../Graphics/OpenGL/glApiManager.cs | 1566 +----------------
StgSharp.Common/Graphics/OpenGL/glConst.cs | 297 ----
StgSharp.Common/Graphics/OpenGL/glFunction.cs | 22 +-
.../Graphics/OpenGL/glRenderStream.cs | 12 +-
StgSharp.Common/Graphics/OpenGL/glType.cs | 8 +-
StgSharp.Common/Graphics/RenderStream.cs | 6 +-
StgSharp.Common/HighPerformance/Lable.cs | 2 +-
.../HighPerformance/UnsafeCompute.cs | 6 +-
.../Internal/{InternalIO.cs => DefaultLog.cs} | 55 +-
.../BuiltinShader.cs} | 14 +-
.../Internal/{ClangLoad => Graphic}/gl.cs | 30 +-
.../Internal/{ => Graphic}/glfw.cs | 31 +-
.../glfw.function.cs} | 0
.../Intrinsic/intrinsicContextProvider.cs | 4 +-
StgSharp.Common/Internal/Native.cs | 48 +
StgSharp.Common/Internal/StructDefine.cs | 11 +-
.../Internal/{publicType.cs => public.cs} | 9 +-
StgSharp.Common/MVVM/View/ViewBase.cs | 2 +-
StgSharp.Common/MVVM/View/ViewResponder.cs | 2 +-
.../MVVM/ViewModel/ShowViewPort.cs | 10 +-
StgSharp.Common/MVVM/ViewModel/ViewModel.cs | 24 +-
StgSharp.Common/MVVM/ViewPort.cs | 4 +-
.../Mathematics/Graphic/Matrix44.cs | 2 +-
.../Mathematics/Scalar/Factorial.cs | 6 +-
StgSharp.Common/State/IState.cs | 37 +
StgSharp.Common/State/IStateMachine.cs | 46 +
StgSharp.Common/Stg/CollisionTexture.cs | 12 +-
StgSharp.Common/Timing/TimeProvider.cs | 2 +-
StgSharp.Common/Timing/TimeSpanProvider.cs | 6 +-
.../Numeric/MatrixCompute.Basic.cs | 72 +-
.../Numeric/MatrixComputeModel.cs | 195 +-
.../Numeric/MatrixParallel.Publish.cs | 346 ++--
.../Numeric/MatrixParallelTask.cs | 12 +-
46 files changed, 2572 insertions(+), 2310 deletions(-)
create mode 100644 .cr/team/Editor/Formatting/Wrapping.CSharp.xml
create mode 100644 .cr/team/Editor/Right Margin Line/Right Margin Line.xml
create mode 100644 StgSharp.Common/Graphics/Constant.cs
rename StgSharp.Common/Graphics/OpenGL/{glApiManagerConst.cs => glApiManager.Const.cs} (100%)
create mode 100644 StgSharp.Common/Graphics/OpenGL/glApiManager.Load.cs
rename StgSharp.Common/Internal/{InternalIO.cs => DefaultLog.cs} (68%)
rename StgSharp.Common/Internal/{InternalResource.cs => Graphic/BuiltinShader.cs} (95%)
rename StgSharp.Common/Internal/{ClangLoad => Graphic}/gl.cs (73%)
rename StgSharp.Common/Internal/{ => Graphic}/glfw.cs (97%)
rename StgSharp.Common/Internal/{glfwFunction.cs => Graphic/glfw.function.cs} (100%)
create mode 100644 StgSharp.Common/Internal/Native.cs
rename StgSharp.Common/Internal/{publicType.cs => public.cs} (94%)
create mode 100644 StgSharp.Common/State/IState.cs
create mode 100644 StgSharp.Common/State/IStateMachine.cs
diff --git a/.cr/personal/Editor/Right Margin Line/Right Margin Line.xml b/.cr/personal/Editor/Right Margin Line/Right Margin Line.xml
index 8432cfbd..b18e300f 100644
--- a/.cr/personal/Editor/Right Margin Line/Right Margin Line.xml
+++ b/.cr/personal/Editor/Right Margin Line/Right Margin Line.xml
@@ -2,5 +2,7 @@
True
+
+ 2
\ No newline at end of file
diff --git a/.cr/team/Editor/Formatting/Wrapping.CSharp.xml b/.cr/team/Editor/Formatting/Wrapping.CSharp.xml
new file mode 100644
index 00000000..ee502938
--- /dev/null
+++ b/.cr/team/Editor/Formatting/Wrapping.CSharp.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.cr/team/Editor/Right Margin Line/Right Margin Line.xml b/.cr/team/Editor/Right Margin Line/Right Margin Line.xml
new file mode 100644
index 00000000..ed19c709
--- /dev/null
+++ b/.cr/team/Editor/Right Margin Line/Right Margin Line.xml
@@ -0,0 +1,6 @@
+
+
+
+ 120
+
+
\ No newline at end of file
diff --git a/StgSharp.Common/Collections/StringHashMultiplexer.cs b/StgSharp.Common/Collections/StringHashMultiplexer.cs
index 1a8a3368..1a09285b 100644
--- a/StgSharp.Common/Collections/StringHashMultiplexer.cs
+++ b/StgSharp.Common/Collections/StringHashMultiplexer.cs
@@ -71,7 +71,7 @@ namespace StgSharp.Collections
{
int hash;
fixed (char* cPtr = obj.AsSpan()) {
- hash = InternalIO.Intrinsic.city_hash_simplify(cPtr, obj.Length);
+ hash = NativeIntrinsic.Intrinsic.city_hash_simplify(cPtr, obj.Length);
}
return hash;
}
@@ -129,21 +129,21 @@ namespace StgSharp.Collections
public void ExtendCache(int count)
{
- _multiplexers.Value.ExtendCache(count);
+ _multiplexers.Value!.ExtendCache(count);
}
public unsafe int ForceComputeHash([NotNull] string obj)
{
int hash;
fixed (char* cPtr = obj.AsSpan()) {
- hash = InternalIO.Intrinsic.city_hash_simplify(cPtr, obj.Length);
+ hash = NativeIntrinsic.Intrinsic.city_hash_simplify(cPtr, obj.Length);
}
return hash;
}
public int GetHashCode(string obj)
{
- return _multiplexers.Value.GetHashCode(obj);
+ return _multiplexers.Value!.GetHashCode(obj);
}
private void Dispose(bool disposing)
diff --git a/StgSharp.Common/Environment/GlobalSetting.cs b/StgSharp.Common/Environment/GlobalSetting.cs
index 83977321..a4322542 100644
--- a/StgSharp.Common/Environment/GlobalSetting.cs
+++ b/StgSharp.Common/Environment/GlobalSetting.cs
@@ -85,7 +85,7 @@ namespace StgSharp
if (API != GraphicAPI.GL) {
return;
}
- InternalIO.InternalInitGL(majorVersion, minorVersion);
+ GraphicFramework.InternalInitGL(majorVersion, minorVersion);
}
public static class GlobalSetting
@@ -98,7 +98,7 @@ namespace StgSharp
get => vsyncActivated;
set
{
- InternalIO.glfwSwapInterval(value ? 1 : 0);
+ GraphicFramework.glfwSwapInterval(value ? 1 : 0);
vsyncActivated = value;
}
}
diff --git a/StgSharp.Common/Environment/Monitors.cs b/StgSharp.Common/Environment/Monitors.cs
index 6fe23141..c8e9aec5 100644
--- a/StgSharp.Common/Environment/Monitors.cs
+++ b/StgSharp.Common/Environment/Monitors.cs
@@ -48,7 +48,7 @@ namespace StgSharp
if (monitorsArray == null)
{
int count = 0;
- IntPtr* arrayhandle = InternalIO.glfwGetMonitors(&count);
+ IntPtr* arrayhandle = GraphicFramework.glfwGetMonitors(&count);
monitorsArray = new IntPtr[count];
Marshal.Copy((IntPtr)arrayhandle, monitorsArray, 0, count);
Marshal.FreeHGlobal((IntPtr)arrayhandle);
diff --git a/StgSharp.Common/Environment/Platform.cs b/StgSharp.Common/Environment/Platform.cs
index 3463b8d2..5b387757 100644
--- a/StgSharp.Common/Environment/Platform.cs
+++ b/StgSharp.Common/Environment/Platform.cs
@@ -55,7 +55,7 @@ namespace StgSharp
private static uint markCount = 0;
internal static GraphicAPI API = default;
- public static int DefaultSIMDAlignment => InternalIO.IntrinsicLevel switch
+ public static int DefaultSIMDAlignment => NativeIntrinsic.IntrinsicLevel switch
{
IntrinsicLevel.SSE => 16,
IntrinsicLevel.AVX2 => 32,
@@ -69,12 +69,12 @@ namespace StgSharp
{
mainTimeProvider = new StgSharpTime();
MainTimeProvider.StartProvidingTime();
- InternalIO.LoadGlfw();
- if (InternalIO.glfwInit() == 0) {
+ GraphicFramework.LoadGlfw();
+ if (GraphicFramework.glfwInit() == 0) {
throw new Exception("Failed to init system graphic environment.");
}
- InternalIO.InternalAppendLog("\n\n\n");
- InternalIO.InternalWriteLog(
+ DefaultLog.InternalAppendLog("\n\n\n");
+ DefaultLog.InternalWriteLog(
$"Program {Assembly.GetEntryAssembly()!.FullName} on {Environment.MachineName} Started.", LogType.Info);
MainThreadID = Environment.CurrentManagedThreadId;
@@ -84,30 +84,31 @@ namespace StgSharp
Dialogue.CreateDialogueProcessIfNotExist();
}
- InternalIO.InitIntrinsicContext();
+ NativeIntrinsic.InitIntrinsicContext();
}
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void LogError(Exception ex)
{
- InternalIO.InternalWriteLog(ex.Message, LogType.Error);
+ DefaultLog.InternalWriteLog(ex.Message, LogType.Error);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void LogInfo(string log)
{
- InternalIO.InternalWriteLog(log, LogType.Info);
+ DefaultLog.InternalWriteLog(log, LogType.Info);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void LogWarning(string log)
{
- InternalIO.InternalWriteLog(log, LogType.Warning);
+ DefaultLog.InternalWriteLog(log, LogType.Warning);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void LogWarning(Exception notVerySeriesException)
{
- InternalIO.InternalWriteLog(notVerySeriesException.Message, LogType.Warning);
+ DefaultLog.InternalWriteLog(notVerySeriesException.Message, LogType.Warning);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -122,7 +123,7 @@ namespace StgSharp
public static void Terminate(int exitCode)
{
MainTimeProvider.StopProvidingTime();
- InternalIO.glfwTerminate();
+ GraphicFramework.glfwTerminate();
Environment.Exit(exitCode);
}
@@ -149,7 +150,7 @@ namespace StgSharp
Console.WriteLine(log);
} else
{
- InternalIO.InternalWriteLog(log, LogType.Info);
+ DefaultLog.InternalWriteLog(log, LogType.Info);
}
}
@@ -165,7 +166,7 @@ namespace StgSharp
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void WriteLog(string message, LogType logType)
{
- InternalIO.InternalWriteLog(message, logType);
+ DefaultLog.InternalWriteLog(message, logType);
}
internal static TDele ConvertAPI(IntPtr funcPtr)
diff --git a/StgSharp.Common/Geometries/PlainGeometry/Parallelogram.cs b/StgSharp.Common/Geometries/PlainGeometry/Parallelogram.cs
index 34ac987a..cacdf6ed 100644
--- a/StgSharp.Common/Geometries/PlainGeometry/Parallelogram.cs
+++ b/StgSharp.Common/Geometries/PlainGeometry/Parallelogram.cs
@@ -35,8 +35,7 @@ namespace StgSharp.Geometries
public class Parallelogram : Polygon4
{
- internal readonly Func movCenterOperation =
- new Func(GeometryOperation.DefaultMotion);
+ internal readonly Func movCenterOperation = GeometryOperation.DefaultMotion;
internal Point center;
@@ -46,7 +45,7 @@ namespace StgSharp.Geometries
#if DEBUG
if (this[0].Coord + this[2].Coord != this[1].Coord + this[3].Coord)
{
- InternalIO.InternalWriteLog(
+ DefaultLog.InternalWriteLog(
"Init of geometry item failed, because four vertices cannot form a rectangle.",
LogType.Warning);
}
@@ -68,7 +67,7 @@ namespace StgSharp.Geometries
#if DEBUG
if (this[0].Coord + this[2].Coord != this[1].Coord + this[3].Coord)
{
- InternalIO.InternalWriteLog(
+ DefaultLog.InternalWriteLog(
"Init of geometry item failed, because four vertices cannot form a rectangle.",
LogType.Warning);
}
diff --git a/StgSharp.Common/Graphics/Constant.cs b/StgSharp.Common/Graphics/Constant.cs
new file mode 100644
index 00000000..f6cef832
--- /dev/null
+++ b/StgSharp.Common/Graphics/Constant.cs
@@ -0,0 +1,336 @@
+//-----------------------------------------------------------------------
+// -----------------------------------------------------------------------
+// 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
+ }
+}
diff --git a/StgSharp.Common/Graphics/Image.cs b/StgSharp.Common/Graphics/Image.cs
index 4af9abf3..b8649e87 100644
--- a/StgSharp.Common/Graphics/Image.cs
+++ b/StgSharp.Common/Graphics/Image.cs
@@ -114,10 +114,7 @@ namespace StgSharp.Graphics
public SerializableTypeCode SSDTypeCode => SerializableTypeCode.PixelImage;
- internal ref byte[] Data
- {
- get => ref _data;
- }
+ internal ref byte[] Data => ref _data;
public void FromBytes(byte[] stream) { }
@@ -125,7 +122,7 @@ namespace StgSharp.Graphics
{
Image ret = new Image();
fixed (ImageInfo* iptr = &ret._rawInfo) {
- InternalIO.InternalLoadImage(route, iptr, loader);
+ GraphicFramework.InternalLoadImage(route, iptr, loader);
}
return ret;
}
@@ -171,7 +168,7 @@ namespace StgSharp.Graphics
int size = Width * Height * ImageInfo.GetPixelSize(PixelLayout, Channel);
_data = new Span((byte*)_rawInfo.StreamPtr, size).ToArray();
fixed (ImageInfo* pptr = &_rawInfo) {
- InternalIO.InternalUnloadImage(pptr);
+ GraphicFramework.InternalUnloadImage(pptr);
}
_rawInfo.StreamPtr = IntPtr.Zero;
}
diff --git a/StgSharp.Common/Graphics/OpenGL/ShaderEdit/Shader.cs b/StgSharp.Common/Graphics/OpenGL/ShaderEdit/Shader.cs
index c67e788c..5a63db4f 100644
--- a/StgSharp.Common/Graphics/OpenGL/ShaderEdit/Shader.cs
+++ b/StgSharp.Common/Graphics/OpenGL/ShaderEdit/Shader.cs
@@ -245,21 +245,21 @@ namespace StgSharp.Graphics.OpenGL
///
public unsafe void Link()
{
- if (InternalIO.InternalLinkShaderProgram(
+ if (GraphicFramework.InternalLinkShaderProgram(
(OpenglContext*)this.GL.ContextHandle, handle.Value) == 0)
{
- IntPtr logPtr = InternalIO.InternalReadSSCLog();
+ IntPtr logPtr = GraphicFramework.InternalReadSSCLog();
try
{
byte[] logByte = new byte[512];
Marshal.Copy(logPtr, logByte, 0, 512);
string log = Encoding.UTF8.GetString(logByte);
log = log.Replace("\0", string.Empty);
- InternalIO.InternalWriteLog(log, LogType.Error);
+ DefaultLog.InternalWriteLog(log, LogType.Error);
}
catch (Exception ex)
{
- InternalIO.InternalWriteLog(ex.Message, LogType.Error);
+ DefaultLog.InternalWriteLog(ex.Message, LogType.Error);
}
}
}
diff --git a/StgSharp.Common/Graphics/OpenGL/glApiManagerConst.cs b/StgSharp.Common/Graphics/OpenGL/glApiManager.Const.cs
similarity index 100%
rename from StgSharp.Common/Graphics/OpenGL/glApiManagerConst.cs
rename to StgSharp.Common/Graphics/OpenGL/glApiManager.Const.cs
diff --git a/StgSharp.Common/Graphics/OpenGL/glApiManager.Load.cs b/StgSharp.Common/Graphics/OpenGL/glApiManager.Load.cs
new file mode 100644
index 00000000..7e331f5c
--- /dev/null
+++ b/StgSharp.Common/Graphics/OpenGL/glApiManager.Load.cs
@@ -0,0 +1,1538 @@
+//-----------------------------------------------------------------------
+// -----------------------------------------------------------------------
+// file="glApiManager.Load"
+// 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;
+
+namespace StgSharp.Graphics.OpenGL
+{
+ public static partial class glManager
+ {
+
+ internal static unsafe bool LoadGLcore10(OpenglContext* contextPtr, delegate*, IntPtr> load)
+ {
+ if (!core10)
+ {
+ DefaultLog.InternalAppendLog("The core version 1.0 is not supported.");
+ return false;
+ }
+
+ #region load
+
+ contextPtr->glBlendFunc = (delegate*)load("glBlendFunc"u8);
+ contextPtr->glClear = (delegate*)load("glClear"u8);
+ contextPtr->glClearColor = (delegate*)load("glClearColor"u8);
+ contextPtr->glClearDepth = (delegate*)load("glClearDepth"u8);
+ contextPtr->glClearStencil = (delegate*)load("glClearStencil"u8);
+ contextPtr->glColorMask = (delegate*)load("glColorMask"u8);
+ contextPtr->glCullFace = (delegate*)load("glCullFace"u8);
+ contextPtr->glDepthFunc = (delegate*)load("glDepthFunc"u8);
+ contextPtr->glDepthMask = (delegate*)load("glDepthMask"u8);
+ contextPtr->glDepthRange = (delegate*)load("glDepthRange"u8);
+ contextPtr->glDisable = (delegate*)load("glDisable"u8);
+ contextPtr->glDrawBuffer = (delegate*)load("glDrawBuffer"u8);
+ contextPtr->glEnable = (delegate*)load("glEnable"u8);
+ contextPtr->glFinish = (delegate*)load("glFinish"u8);
+ contextPtr->glFlush = (delegate*)load("glFlush"u8);
+ contextPtr->glFrontFace = (delegate*)load("glFrontFace"u8);
+ contextPtr->glGetBooleanv = (delegate*)load("glGetBooleanv"u8);
+ contextPtr->glGetDoublev = (delegate*)load("glGetDoublev"u8);
+ contextPtr->glGetError = (delegate*)load("glGetError"u8);
+ contextPtr->glGetFloatv = (delegate*)load("glGetFloatv"u8);
+ contextPtr->glGetIntegerv = (delegate*)load("glGetIntegerv"u8);
+ contextPtr->glGetString = (delegate*)load("glGetString"u8);
+ contextPtr->glGetTexImage = (delegate*)load("glGetTexImage"u8);
+ contextPtr->glGetTexLevelParameterfv = (delegate*)load("glGetTexLevelParameterfv"u8);
+ contextPtr->glGetTexLevelParameteriv = (delegate*)load("glGetTexLevelParameteriv"u8);
+ contextPtr->glGetTexParameterfv = (delegate*)load("glGetTexParameterfv"u8);
+ contextPtr->glGetTexParameteriv = (delegate*)load("glGetTexParameteriv"u8);
+ contextPtr->glHint = (delegate*)load("glHint"u8);
+ contextPtr->glIsEnabled = (delegate*)load("glIsEnabled"u8);
+ contextPtr->glLineWidth = (delegate*)load("glLineWidth"u8);
+ contextPtr->glLogicOp = (delegate*)load("glLogicOp"u8);
+ contextPtr->glPixelStoref = (delegate*)load("glPixelStoref"u8);
+ contextPtr->glPixelStorei = (delegate*)load("glPixelStorei"u8);
+ contextPtr->glPointSize = (delegate*)load("glPointSize"u8);
+ contextPtr->glPolygonMode = (delegate*)load("glPolygonMode"u8);
+ contextPtr->glReadBuffer = (delegate*)load("glReadBuffer"u8);
+ contextPtr->glReadPixels = (delegate*)load("glReadPixels"u8);
+ contextPtr->glScissor = (delegate*)load("glScissor"u8);
+ contextPtr->glStencilFunc = (delegate*)load("glStencilFunc"u8);
+ contextPtr->glStencilMask = (delegate*)load("glStencilMask"u8);
+ contextPtr->glStencilOp = (delegate*)load("glStencilOp"u8);
+ contextPtr->glTexImage1D = (delegate*)load("glTexImage1D"u8);
+ contextPtr->glTexImage2D = (delegate*)load("glTexImage2D"u8);
+ contextPtr->glTexParameterf = (delegate*)load("glTexParameterf"u8);
+ contextPtr->glTexParameterfv = (delegate*)load("glTexParameterfv"u8);
+ contextPtr->glTexParameteri = (delegate*)load("glTexParameteri"u8);
+ contextPtr->glTexParameteriv = (delegate*)load("glTexParameteriv"u8);
+ contextPtr->glViewport = (delegate*)load("glViewport"u8);
+
+ #endregion load
+
+ DefaultLog.InternalAppendLog("Successfully load all OpenGL 1.0 APIs");
+ return true;
+ }
+
+ internal static unsafe bool LoadGLcore11(OpenglContext* contextPtr, delegate*, IntPtr> load)
+ {
+ if (!core11)
+ {
+ DefaultLog.InternalAppendLog("The core version 1.1 is not supported.");
+ return false;
+ }
+
+ #region load
+
+ contextPtr->glBindTexture = (delegate*)load("glBindTexture"u8);
+ contextPtr->glCopyTexImage1D = (delegate*)load(
+ "glCopyTexImage1D"u8);
+ contextPtr->glCopyTexImage2D = (delegate*)load(
+ "glCopyTexImage2D"u8);
+ contextPtr->glCopyTexSubImage1D = (delegate*)load(
+ "glCopyTexSubImage1D"u8);
+ contextPtr->glCopyTexSubImage2D = (delegate*)load(
+ "glCopyTexSubImage2D"u8);
+ contextPtr->glDeleteTextures = (delegate*)load(
+ "glDeleteTextures"u8);
+ contextPtr->glDrawArrays = (delegate*)load("glDrawArrays"u8);
+ contextPtr->glDrawElements = (delegate*)load(
+ "glDrawElements"u8);
+ contextPtr->glGenTextures = (delegate*)load("glGenTextures"u8);
+ contextPtr->glGetPointerv = (delegate*)load("glGetPointerv"u8);
+ contextPtr->glIsTexture = (delegate*)load("glIsTexture"u8);
+ contextPtr->glPolygonOffset = (delegate*)load("glPolygonOffset"u8);
+ contextPtr->glTexSubImage1D = (delegate*)load(
+ "glTexSubImage1D"u8);
+ contextPtr->glTexSubImage2D = (delegate*)load(
+ "glTexSubImage2D"u8);
+
+ #endregion load
+
+ DefaultLog.InternalAppendLog("Successfully load all OpenGL 1.1 APIs");
+ return true;
+ }
+
+ internal static unsafe bool LoadGLcore12(OpenglContext* contextPtr, delegate*, IntPtr> load)
+ {
+ if (!core12)
+ {
+ DefaultLog.InternalAppendLog("The core version 1.2 is not supported.");
+ return false;
+ }
+
+ #region load
+
+ contextPtr->glCopyTexSubImage3D = (delegate*)load(
+ "glCopyTexSubImage3D"u8);
+ contextPtr->glDrawRangeElements = (delegate*)load(
+ "glDrawRangeElements"u8);
+ contextPtr->glTexImage3D = (delegate*)load(
+ "glTexImage3D"u8);
+ contextPtr->glTexSubImage3D = (delegate*)load(
+ "glTexSubImage3D"u8);
+
+ #endregion load
+
+ DefaultLog.InternalAppendLog("Successfully load all OpenGL 1.2 APIs");
+ return true;
+ }
+
+ internal static unsafe bool LoadGLcore13(OpenglContext* contextPtr, delegate*, IntPtr> load)
+ {
+ if (!core13)
+ {
+ DefaultLog.InternalAppendLog("The core version 1.3 is not supported.");
+ return false;
+ }
+
+ #region load
+
+ contextPtr->glActiveTexture = (delegate*)load("glActiveTexture"u8);
+ contextPtr->glCompressedTexImage1D = (delegate*)load(
+ "glCompressedTexImage1D"u8);
+ contextPtr->glCompressedTexImage2D = (delegate*)load(
+ "glCompressedTexImage2D"u8);
+ contextPtr->glCompressedTexImage3D = (delegate*)load(
+ "glCompressedTexImage3D"u8);
+ contextPtr->glCompressedTexSubImage1D = (delegate*)load(
+ "glCompressedTexSubImage1D"u8);
+ contextPtr->glCompressedTexSubImage2D = (delegate*)load(
+ "glCompressedTexSubImage2D"u8);
+ contextPtr->glCompressedTexSubImage3D = (delegate*)load(
+ "glCompressedTexSubImage3D"u8);
+ contextPtr->glGetCompressedTexImage = (delegate*)load(
+ "glGetCompressedTexImage"u8);
+ contextPtr->glSampleCoverage = (delegate*)load(
+ "glSampleCoverage"u8);
+
+ #endregion load
+
+ DefaultLog.InternalAppendLog("Successfully load all OpenGL 1.3 APIs");
+ return true;
+ }
+
+ internal static unsafe bool LoadGLcore14(OpenglContext* contextPtr, delegate*, IntPtr> load)
+ {
+ if (!core14)
+ {
+ DefaultLog.InternalAppendLog("The core version 1.4 is not supported.");
+ return false;
+ }
+
+ #region load
+
+ contextPtr->glBlendColor = (delegate*)load(
+ "glBlendColor"u8);
+ contextPtr->glBlendEquation = (delegate*)load("glBlendEquation"u8);
+ contextPtr->glBlendFuncSeparate = (delegate*)load(
+ "glBlendFuncSeparate"u8);
+ contextPtr->glMultiDrawArrays = (delegate*)load(
+ "glMultiDrawArrays"u8);
+ contextPtr->glMultiDrawElements = (delegate*)load(
+ "glMultiDrawElements"u8);
+ contextPtr->glPointParameterf = (delegate*)load(
+ "glPointParameterf"u8);
+ contextPtr->glPointParameterfv = (delegate*)load(
+ "glPointParameterfv"u8);
+ contextPtr->glPointParameteri = (delegate*)load(
+ "glPointParameteri"u8);
+ contextPtr->glPointParameteriv = (delegate*)load(
+ "glPointParameteriv"u8);
+
+ #endregion load
+
+ DefaultLog.InternalAppendLog("Successfully load all OpenGL 1.4 APIs");
+ return true;
+ }
+
+ internal static unsafe bool LoadGLcore15(OpenglContext* contextPtr, delegate*, IntPtr> load)
+ {
+ if (!core15)
+ {
+ DefaultLog.InternalAppendLog("The core version 1.5 is not supported.");
+ return false;
+ }
+
+ #region load
+
+ contextPtr->glBeginQuery = (delegate*)load("glBeginQuery"u8);
+ contextPtr->glBindBuffer = (delegate*)load("glBindBuffer"u8);
+ contextPtr->glBufferData = (delegate*)load(
+ "glBufferData"u8);
+ contextPtr->glBufferSubData = (delegate*)load(
+ "glBufferSubData"u8);
+ contextPtr->glDeleteBuffers = (delegate*)load("glDeleteBuffers"u8);
+ contextPtr->glDeleteQueries = (delegate*)load("glDeleteQueries"u8);
+ contextPtr->glEndQuery = (delegate*)load("glEndQuery"u8);
+ contextPtr->glGenBuffers = (delegate*)load("glGenBuffers"u8);
+ contextPtr->glGenQueries = (delegate*)load("glGenQueries"u8);
+ contextPtr->glGetBufferParameteriv = (delegate*)load(
+ "glGetBufferParameteriv"u8);
+ contextPtr->glGetBufferPointerv = (delegate*)load(
+ "glGetBufferPointerv"u8);
+ contextPtr->glGetBufferSubData = (delegate*)load(
+ "glGetBufferSubData"u8);
+ contextPtr->glGetQueryObjectiv = (delegate*)load(
+ "glGetQueryObjectiv"u8);
+ contextPtr->glGetQueryObjectuiv = (delegate*)load(
+ "glGetQueryObjectuiv"u8);
+ contextPtr->glGetQueryiv = (delegate*)load("glGetQueryiv"u8);
+ contextPtr->glIsBuffer = (delegate*)load("glIsBuffer"u8);
+ contextPtr->glIsQuery = (delegate*)load("glIsQuery"u8);
+ contextPtr->glMapBuffer = (delegate*)load("glMapBuffer"u8);
+ contextPtr->glUnmapBuffer = (delegate*)load("glUnmapBuffer"u8);
+
+ #endregion load
+
+ DefaultLog.InternalAppendLog("Successfully load all OpenGL 1.5 APIs");
+ return true;
+ }
+
+ internal static unsafe bool LoadGLcore20(OpenglContext* contextPtr, delegate*, IntPtr> load)
+ {
+ if (!core20)
+ {
+ DefaultLog.InternalAppendLog("The core version 2.0 is not supported.");
+ return false;
+ }
+
+ #region load
+
+ contextPtr->glAttachShader = (delegate*)load("glAttachShader"u8);
+ contextPtr->glBindAttribLocation = (delegate*)load(
+ "glBindAttribLocation"u8);
+ contextPtr->glBlendEquationSeparate = (delegate*)load(
+ "glBlendEquationSeparate"u8);
+ contextPtr->glCompileShader = (delegate*)load("glCompileShader"u8);
+ contextPtr->glCreateProgram = (delegate*)load("glCreateProgram"u8);
+ contextPtr->glCreateShader = (delegate*)load("glCreateShader"u8);
+ contextPtr->glDeleteProgram = (delegate*)load("glDeleteProgram"u8);
+ contextPtr->glDeleteShader = (delegate*)load("glDeleteShader"u8);
+ contextPtr->glDetachShader = (delegate*)load("glDetachShader"u8);
+ contextPtr->glDisableVertexAttribArray = (delegate*)load(
+ "glDisableVertexAttribArray"u8);
+ contextPtr->glDrawBuffers = (delegate*)load("glDrawBuffers"u8);
+ contextPtr->glEnableVertexAttribArray = (delegate*)load(
+ "glEnableVertexAttribArray"u8);
+ contextPtr->glGetActiveAttrib = (delegate*)load(
+ "glGetActiveAttrib"u8);
+ contextPtr->glGetActiveUniform = (delegate*)load(
+ "glGetActiveUniform"u8);
+ contextPtr->glGetAttachedShaders = (delegate*)load(
+ "glGetAttachedShaders"u8);
+ contextPtr->glGetAttribLocation = (delegate*)load(
+ "glGetAttribLocation"u8);
+ contextPtr->glGetProgramInfoLog = (delegate*)load(
+ "glGetProgramInfoLog"u8);
+ contextPtr->glGetProgramiv = (delegate*)load(
+ "glGetProgramiv"u8);
+ contextPtr->glGetShaderInfoLog = (delegate*)load(
+ "glGetShaderInfoLog"u8);
+ contextPtr->glGetShaderSource = (delegate*)load(
+ "glGetShaderSource"u8);
+ contextPtr->glGetShaderiv = (delegate*)load("glGetShaderiv"u8);
+ contextPtr->glGetUniformLocation = (delegate*)load(
+ "glGetUniformLocation"u8);
+ contextPtr->glGetUniformfv = (delegate*)load(
+ "glGetUniformfv"u8);
+ contextPtr->glGetUniformiv = (delegate*)load(
+ "glGetUniformiv"u8);
+ contextPtr->glGetVertexAttribPointerv = (delegate*)load(
+ "glGetVertexAttribPointerv"u8);
+ contextPtr->glGetVertexAttribdv = (delegate*)load(
+ "glGetVertexAttribdv"u8);
+ contextPtr->glGetVertexAttribfv = (delegate*)load(
+ "glGetVertexAttribfv"u8);
+ contextPtr->glGetVertexAttribiv = (delegate*)load(
+ "glGetVertexAttribiv"u8);
+ contextPtr->glIsProgram = (delegate*)load("glIsProgram"u8);
+ contextPtr->glIsShader = (delegate*)load("glIsShader"u8);
+ contextPtr->glLinkProgram = (delegate*)load("glLinkProgram"u8);
+ contextPtr->glShaderSource = (delegate* unmanaged[Stdcall])load(
+ "glShaderSource"u8);
+ contextPtr->glStencilFuncSeparate = (delegate*)load(
+ "glStencilFuncSeparate"u8);
+ contextPtr->glStencilMaskSeparate = (delegate*)load(
+ "glStencilMaskSeparate"u8);
+ contextPtr->glStencilOpSeparate = (delegate*)load(
+ "glStencilOpSeparate"u8);
+ contextPtr->glUniform1f = (delegate*)load("glUniform1f"u8);
+ contextPtr->glUniform1fv = (delegate*)load("glUniform1fv"u8);
+ contextPtr->glUniform1i = (delegate*)load("glUniform1i"u8);
+ contextPtr->glUniform1iv = (delegate*)load("glUniform1iv"u8);
+ contextPtr->glUniform2f = (delegate*)load("glUniform2f"u8);
+ contextPtr->glUniform2fv = (delegate*)load("glUniform2fv"u8);
+ contextPtr->glUniform2i = (delegate*)load("glUniform2i"u8);
+ contextPtr->glUniform2iv = (delegate*)load("glUniform2iv"u8);
+ contextPtr->glUniform3f = (delegate*)load(
+ "glUniform3f"u8);
+ contextPtr->glUniform3fv = (delegate*)load("glUniform3fv"u8);
+ contextPtr->glUniform3i = (delegate*)load("glUniform3i"u8);
+ contextPtr->glUniform3iv = (delegate*)load("glUniform3iv"u8);
+ contextPtr->glUniform4f = (delegate*)load(
+ "glUniform4f"u8);
+ contextPtr->glUniform4fv = (delegate*)load("glUniform4fv"u8);
+ contextPtr->glUniform4i = (delegate*)load(
+ "glUniform4i"u8);
+ contextPtr->glUniform4iv = (delegate*)load("glUniform4iv"u8);
+ contextPtr->glUniformMatrix2fv = (delegate*)load(
+ "glUniformMatrix2fv"u8);
+ contextPtr->glUniformMatrix3fv = (delegate*)load(
+ "glUniformMatrix3fv"u8);
+ contextPtr->glUniformMatrix4fv = (delegate*)load(
+ "glUniformMatrix4fv"u8);
+ contextPtr->glUseProgram = (delegate*)load("glUseProgram"u8);
+ contextPtr->glValidateProgram = (delegate*)load("glValidateProgram"u8);
+ contextPtr->glVertexAttrib1d = (delegate*)load(
+ "glVertexAttrib1d"u8);
+ contextPtr->glVertexAttrib1dv = (delegate*)load(
+ "glVertexAttrib1dv"u8);
+ contextPtr->glVertexAttrib1f = (delegate*)load(
+ "glVertexAttrib1f"u8);
+ contextPtr->glVertexAttrib1fv = (delegate*)load(
+ "glVertexAttrib1fv"u8);
+ contextPtr->glVertexAttrib1s = (delegate*)load(
+ "glVertexAttrib1s"u8);
+ contextPtr->glVertexAttrib1sv = (delegate*)load(
+ "glVertexAttrib1sv"u8);
+ contextPtr->glVertexAttrib2d = (delegate*)load(
+ "glVertexAttrib2d"u8);
+ contextPtr->glVertexAttrib2dv = (delegate*)load(
+ "glVertexAttrib2dv"u8);
+ contextPtr->glVertexAttrib2f = (delegate*)load(
+ "glVertexAttrib2f"u8);
+ contextPtr->glVertexAttrib2fv = (delegate*)load(
+ "glVertexAttrib2fv"u8);
+ contextPtr->glVertexAttrib2s = (delegate*)load(
+ "glVertexAttrib2s"u8);
+ contextPtr->glVertexAttrib2sv = (delegate*)load(
+ "glVertexAttrib2sv"u8);
+ contextPtr->glVertexAttrib3d = (delegate*)load(
+ "glVertexAttrib3d"u8);
+ contextPtr->glVertexAttrib3dv = (delegate*)load(
+ "glVertexAttrib3dv"u8);
+ contextPtr->glVertexAttrib3f = (delegate*)load(
+ "glVertexAttrib3f"u8);
+ contextPtr->glVertexAttrib3fv = (delegate*)load(
+ "glVertexAttrib3fv"u8);
+ contextPtr->glVertexAttrib3s = (delegate*)load(
+ "glVertexAttrib3s"u8);
+ contextPtr->glVertexAttrib3sv = (delegate*)load(
+ "glVertexAttrib3sv"u8);
+ contextPtr->glVertexAttrib4Nbv = (delegate*)load(
+ "glVertexAttrib4Nbv"u8);
+ contextPtr->glVertexAttrib4Niv = (delegate*)load(
+ "glVertexAttrib4Niv"u8);
+ contextPtr->glVertexAttrib4Nsv = (delegate*)load(
+ "glVertexAttrib4Nsv"u8);
+ contextPtr->glVertexAttrib4Nub = (delegate*)load(
+ "glVertexAttrib4Nub"u8);
+ contextPtr->glVertexAttrib4Nubv = (delegate*)load(
+ "glVertexAttrib4Nubv"u8);
+ contextPtr->glVertexAttrib4Nuiv = (delegate*)load(
+ "glVertexAttrib4Nuiv"u8);
+ contextPtr->glVertexAttrib4Nusv = (delegate*)load(
+ "glVertexAttrib4Nusv"u8);
+ contextPtr->glVertexAttrib4bv = (delegate*)load(
+ "glVertexAttrib4bv"u8);
+ contextPtr->glVertexAttrib4d = (delegate*)load(
+ "glVertexAttrib4d"u8);
+ contextPtr->glVertexAttrib4dv = (delegate*)load(
+ "glVertexAttrib4dv"u8);
+ contextPtr->glVertexAttrib4f = (delegate*)load(
+ "glVertexAttrib4f"u8);
+ contextPtr->glVertexAttrib4fv = (delegate*)load(
+ "glVertexAttrib4fv"u8);
+ contextPtr->glVertexAttrib4iv = (delegate*)load(
+ "glVertexAttrib4iv"u8);
+ contextPtr->glVertexAttrib4s = (delegate*)load(
+ "glVertexAttrib4s"u8);
+ contextPtr->glVertexAttrib4sv = (delegate*)load(
+ "glVertexAttrib4sv"u8);
+ contextPtr->glVertexAttrib4ubv = (delegate*)load(
+ "glVertexAttrib4ubv"u8);
+ contextPtr->glVertexAttrib4uiv = (delegate*)load(
+ "glVertexAttrib4uiv"u8);
+ contextPtr->glVertexAttrib4usv = (delegate*)load(
+ "glVertexAttrib4usv"u8);
+ contextPtr->glVertexAttribPointer = (delegate*)load(
+ "glVertexAttribPointer"u8);
+
+ #endregion load
+
+ DefaultLog.InternalAppendLog("Successfully load all OpenGL 2.0 APIs");
+ return true;
+ }
+
+ internal static unsafe bool LoadGLcore21(OpenglContext* contextPtr, delegate*, IntPtr> load)
+ {
+ if (!core21)
+ {
+ DefaultLog.InternalAppendLog("The core version 2.1 is not supported.");
+ return false;
+ }
+
+ #region load
+
+ contextPtr->glUniformMatrix2x3fv = (delegate*)load(
+ "glUniformMatrix2x3fv"u8);
+ contextPtr->glUniformMatrix2x4fv = (delegate*)load(
+ "glUniformMatrix2x4fv"u8);
+ contextPtr->glUniformMatrix3x2fv = (delegate*)load(
+ "glUniformMatrix3x2fv"u8);
+ contextPtr->glUniformMatrix3x4fv = (delegate*)load(
+ "glUniformMatrix3x4fv"u8);
+ contextPtr->glUniformMatrix4x2fv = (delegate*)load(
+ "glUniformMatrix4x2fv"u8);
+ contextPtr->glUniformMatrix4x3fv = (delegate*)load(
+ "glUniformMatrix4x3fv"u8);
+
+ #endregion load
+
+ DefaultLog.InternalAppendLog("Successfully load all OpenGL 2.1 APIs");
+ return true;
+ }
+
+ internal static unsafe bool LoadGLcore30(OpenglContext* contextPtr, delegate*, IntPtr> load)
+ {
+ if (!core30)
+ {
+ DefaultLog.InternalAppendLog("The core version 3.0 is not supported.");
+ return false;
+ }
+
+ #region load
+
+ contextPtr->glBeginConditionalRender = (delegate*)load(
+ "glBeginConditionalRender"u8);
+ contextPtr->glBeginTransformFeedback = (delegate*)load(
+ "glBeginTransformFeedback"u8);
+ contextPtr->glBindBufferBase = (delegate*)load(
+ "glBindBufferBase"u8);
+ contextPtr->glBindBufferRange = (delegate*)load(
+ "glBindBufferRange"u8);
+ contextPtr->glBindFragDataLocation = (delegate*)load(
+ "glBindFragDataLocation"u8);
+ contextPtr->glBindFramebuffer = (delegate*)load(
+ "glBindFramebuffer"u8);
+ contextPtr->glBindRenderbuffer = (delegate*)load(
+ "glBindRenderbuffer"u8);
+ contextPtr->glBindVertexArray = (delegate*)load("glBindVertexArray"u8);
+ contextPtr->glBlitFramebuffer = (delegate*)load(
+ "glBlitFramebuffer"u8);
+ contextPtr->glCheckFramebufferStatus = (delegate*)load(
+ "glCheckFramebufferStatus"u8);
+ contextPtr->glClampColor = (delegate*)load("glClampColor"u8);
+ contextPtr->glClearBufferfi = (delegate*)load(
+ "glClearBufferfi"u8);
+ contextPtr->glClearBufferfv = (delegate*)load(
+ "glClearBufferfv"u8);
+ contextPtr->glClearBufferiv = (delegate*)load(
+ "glClearBufferiv"u8);
+ contextPtr->glClearBufferuiv = (delegate*)load(
+ "glClearBufferuiv"u8);
+ contextPtr->glColorMaski = (delegate*)load(
+ "glColorMaski"u8);
+ contextPtr->glDeleteFramebuffers = (delegate*)load(
+ "glDeleteFramebuffers"u8);
+ contextPtr->glDeleteRenderbuffers = (delegate*)load(
+ "glDeleteRenderbuffers"u8);
+ contextPtr->glDeleteVertexArrays = (delegate*)load(
+ "glDeleteVertexArrays"u8);
+ contextPtr->glDisablei = (delegate*)load("glDisablei"u8);
+ contextPtr->glEnablei = (delegate*)load("glEnablei"u8);
+ contextPtr->glEndConditionalRender = (delegate*)load("glEndConditionalRender"u8);
+ contextPtr->glEndTransformFeedback = (delegate*)load("glEndTransformFeedback"u8);
+ contextPtr->glFlushMappedBufferRange = (delegate*)load(
+ "glFlushMappedBufferRange"u8);
+ contextPtr->glFramebufferRenderbuffer = (delegate*)load(
+ "glFramebufferRenderbuffer"u8);
+ contextPtr->glFramebufferTexture1D = (delegate*)load(
+ "glFramebufferTexture1D"u8);
+ contextPtr->glFramebufferTexture2D = (delegate*)load(
+ "glFramebufferTexture2D"u8);
+ contextPtr->glFramebufferTexture3D = (delegate*)load(
+ "glFramebufferTexture3D"u8);
+ contextPtr->glFramebufferTextureLayer = (delegate*)load(
+ "glFramebufferTextureLayer"u8);
+ contextPtr->glGenFramebuffers = (delegate*)load(
+ "glGenFramebuffers"u8);
+ contextPtr->glGenRenderbuffers = (delegate*)load(
+ "glGenRenderbuffers"u8);
+ contextPtr->glGenVertexArrays = (delegate*)load(
+ "glGenVertexArrays"u8);
+ contextPtr->glGenerateMipmap = (delegate*)load("glGenerateMipmap"u8);
+ contextPtr->glGetBooleani_v = (delegate*)load(
+ "glGetBooleani_v"u8);
+ contextPtr->glGetFragDataLocation = (delegate*)load(
+ "glGetFragDataLocation"u8);
+ contextPtr->glGetFramebufferAttachmentParameteriv = (delegate*)load(
+ "glGetFramebufferAttachmentParameteriv"u8);
+ contextPtr->glGetIntegeri_v = (delegate*)load(
+ "glGetIntegeri_v"u8);
+ contextPtr->glGetRenderbufferParameteriv = (delegate*)load(
+ "glGetRenderbufferParameteriv"u8);
+ contextPtr->glGetStringi = (delegate*