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*)load("glGetStringi"u8); + contextPtr->glGetTexParameterIiv = (delegate*)load( + "glGetTexParameterIiv"u8); + contextPtr->glGetTexParameterIuiv = (delegate*)load( + "glGetTexParameterIuiv"u8); + contextPtr->glGetTransformFeedbackVarying = (delegate*)load( + "glGetTransformFeedbackVarying"u8); + contextPtr->glGetUniformuiv = (delegate*)load( + "glGetUniformuiv"u8); + contextPtr->glGetVertexAttribIiv = (delegate*)load( + "glGetVertexAttribIiv"u8); + contextPtr->glGetVertexAttribIuiv = (delegate*)load( + "glGetVertexAttribIuiv"u8); + contextPtr->glIsEnabledi = (delegate*)load("glIsEnabledi"u8); + contextPtr->glIsFramebuffer = (delegate*)load("glIsFramebuffer"u8); + contextPtr->glIsRenderbuffer = (delegate*)load("glIsRenderbuffer"u8); + contextPtr->glIsVertexArray = (delegate*)load("glIsVertexArray"u8); + contextPtr->glMapBufferRange = (delegate*)load( + "glMapBufferRange"u8); + contextPtr->glRenderbufferStorage = (delegate*)load( + "glRenderbufferStorage"u8); + contextPtr->glRenderbufferStorageMultisample = (delegate*)load( + "glRenderbufferStorageMultisample"u8); + contextPtr->glTexParameterIiv = (delegate*)load( + "glTexParameterIiv"u8); + contextPtr->glTexParameterIuiv = (delegate*)load( + "glTexParameterIuiv"u8); + contextPtr->glTransformFeedbackVaryings = (delegate*)load( + "glTransformFeedbackVaryings"u8); + contextPtr->glUniform1ui = (delegate*)load("glUniform1ui"u8); + contextPtr->glUniform1uiv = (delegate*)load("glUniform1uiv"u8); + contextPtr->glUniform2ui = (delegate*)load("glUniform2ui"u8); + contextPtr->glUniform2uiv = (delegate*)load("glUniform2uiv"u8); + contextPtr->glUniform3ui = (delegate*)load( + "glUniform3ui"u8); + contextPtr->glUniform3uiv = (delegate*)load("glUniform3uiv"u8); + contextPtr->glUniform4ui = (delegate*)load( + "glUniform4ui"u8); + contextPtr->glUniform4uiv = (delegate*)load("glUniform4uiv"u8); + contextPtr->glVertexAttribI1i = (delegate*)load( + "glVertexAttribI1i"u8); + contextPtr->glVertexAttribI1iv = (delegate*)load( + "glVertexAttribI1iv"u8); + contextPtr->glVertexAttribI1ui = (delegate*)load( + "glVertexAttribI1ui"u8); + contextPtr->glVertexAttribI1uiv = (delegate*)load( + "glVertexAttribI1uiv"u8); + contextPtr->glVertexAttribI2i = (delegate*)load( + "glVertexAttribI2i"u8); + contextPtr->glVertexAttribI2iv = (delegate*)load( + "glVertexAttribI2iv"u8); + contextPtr->glVertexAttribI2ui = (delegate*)load( + "glVertexAttribI2ui"u8); + contextPtr->glVertexAttribI2uiv = (delegate*)load( + "glVertexAttribI2uiv"u8); + contextPtr->glVertexAttribI3i = (delegate*)load( + "glVertexAttribI3i"u8); + contextPtr->glVertexAttribI3iv = (delegate*)load( + "glVertexAttribI3iv"u8); + contextPtr->glVertexAttribI3ui = (delegate*)load( + "glVertexAttribI3ui"u8); + contextPtr->glVertexAttribI3uiv = (delegate*)load( + "glVertexAttribI3uiv"u8); + contextPtr->glVertexAttribI4bv = (delegate*)load( + "glVertexAttribI4bv"u8); + contextPtr->glVertexAttribI4i = (delegate*)load( + "glVertexAttribI4i"u8); + contextPtr->glVertexAttribI4iv = (delegate*)load( + "glVertexAttribI4iv"u8); + contextPtr->glVertexAttribI4sv = (delegate*)load( + "glVertexAttribI4sv"u8); + contextPtr->glVertexAttribI4ubv = (delegate*)load( + "glVertexAttribI4ubv"u8); + contextPtr->glVertexAttribI4ui = (delegate*)load( + "glVertexAttribI4ui"u8); + contextPtr->glVertexAttribI4uiv = (delegate*)load( + "glVertexAttribI4uiv"u8); + contextPtr->glVertexAttribI4usv = (delegate*)load( + "glVertexAttribI4usv"u8); + contextPtr->glVertexAttribIPointer = (delegate*)load( + "glVertexAttribIPointer"u8); + + #endregion load + + DefaultLog.InternalAppendLog("Successfully load all OpenGL 3.0 APIs"); + return true; + } + + internal static unsafe bool LoadGLcore31(OpenglContext* contextPtr, delegate*, IntPtr> load) + { + if (!core31) + { + DefaultLog.InternalAppendLog("The core version 3.1 is not supported."); + return false; + } + + #region load + + contextPtr->glBindBufferBase = (delegate*)load( + "glBindBufferBase"u8); + contextPtr->glBindBufferRange = (delegate*)load( + "glBindBufferRange"u8); + contextPtr->glCopyBufferSubData = (delegate*)load( + "glCopyBufferSubData"u8); + contextPtr->glDrawArraysInstanced = (delegate*)load( + "glDrawArraysInstanced"u8); + contextPtr->glDrawElementsInstanced = (delegate*)load( + "glDrawElementsInstanced"u8); + contextPtr->glGetActiveUniformBlockName = (delegate*)load( + "glGetActiveUniformBlockName"u8); + contextPtr->glGetActiveUniformBlockiv = (delegate*)load( + "glGetActiveUniformBlockiv"u8); + contextPtr->glGetActiveUniformName = (delegate*)load( + "glGetActiveUniformName"u8); + contextPtr->glGetActiveUniformsiv = (delegate*)load( + "glGetActiveUniformsiv"u8); + contextPtr->glGetIntegeri_v = (delegate*)load( + "glGetIntegeri_v"u8); + contextPtr->glGetUniformBlockIndex = (delegate*)load( + "glGetUniformBlockIndex"u8); + contextPtr->glGetUniformIndices = (delegate*)load( + "glGetUniformIndices"u8); + contextPtr->glPrimitiveRestartIndex = (delegate*)load( + "glPrimitiveRestartIndex"u8); + contextPtr->glTexBuffer = (delegate*)load("glTexBuffer"u8); + contextPtr->glUniformBlockBinding = (delegate*)load( + "glUniformBlockBinding"u8); + + #endregion load + + DefaultLog.InternalAppendLog("Successfully load all OpenGL 3.1 APIs"); + return true; + } + + internal static unsafe bool LoadGLcore32(OpenglContext* contextPtr, delegate*, IntPtr> load) + { + if (!core32) + { + DefaultLog.InternalAppendLog("The core version 3.2 is not supported."); + return false; + } + + #region load + + contextPtr->glClientWaitSync = (delegate*)load( + "glClientWaitSync"u8); + contextPtr->glDeleteSync = (delegate*)load("glDeleteSync"u8); + contextPtr->glDrawElementsBaseVertex = (delegate*)load( + "glDrawElementsBaseVertex"u8); + contextPtr->glDrawElementsInstancedBaseVertex = (delegate*)load( + "glDrawElementsInstancedBaseVertex"u8); + contextPtr->glDrawRangeElementsBaseVertex = (delegate*)load( + "glDrawRangeElementsBaseVertex"u8); + contextPtr->glFenceSync = (delegate*)load("glFenceSync"u8); + contextPtr->glFramebufferTexture = (delegate*)load( + "glFramebufferTexture"u8); + contextPtr->glGetBufferParameteri64v = (delegate*)load( + "glGetBufferParameteri64v"u8); + contextPtr->glGetInteger64i_v = (delegate*)load( + "glGetInteger64i_v"u8); + contextPtr->glGetInteger64v = (delegate*)load("glGetInteger64v"u8); + contextPtr->glGetMultisamplefv = (delegate*)load( + "glGetMultisamplefv"u8); + contextPtr->glGetSynciv = (delegate*)load( + "glGetSynciv"u8); + contextPtr->glIsSync = (delegate*)load("glIsSync"u8); + contextPtr->glMultiDrawElementsBaseVertex = (delegate*)load( + "glMultiDrawElementsBaseVertex"u8); + contextPtr->glProvokingVertex = (delegate*)load("glProvokingVertex"u8); + contextPtr->glSampleMaski = (delegate*)load("glSampleMaski"u8); + contextPtr->glTexImage2DMultisample = (delegate*)load( + "glTexImage2DMultisample"u8); + contextPtr->glTexImage3DMultisample = (delegate*)load( + "glTexImage3DMultisample"u8); + contextPtr->glWaitSync = (delegate*)load("glWaitSync"u8); + + #endregion load + + DefaultLog.InternalAppendLog("Successfully load all OpenGL 3.2 APIs"); + return true; + } + + internal static unsafe bool LoadGLcore33(OpenglContext* contextPtr, delegate*, IntPtr> load) + { + if (!core33) + { + DefaultLog.InternalAppendLog("The core version 3.3 is not supported."); + return false; + } + + #region load + + contextPtr->glBindFragDataLocationIndexed = (delegate*)load( + "glBindFragDataLocationIndexed"u8); + contextPtr->glBindSampler = (delegate*)load("glBindSampler"u8); + contextPtr->glDeleteSamplers = (delegate*)load( + "glDeleteSamplers"u8); + contextPtr->glGenSamplers = (delegate*)load("glGenSamplers"u8); + contextPtr->glGetFragDataIndex = (delegate*)load( + "glGetFragDataIndex"u8); + contextPtr->glGetQueryObjecti64v = (delegate*)load( + "glGetQueryObjecti64v"u8); + contextPtr->glGetQueryObjectui64v = (delegate*)load( + "glGetQueryObjectui64v"u8); + contextPtr->glGetSamplerParameterIiv = (delegate*)load( + "glGetSamplerParameterIiv"u8); + contextPtr->glGetSamplerParameterIuiv = (delegate*)load( + "glGetSamplerParameterIuiv"u8); + contextPtr->glGetSamplerParameterfv = (delegate*)load( + "glGetSamplerParameterfv"u8); + contextPtr->glGetSamplerParameteriv = (delegate*)load( + "glGetSamplerParameteriv"u8); + contextPtr->glIsSampler = (delegate*)load("glIsSampler"u8); + contextPtr->glQueryCounter = (delegate*)load("glQueryCounter"u8); + contextPtr->glSamplerParameterIiv = (delegate*)load( + "glSamplerParameterIiv"u8); + contextPtr->glSamplerParameterIuiv = (delegate*)load( + "glSamplerParameterIuiv"u8); + contextPtr->glSamplerParameterf = (delegate*)load( + "glSamplerParameterf"u8); + contextPtr->glSamplerParameterfv = (delegate*)load( + "glSamplerParameterfv"u8); + contextPtr->glSamplerParameteri = (delegate*)load( + "glSamplerParameteri"u8); + contextPtr->glSamplerParameteriv = (delegate*)load( + "glSamplerParameteriv"u8); + contextPtr->glVertexAttribDivisor = (delegate*)load( + "glVertexAttribDivisor"u8); + contextPtr->glVertexAttribP1ui = (delegate*)load( + "glVertexAttribP1ui"u8); + contextPtr->glVertexAttribP1uiv = (delegate*)load( + "glVertexAttribP1uiv"u8); + contextPtr->glVertexAttribP2ui = (delegate*)load( + "glVertexAttribP2ui"u8); + contextPtr->glVertexAttribP2uiv = (delegate*)load( + "glVertexAttribP2uiv"u8); + contextPtr->glVertexAttribP3ui = (delegate*)load( + "glVertexAttribP3ui"u8); + contextPtr->glVertexAttribP3uiv = (delegate*)load( + "glVertexAttribP3uiv"u8); + contextPtr->glVertexAttribP4ui = (delegate*)load( + "glVertexAttribP4ui"u8); + contextPtr->glVertexAttribP4uiv = (delegate*)load( + "glVertexAttribP4uiv"u8); + + #endregion load + + DefaultLog.InternalAppendLog("Successfully load all OpenGL 3.3 APIs"); + return true; + } + + internal static unsafe bool LoadGLcore40(OpenglContext* contextPtr, delegate*, IntPtr> load) + { + if (!core40) + { + DefaultLog.InternalAppendLog("The core version 4.0 is not supported."); + return false; + } + + #region load + + contextPtr->glBeginQueryIndexed = (delegate*)load( + "glBeginQueryIndexed"u8); + contextPtr->glBindTransformFeedback = (delegate*)load( + "glBindTransformFeedback"u8); + contextPtr->glBlendEquationSeparatei = (delegate*)load( + "glBlendEquationSeparatei"u8); + contextPtr->glBlendEquationi = (delegate*)load("glBlendEquationi"u8); + contextPtr->glBlendFuncSeparatei = (delegate*)load( + "glBlendFuncSeparatei"u8); + contextPtr->glBlendFunci = (delegate*)load("glBlendFunci"u8); + contextPtr->glDeleteTransformFeedbacks = (delegate*)load( + "glDeleteTransformFeedbacks"u8); + contextPtr->glDrawArraysIndirect = (delegate*)load( + "glDrawArraysIndirect"u8); + contextPtr->glDrawElementsIndirect = (delegate*)load( + "glDrawElementsIndirect"u8); + contextPtr->glDrawTransformFeedback = (delegate*)load( + "glDrawTransformFeedback"u8); + contextPtr->glDrawTransformFeedbackStream = (delegate*)load( + "glDrawTransformFeedbackStream"u8); + contextPtr->glEndQueryIndexed = (delegate*)load( + "glEndQueryIndexed"u8); + contextPtr->glGenTransformFeedbacks = (delegate*)load( + "glGenTransformFeedbacks"u8); + contextPtr->glGetActiveSubroutineName = (delegate*)load( + "glGetActiveSubroutineName"u8); + contextPtr->glGetActiveSubroutineUniformName = (delegate*)load( + "glGetActiveSubroutineUniformName"u8); + contextPtr->glGetActiveSubroutineUniformiv = (delegate*)load( + "glGetActiveSubroutineUniformiv"u8); + contextPtr->glGetProgramStageiv = (delegate*)load( + "glGetProgramStageiv"u8); + contextPtr->glGetQueryIndexediv = (delegate*)load( + "glGetQueryIndexediv"u8); + contextPtr->glGetSubroutineIndex = (delegate*)load( + "glGetSubroutineIndex"u8); + contextPtr->glGetSubroutineUniformLocation = (delegate*)load( + "glGetSubroutineUniformLocation"u8); + contextPtr->glGetUniformSubroutineuiv = (delegate*)load( + "glGetUniformSubroutineuiv"u8); + contextPtr->glGetUniformdv = (delegate*)load( + "glGetUniformdv"u8); + contextPtr->glIsTransformFeedback = (delegate*)load( + "glIsTransformFeedback"u8); + contextPtr->glMinSampleShading = (delegate*)load("glMinSampleShading"u8); + contextPtr->glPatchParameterfv = (delegate*)load( + "glPatchParameterfv"u8); + contextPtr->glPatchParameteri = (delegate*)load( + "glPatchParameteri"u8); + contextPtr->glPauseTransformFeedback = (delegate*)load( + "glPauseTransformFeedback"u8); + contextPtr->glResumeTransformFeedback = (delegate*)load( + "glResumeTransformFeedback"u8); + contextPtr->glUniform1d = (delegate*)load("glUniform1d"u8); + contextPtr->glUniform1dv = (delegate*)load("glUniform1dv"u8); + contextPtr->glUniform2d = (delegate*)load("glUniform2d"u8); + contextPtr->glUniform2dv = (delegate*)load("glUniform2dv"u8); + contextPtr->glUniform3d = (delegate*)load( + "glUniform3d"u8); + contextPtr->glUniform3dv = (delegate*)load("glUniform3dv"u8); + contextPtr->glUniform4d = (delegate*)load( + "glUniform4d"u8); + contextPtr->glUniform4dv = (delegate*)load("glUniform4dv"u8); + contextPtr->glUniformMatrix2dv = (delegate*)load( + "glUniformMatrix2dv"u8); + contextPtr->glUniformMatrix2x3dv = (delegate*)load( + "glUniformMatrix2x3dv"u8); + contextPtr->glUniformMatrix2x4dv = (delegate*)load( + "glUniformMatrix2x4dv"u8); + contextPtr->glUniformMatrix3dv = (delegate*)load( + "glUniformMatrix3dv"u8); + contextPtr->glUniformMatrix3x2dv = (delegate*)load( + "glUniformMatrix3x2dv"u8); + contextPtr->glUniformMatrix3x4dv = (delegate*)load( + "glUniformMatrix3x4dv"u8); + contextPtr->glUniformMatrix4dv = (delegate*)load( + "glUniformMatrix4dv"u8); + contextPtr->glUniformMatrix4x2dv = (delegate*)load( + "glUniformMatrix4x2dv"u8); + contextPtr->glUniformMatrix4x3dv = (delegate*)load( + "glUniformMatrix4x3dv"u8); + contextPtr->glUniformSubroutinesuiv = (delegate*)load( + "glUniformSubroutinesuiv"u8); + + #endregion load + + DefaultLog.InternalAppendLog("Successfully load all OpenGL 4.0 APIs"); + return true; + } + + internal static unsafe bool LoadGLcore41(OpenglContext* contextPtr, delegate*, IntPtr> load) + { + if (!core41) + { + DefaultLog.InternalAppendLog("The core version 4.1 is not supported."); + return false; + } + + #region load + + contextPtr->glActiveShaderProgram = (delegate*)load( + "glActiveShaderProgram"u8); + contextPtr->glBindProgramPipeline = (delegate*)load( + "glBindProgramPipeline"u8); + contextPtr->glClearDepthf = (delegate*)load("glClearDepthf"u8); + contextPtr->glCreateShaderProgramv = (delegate*)load( + "glCreateShaderProgramv"u8); + contextPtr->glDeleteProgramPipelines = (delegate*)load( + "glDeleteProgramPipelines"u8); + contextPtr->glDepthRangeArrayv = (delegate*)load( + "glDepthRangeArrayv"u8); + contextPtr->glDepthRangeIndexed = (delegate*)load( + "glDepthRangeIndexed"u8); + contextPtr->glDepthRangef = (delegate*)load("glDepthRangef"u8); + contextPtr->glGenProgramPipelines = (delegate*)load( + "glGenProgramPipelines"u8); + contextPtr->glGetDoublei_v = (delegate*)load( + "glGetDoublei_v"u8); + contextPtr->glGetFloati_v = (delegate*)load( + "glGetFloati_v"u8); + contextPtr->glGetProgramBinary = (delegate*)load( + "glGetProgramBinary"u8); + contextPtr->glGetProgramPipelineInfoLog = (delegate*)load( + "glGetProgramPipelineInfoLog"u8); + contextPtr->glGetProgramPipelineiv = (delegate*)load( + "glGetProgramPipelineiv"u8); + contextPtr->glGetShaderPrecisionFormat = (delegate*)load( + "glGetShaderPrecisionFormat"u8); + contextPtr->glGetVertexAttribLdv = (delegate*)load( + "glGetVertexAttribLdv"u8); + contextPtr->glIsProgramPipeline = (delegate*)load("glIsProgramPipeline"u8); + contextPtr->glProgramBinary = (delegate*)load( + "glProgramBinary"u8); + contextPtr->glProgramParameteri = (delegate*)load( + "glProgramParameteri"u8); + contextPtr->glProgramUniform1d = (delegate*)load( + "glProgramUniform1d"u8); + contextPtr->glProgramUniform1dv = (delegate*)load( + "glProgramUniform1dv"u8); + contextPtr->glProgramUniform1f = (delegate*)load( + "glProgramUniform1f"u8); + contextPtr->glProgramUniform1fv = (delegate*)load( + "glProgramUniform1fv"u8); + contextPtr->glProgramUniform1i = (delegate*)load( + "glProgramUniform1i"u8); + contextPtr->glProgramUniform1iv = (delegate*)load( + "glProgramUniform1iv"u8); + contextPtr->glProgramUniform1ui = (delegate*)load( + "glProgramUniform1ui"u8); + contextPtr->glProgramUniform1uiv = (delegate*)load( + "glProgramUniform1uiv"u8); + contextPtr->glProgramUniform2d = (delegate*)load( + "glProgramUniform2d"u8); + contextPtr->glProgramUniform2dv = (delegate*)load( + "glProgramUniform2dv"u8); + contextPtr->glProgramUniform2f = (delegate*)load( + "glProgramUniform2f"u8); + contextPtr->glProgramUniform2fv = (delegate*)load( + "glProgramUniform2fv"u8); + contextPtr->glProgramUniform2i = (delegate*)load( + "glProgramUniform2i"u8); + contextPtr->glProgramUniform2iv = (delegate*)load( + "glProgramUniform2iv"u8); + contextPtr->glProgramUniform2ui = (delegate*)load( + "glProgramUniform2ui"u8); + contextPtr->glProgramUniform2uiv = (delegate*)load( + "glProgramUniform2uiv"u8); + contextPtr->glProgramUniform3d = (delegate*)load( + "glProgramUniform3d"u8); + contextPtr->glProgramUniform3dv = (delegate*)load( + "glProgramUniform3dv"u8); + contextPtr->glProgramUniform3f = (delegate*)load( + "glProgramUniform3f"u8); + contextPtr->glProgramUniform3fv = (delegate*)load( + "glProgramUniform3fv"u8); + contextPtr->glProgramUniform3i = (delegate*)load( + "glProgramUniform3i"u8); + contextPtr->glProgramUniform3iv = (delegate*)load( + "glProgramUniform3iv"u8); + contextPtr->glProgramUniform3ui = (delegate*)load( + "glProgramUniform3ui"u8); + contextPtr->glProgramUniform3uiv = (delegate*)load( + "glProgramUniform3uiv"u8); + contextPtr->glProgramUniform4d = (delegate*)load( + "glProgramUniform4d"u8); + contextPtr->glProgramUniform4dv = (delegate*)load( + "glProgramUniform4dv"u8); + contextPtr->glProgramUniform4f = (delegate*)load( + "glProgramUniform4f"u8); + contextPtr->glProgramUniform4fv = (delegate*)load( + "glProgramUniform4fv"u8); + contextPtr->glProgramUniform4i = (delegate*)load( + "glProgramUniform4i"u8); + contextPtr->glProgramUniform4iv = (delegate*)load( + "glProgramUniform4iv"u8); + contextPtr->glProgramUniform4ui = (delegate*)load( + "glProgramUniform4ui"u8); + contextPtr->glProgramUniform4uiv = (delegate*)load( + "glProgramUniform4uiv"u8); + contextPtr->glProgramUniformMatrix2dv = (delegate*)load( + "glProgramUniformMatrix2dv"u8); + contextPtr->glProgramUniformMatrix2fv = (delegate*)load( + "glProgramUniformMatrix2fv"u8); + contextPtr->glProgramUniformMatrix2x3dv = (delegate*)load( + "glProgramUniformMatrix2x3dv"u8); + contextPtr->glProgramUniformMatrix2x3fv = (delegate*)load( + "glProgramUniformMatrix2x3fv"u8); + contextPtr->glProgramUniformMatrix2x4dv = (delegate*)load( + "glProgramUniformMatrix2x4dv"u8); + contextPtr->glProgramUniformMatrix2x4fv = (delegate*)load( + "glProgramUniformMatrix2x4fv"u8); + contextPtr->glProgramUniformMatrix3dv = (delegate*)load( + "glProgramUniformMatrix3dv"u8); + contextPtr->glProgramUniformMatrix3fv = (delegate*)load( + "glProgramUniformMatrix3fv"u8); + contextPtr->glProgramUniformMatrix3x2dv = (delegate*)load( + "glProgramUniformMatrix3x2dv"u8); + contextPtr->glProgramUniformMatrix3x2fv = (delegate*)load( + "glProgramUniformMatrix3x2fv"u8); + contextPtr->glProgramUniformMatrix3x4dv = (delegate*)load( + "glProgramUniformMatrix3x4dv"u8); + contextPtr->glProgramUniformMatrix3x4fv = (delegate*)load( + "glProgramUniformMatrix3x4fv"u8); + contextPtr->glProgramUniformMatrix4dv = (delegate*)load( + "glProgramUniformMatrix4dv"u8); + contextPtr->glProgramUniformMatrix4fv = (delegate*)load( + "glProgramUniformMatrix4fv"u8); + contextPtr->glProgramUniformMatrix4x2dv = (delegate*)load( + "glProgramUniformMatrix4x2dv"u8); + contextPtr->glProgramUniformMatrix4x2fv = (delegate*)load( + "glProgramUniformMatrix4x2fv"u8); + contextPtr->glProgramUniformMatrix4x3dv = (delegate*)load( + "glProgramUniformMatrix4x3dv"u8); + contextPtr->glProgramUniformMatrix4x3fv = (delegate*)load( + "glProgramUniformMatrix4x3fv"u8); + contextPtr->glReleaseShaderCompiler = (delegate*)load( + "glReleaseShaderCompiler"u8); + contextPtr->glScissorArrayv = (delegate*)load( + "glScissorArrayv"u8); + contextPtr->glScissorIndexed = (delegate*)load( + "glScissorIndexed"u8); + contextPtr->glScissorIndexedv = (delegate*)load( + "glScissorIndexedv"u8); + contextPtr->glShaderBinary = (delegate*)load( + "glShaderBinary"u8); + contextPtr->glUseProgramStages = (delegate*)load( + "glUseProgramStages"u8); + contextPtr->glValidateProgramPipeline = (delegate*)load( + "glValidateProgramPipeline"u8); + contextPtr->glVertexAttribL1d = (delegate*)load( + "glVertexAttribL1d"u8); + contextPtr->glVertexAttribL1dv = (delegate*)load( + "glVertexAttribL1dv"u8); + contextPtr->glVertexAttribL2d = (delegate*)load( + "glVertexAttribL2d"u8); + contextPtr->glVertexAttribL2dv = (delegate*)load( + "glVertexAttribL2dv"u8); + contextPtr->glVertexAttribL3d = (delegate*)load( + "glVertexAttribL3d"u8); + contextPtr->glVertexAttribL3dv = (delegate*)load( + "glVertexAttribL3dv"u8); + contextPtr->glVertexAttribL4d = (delegate*)load( + "glVertexAttribL4d"u8); + contextPtr->glVertexAttribL4dv = (delegate*)load( + "glVertexAttribL4dv"u8); + contextPtr->glVertexAttribLPointer = (delegate*)load( + "glVertexAttribLPointer"u8); + contextPtr->glViewportArrayv = (delegate*)load( + "glViewportArrayv"u8); + contextPtr->glViewportIndexedf = (delegate*)load( + "glViewportIndexedf"u8); + contextPtr->glViewportIndexedfv = (delegate*)load( + "glViewportIndexedfv"u8); + + #endregion load + + DefaultLog.InternalAppendLog("Successfully load all OpenGL 4.1 APIs"); + return true; + } + + internal static unsafe bool LoadGLcore42(OpenglContext* contextPtr, delegate*, IntPtr> load) + { + if (!core42) + { + DefaultLog.InternalAppendLog("The core version 4.2 is not supported."); + return false; + } + + #region load + + contextPtr->glBindImageTexture = (delegate*)load( + "glBindImageTexture"u8); + contextPtr->glDrawArraysInstancedBaseInstance = (delegate*)load( + "glDrawArraysInstancedBaseInstance"u8); + contextPtr->glDrawElementsInstancedBaseInstance = (delegate*)load( + "glDrawElementsInstancedBaseInstance"u8); + contextPtr->glDrawElementsInstancedBaseVertexBaseInstance = (delegate*)load( + "glDrawElementsInstancedBaseVertexBaseInstance"u8); + contextPtr->glDrawTransformFeedbackInstanced = (delegate*)load( + "glDrawTransformFeedbackInstanced"u8); + contextPtr->glDrawTransformFeedbackStreamInstanced = (delegate*)load( + "glDrawTransformFeedbackStreamInstanced"u8); + contextPtr->glGetActiveAtomicCounterBufferiv = (delegate*)load( + "glGetActiveAtomicCounterBufferiv"u8); + contextPtr->glGetInternalformativ = (delegate*)load( + "glGetInternalformativ"u8); + contextPtr->glMemoryBarrier = (delegate*)load("glMemoryBarrier"u8); + contextPtr->glTexStorage1D = (delegate*)load( + "glTexStorage1D"u8); + contextPtr->glTexStorage2D = (delegate*)load( + "glTexStorage2D"u8); + contextPtr->glTexStorage3D = (delegate*)load( + "glTexStorage3D"u8); + + #endregion load + + DefaultLog.InternalAppendLog("Successfully load all OpenGL 4.2 APIs"); + return true; + } + + internal static unsafe bool LoadGLcore43(OpenglContext* contextPtr, delegate*, IntPtr> load) + { + if (!core43) + { + DefaultLog.InternalAppendLog("The core version 4.3 is not supported."); + return false; + } + + #region load + + contextPtr->glBindVertexBuffer = (delegate*)load( + "glBindVertexBuffer"u8); + contextPtr->glClearBufferData = (delegate*)load( + "glClearBufferData"u8); + contextPtr->glClearBufferSubData = (delegate*)load( + "glClearBufferSubData"u8); + contextPtr->glCopyImageSubData = (delegate*)load( + "glCopyImageSubData"u8); + contextPtr->glDebugMessageCallback = (delegate*)load( + "glDebugMessageCallback"u8); + contextPtr->glDebugMessageControl = (delegate*)load( + "glDebugMessageControl"u8); + contextPtr->glDebugMessageInsert = (delegate*)load( + "glDebugMessageInsert"u8); + contextPtr->glDispatchCompute = (delegate*)load( + "glDispatchCompute"u8); + contextPtr->glDispatchComputeIndirect = (delegate*)load( + "glDispatchComputeIndirect"u8); + contextPtr->glFramebufferParameteri = (delegate*)load( + "glFramebufferParameteri"u8); + contextPtr->glGetDebugMessageLog = (delegate*)load( + "glGetDebugMessageLog"u8); + contextPtr->glGetFramebufferParameteriv = (delegate*)load( + "glGetFramebufferParameteriv"u8); + contextPtr->glGetInternalformati64v = (delegate*)load( + "glGetInternalformati64v"u8); + contextPtr->glGetObjectLabel = (delegate*)load( + "glGetObjectLabel"u8); + contextPtr->glGetObjectPtrLabel = (delegate*)load( + "glGetObjectPtrLabel"u8); + contextPtr->glGetPointerv = (delegate*)load("glGetPointerv"u8); + contextPtr->glGetProgramInterfaceiv = (delegate*)load( + "glGetProgramInterfaceiv"u8); + contextPtr->glGetProgramResourceIndex = (delegate*)load( + "glGetProgramResourceIndex"u8); + contextPtr->glGetProgramResourceLocation = (delegate*)load( + "glGetProgramResourceLocation"u8); + contextPtr->glGetProgramResourceLocationIndex = (delegate*)load( + "glGetProgramResourceLocationIndex"u8); + contextPtr->glGetProgramResourceName = (delegate*)load( + "glGetProgramResourceName"u8); + contextPtr->glGetProgramResourceiv = (delegate*)load( + "glGetProgramResourceiv"u8); + contextPtr->glInvalidateBufferData = (delegate*)load( + "glInvalidateBufferData"u8); + contextPtr->glInvalidateBufferSubData = (delegate*)load( + "glInvalidateBufferSubData"u8); + contextPtr->glInvalidateFramebuffer = (delegate*)load( + "glInvalidateFramebuffer"u8); + contextPtr->glInvalidateSubFramebuffer = (delegate*)load( + "glInvalidateSubFramebuffer"u8); + contextPtr->glInvalidateTexImage = (delegate*)load( + "glInvalidateTexImage"u8); + contextPtr->glInvalidateTexSubImage = (delegate*)load( + "glInvalidateTexSubImage"u8); + contextPtr->glMultiDrawArraysIndirect = (delegate*)load( + "glMultiDrawArraysIndirect"u8); + contextPtr->glMultiDrawElementsIndirect = (delegate*)load( + "glMultiDrawElementsIndirect"u8); + contextPtr->glObjectLabel = (delegate*)load( + "glObjectLabel"u8); + contextPtr->glObjectPtrLabel = (delegate*)load( + "glObjectPtrLabel"u8); + contextPtr->glPopDebugGroup = (delegate*)load("glPopDebugGroup"u8); + contextPtr->glPushDebugGroup = (delegate*)load( + "glPushDebugGroup"u8); + contextPtr->glShaderStorageBlockBinding = (delegate*)load( + "glShaderStorageBlockBinding"u8); + contextPtr->glTexBufferRange = (delegate*)load( + "glTexBufferRange"u8); + contextPtr->glTexStorage2DMultisample = (delegate*)load( + "glTexStorage2DMultisample"u8); + contextPtr->glTexStorage3DMultisample = (delegate*)load( + "glTexStorage3DMultisample"u8); + contextPtr->glTextureView = (delegate*)load( + "glTextureView"u8); + contextPtr->glVertexAttribBinding = (delegate*)load( + "glVertexAttribBinding"u8); + contextPtr->glVertexAttribFormat = (delegate*)load( + "glVertexAttribFormat"u8); + contextPtr->glVertexAttribIFormat = (delegate*)load( + "glVertexAttribIFormat"u8); + contextPtr->glClearBufferData = (delegate*)load( + "glClearBufferData"u8); + contextPtr->glVertexBindingDivisor = (delegate*)load( + "glVertexBindingDivisor"u8); + + #endregion load + + DefaultLog.InternalAppendLog("Successfully load all OpenGL 4.3 APIs"); + return true; + } + + internal static unsafe bool LoadGLcore44(OpenglContext* contextPtr, delegate*, IntPtr> load) + { + if (!core44) + { + DefaultLog.InternalAppendLog("The core version 4.4 is not supported."); + return false; + } + + #region load + + contextPtr->glBindBuffersBase = (delegate*)load( + "glBindBuffersBase"u8); + contextPtr->glBindBuffersRange = (delegate*)load( + "glBindBuffersRange"u8); + contextPtr->glBindImageTextures = (delegate*)load( + "glBindImageTextures"u8); + contextPtr->glBindSamplers = (delegate*)load( + "glBindSamplers"u8); + contextPtr->glBindTextures = (delegate*)load( + "glBindTextures"u8); + contextPtr->glBindVertexBuffers = (delegate*)load( + "glBindVertexBuffers"u8); + contextPtr->glBufferStorage = (delegate*)load( + "glBufferStorage"u8); + contextPtr->glClearTexImage = (delegate*)load( + "glClearTexImage"u8); + contextPtr->glClearTexSubImage = (delegate*)load( + "glClearTexSubImage"u8); + + #endregion load + + DefaultLog.InternalAppendLog("Successfully load all OpenGL 4.4 APIs"); + return true; + } + + internal static unsafe bool LoadGLcore45(OpenglContext* contextPtr, delegate*, IntPtr> load) + { + if (!core45) + { + DefaultLog.InternalAppendLog("The core version 4.5 is not supported."); + return false; + } + + #region load + + contextPtr->glBindTextureUnit = (delegate*)load( + "glBindTextureUnit"u8); + contextPtr->glBlitNamedFramebuffer = (delegate*)load( + "glBlitNamedFramebuffer"u8); + contextPtr->glCheckNamedFramebufferStatus = (delegate*)load( + "glCheckNamedFramebufferStatus"u8); + contextPtr->glClearNamedBufferData = (delegate*)load( + "glClearNamedBufferData"u8); + contextPtr->glClearNamedBufferSubData = (delegate*)load( + "glClearNamedBufferSubData"u8); + contextPtr->glClearNamedFramebufferfi = (delegate*)load( + "glClearNamedFramebufferfi"u8); + contextPtr->glClearNamedFramebufferfv = (delegate*)load( + "glClearNamedFramebufferfv"u8); + contextPtr->glClearNamedFramebufferiv = (delegate*)load( + "glClearNamedFramebufferiv"u8); + contextPtr->glClearNamedFramebufferuiv = (delegate*)load( + "glClearNamedFramebufferuiv"u8); + contextPtr->glClipControl = (delegate*)load("glClipControl"u8); + contextPtr->glCompressedTextureSubImage1D = (delegate*)load( + "glCompressedTextureSubImage1D"u8); + contextPtr->glCompressedTextureSubImage2D = (delegate*)load( + "glCompressedTextureSubImage2D"u8); + contextPtr->glCompressedTextureSubImage3D = (delegate*)load( + "glCompressedTextureSubImage3D"u8); + contextPtr->glCopyNamedBufferSubData = (delegate*)load( + "glCopyNamedBufferSubData"u8); + contextPtr->glCopyTextureSubImage1D = (delegate*)load( + "glCopyTextureSubImage1D"u8); + contextPtr->glCopyTextureSubImage2D = (delegate*)load( + "glCopyTextureSubImage2D"u8); + contextPtr->glCopyTextureSubImage3D = (delegate*)load( + "glCopyTextureSubImage3D"u8); + contextPtr->glCreateBuffers = (delegate*)load("glCreateBuffers"u8); + contextPtr->glCreateFramebuffers = (delegate*)load( + "glCreateFramebuffers"u8); + contextPtr->glCreateProgramPipelines = (delegate*)load( + "glCreateProgramPipelines"u8); + contextPtr->glCreateQueries = (delegate*)load( + "glCreateQueries"u8); + contextPtr->glCreateRenderbuffers = (delegate*)load( + "glCreateRenderbuffers"u8); + contextPtr->glCreateSamplers = (delegate*)load( + "glCreateSamplers"u8); + contextPtr->glCreateTextures = (delegate*)load( + "glCreateTextures"u8); + contextPtr->glCreateTransformFeedbacks = (delegate*)load( + "glCreateTransformFeedbacks"u8); + contextPtr->glCreateVertexArrays = (delegate*)load( + "glCreateVertexArrays"u8); + contextPtr->glDisableVertexArrayAttrib = (delegate*)load( + "glDisableVertexArrayAttrib"u8); + contextPtr->glEnableVertexArrayAttrib = (delegate*)load( + "glEnableVertexArrayAttrib"u8); + contextPtr->glFlushMappedNamedBufferRange = (delegate*)load( + "glFlushMappedNamedBufferRange"u8); + contextPtr->glGenerateTextureMipmap = (delegate*)load( + "glGenerateTextureMipmap"u8); + contextPtr->glGetCompressedTextureImage = (delegate*)load( + "glGetCompressedTextureImage"u8); + contextPtr->glGetCompressedTextureSubImage = (delegate*)load( + "glGetCompressedTextureSubImage"u8); + contextPtr->glGetGraphicsResetStatus = (delegate*)load( + "glGetGraphicsResetStatus"u8); + contextPtr->glGetNamedBufferParameteri64v = (delegate*)load( + "glGetNamedBufferParameteri64v"u8); + contextPtr->glGetNamedBufferParameteriv = (delegate*)load( + "glGetNamedBufferParameteriv"u8); + contextPtr->glGetNamedBufferPointerv = (delegate*)load( + "glGetNamedBufferPointerv"u8); + contextPtr->glGetNamedBufferSubData = (delegate*)load( + "glGetNamedBufferSubData"u8); + contextPtr->glGetNamedFramebufferAttachmentParameteriv = (delegate*)load( + "glGetNamedFramebufferAttachmentParameteriv"u8); + contextPtr->glGetNamedFramebufferParameteriv = (delegate*)load( + "glGetNamedFramebufferParameteriv"u8); + contextPtr->glGetNamedRenderbufferParameteriv = (delegate*)load( + "glGetNamedRenderbufferParameteriv"u8); + contextPtr->glGetQueryBufferObjecti64v = (delegate*)load( + "glGetQueryBufferObjecti64v"u8); + contextPtr->glGetQueryBufferObjectiv = (delegate*)load( + "glGetQueryBufferObjectiv"u8); + contextPtr->glGetQueryBufferObjectui64v = (delegate*)load( + "glGetQueryBufferObjectui64v"u8); + contextPtr->glGetQueryBufferObjectuiv = (delegate*)load( + "glGetQueryBufferObjectuiv"u8); + contextPtr->glGetTextureImage = (delegate*)load( + "glGetTextureImage"u8); + contextPtr->glGetTextureLevelParameterfv = (delegate*)load( + "glGetTextureLevelParameterfv"u8); + contextPtr->glGetTextureLevelParameteriv = (delegate*)load( + "glGetTextureLevelParameteriv"u8); + contextPtr->glGetTextureParameterIiv = (delegate*)load( + "glGetTextureParameterIiv"u8); + contextPtr->glGetTextureParameterIuiv = (delegate*)load( + "glGetTextureParameterIuiv"u8); + contextPtr->glGetTextureParameterfv = (delegate*)load( + "glGetTextureParameterfv"u8); + contextPtr->glGetTextureParameteriv = (delegate*)load( + "glGetTextureParameteriv"u8); + contextPtr->glGetTextureSubImage = (delegate*)load( + "glGetTextureSubImage"u8); + contextPtr->glGetTransformFeedbacki64_v = (delegate*)load( + "glGetTransformFeedbacki64_v"u8); + contextPtr->glGetTransformFeedbacki_v = (delegate*)load( + "glGetTransformFeedbacki_v"u8); + contextPtr->glGetTransformFeedbackiv = (delegate*)load( + "glGetTransformFeedbackiv"u8); + contextPtr->glGetVertexArrayIndexed64iv = (delegate*)load( + "glGetVertexArrayIndexed64iv"u8); + contextPtr->glGetVertexArrayIndexediv = (delegate*)load( + "glGetVertexArrayIndexediv"u8); + contextPtr->glGetVertexArrayiv = (delegate*)load( + "glGetVertexArrayiv"u8); + contextPtr->glGetnCompressedTexImage = (delegate*)load( + "glGetnCompressedTexImage"u8); + contextPtr->glGetnTexImage = (delegate*)load( + "glGetnTexImage"u8); + contextPtr->glGetnUniformdv = (delegate*)load( + "glGetnUniformdv"u8); + contextPtr->glGetnUniformfv = (delegate*)load( + "glGetnUniformfv"u8); + contextPtr->glGetnUniformiv = (delegate*)load( + "glGetnUniformiv"u8); + contextPtr->glGetnUniformuiv = (delegate*)load( + "glGetnUniformuiv"u8); + contextPtr->glInvalidateNamedFramebufferData = (delegate*)load( + "glInvalidateNamedFramebufferData"u8); + contextPtr->glInvalidateNamedFramebufferSubData = (delegate*)load( + "glInvalidateNamedFramebufferSubData"u8); + contextPtr->glMapNamedBuffer = (delegate*)load( + "glMapNamedBuffer"u8); + contextPtr->glMapNamedBufferRange = (delegate*)load( + "glMapNamedBufferRange"u8); + contextPtr->glMemoryBarrierByRegion = (delegate*)load( + "glMemoryBarrierByRegion"u8); + contextPtr->glNamedBufferData = (delegate*)load( + "glNamedBufferData"u8); + contextPtr->glNamedBufferStorage = (delegate*)load( + "glNamedBufferStorage"u8); + contextPtr->glNamedBufferSubData = (delegate*)load( + "glNamedBufferSubData"u8); + contextPtr->glNamedFramebufferDrawBuffer = (delegate*)load( + "glNamedFramebufferDrawBuffer"u8); + contextPtr->glNamedFramebufferDrawBuffers = (delegate*)load( + "glNamedFramebufferDrawBuffers"u8); + contextPtr->glNamedFramebufferParameteri = (delegate*)load( + "glNamedFramebufferParameteri"u8); + contextPtr->glNamedFramebufferReadBuffer = (delegate*)load( + "glNamedFramebufferReadBuffer"u8); + contextPtr->glNamedFramebufferRenderbuffer = (delegate*)load( + "glNamedFramebufferRenderbuffer"u8); + contextPtr->glNamedFramebufferTexture = (delegate*)load( + "glNamedFramebufferTexture"u8); + contextPtr->glNamedFramebufferTextureLayer = (delegate*)load( + "glNamedFramebufferTextureLayer"u8); + contextPtr->glNamedRenderbufferStorage = (delegate*)load( + "glNamedRenderbufferStorage"u8); + contextPtr->glNamedRenderbufferStorageMultisample = (delegate*)load( + "glNamedRenderbufferStorageMultisample"u8); + contextPtr->glReadnPixels = (delegate*)load( + "glReadnPixels"u8); + contextPtr->glTextureBarrier = (delegate*)load("glTextureBarrier"u8); + contextPtr->glTextureBuffer = (delegate*)load( + "glTextureBuffer"u8); + contextPtr->glTextureBufferRange = (delegate*)load( + "glTextureBufferRange"u8); + contextPtr->glTextureParameterIiv = (delegate*)load( + "glTextureParameterIiv"u8); + contextPtr->glTextureParameterIuiv = (delegate*)load( + "glTextureParameterIuiv"u8); + contextPtr->glTextureParameterf = (delegate*)load( + "glTextureParameterf"u8); + contextPtr->glTextureParameterfv = (delegate*)load( + "glTextureParameterfv"u8); + contextPtr->glTextureParameteri = (delegate*)load( + "glTextureParameteri"u8); + contextPtr->glTextureParameteriv = (delegate*)load( + "glTextureParameteriv"u8); + contextPtr->glTextureStorage1D = (delegate*)load( + "glTextureStorage1D"u8); + contextPtr->glTextureStorage2D = (delegate*)load( + "glTextureStorage2D"u8); + contextPtr->glTextureStorage2DMultisample = (delegate*)load( + "glTextureStorage2DMultisample"u8); + contextPtr->glTextureStorage3D = (delegate*)load( + "glTextureStorage3D"u8); + contextPtr->glTextureStorage3DMultisample = (delegate*)load( + "glTextureStorage3DMultisample"u8); + contextPtr->glTextureSubImage1D = (delegate*)load( + "glTextureSubImage1D"u8); + contextPtr->glTextureSubImage2D = (delegate*)load( + "glTextureSubImage2D"u8); + contextPtr->glTextureSubImage3D = (delegate*)load( + "glTextureSubImage3D"u8); + contextPtr->glTransformFeedbackBufferBase = (delegate*)load( + "glTransformFeedbackBufferBase"u8); + contextPtr->glTransformFeedbackBufferRange = (delegate*)load( + "glTransformFeedbackBufferRange"u8); + contextPtr->glUnmapNamedBuffer = (delegate*)load("glUnmapNamedBuffer"u8); + contextPtr->glVertexArrayAttribBinding = (delegate*)load( + "glVertexArrayAttribBinding"u8); + contextPtr->glVertexArrayAttribFormat = (delegate*)load( + "glVertexArrayAttribFormat"u8); + contextPtr->glVertexArrayAttribIFormat = (delegate*)load( + "glVertexArrayAttribIFormat"u8); + contextPtr->glVertexArrayAttribLFormat = (delegate*)load( + "glVertexArrayAttribLFormat"u8); + contextPtr->glVertexArrayBindingDivisor = (delegate*)load( + "glVertexArrayBindingDivisor"u8); + contextPtr->glVertexArrayElementBuffer = (delegate*)load( + "glVertexArrayElementBuffer"u8); + contextPtr->glVertexArrayVertexBuffer = (delegate*)load( + "glVertexArrayVertexBuffer"u8); + contextPtr->glVertexArrayVertexBuffers = (delegate*)load( + "glVertexArrayVertexBuffers"u8); + + #endregion load + + DefaultLog.InternalAppendLog("Successfully load all OpenGL 4.5 APIs"); + return true; + } + + internal static unsafe bool LoadGLcore46(OpenglContext* contextPtr, delegate*, IntPtr> load) + { + if (!core46) + { + DefaultLog.InternalAppendLog("The core version 4.6 is not supported."); + return false; + } + + #region load + + contextPtr->glMultiDrawArraysIndirectCount = (delegate*)load( + "glMultiDrawArraysIndirectCount"u8); + contextPtr->glMultiDrawElementsIndirectCount = (delegate*)load( + "glMultiDrawElementsIndirectCount"u8); + contextPtr->glPolygonOffsetClamp = (delegate*)load( + "glPolygonOffsetClamp"u8); + contextPtr->glSpecializeShader = (delegate*)load( + "glSpecializeShader"u8); + + #endregion load + + DefaultLog.InternalAppendLog("Successfully load all OpenGL 4.6 APIs"); + return true; + } + + } +} diff --git a/StgSharp.Common/Graphics/OpenGL/glApiManager.cs b/StgSharp.Common/Graphics/OpenGL/glApiManager.cs index f1c3aeb9..c41d44e8 100644 --- a/StgSharp.Common/Graphics/OpenGL/glApiManager.cs +++ b/StgSharp.Common/Graphics/OpenGL/glApiManager.cs @@ -67,10 +67,10 @@ namespace StgSharp.Graphics.OpenGL /// public static IntPtr LoadGLfunc(string name) { - IntPtr ret = InternalIO.glfwGetProcAddress(Encoding.UTF8.GetBytes(name)); + IntPtr ret = GraphicFramework.glfwGetProcAddress(Encoding.UTF8.GetBytes(name)); if (ret == default) { - InternalIO.InternalAppendLog( + DefaultLog.InternalAppendLog( $"Cannot load OpenGL api called {name}, this api may not exist or supported."); return ret; } @@ -89,8 +89,8 @@ namespace StgSharp.Graphics.OpenGL if ((IntPtr)context->glGetString != IntPtr.Zero) { return; } - delegate* loader = &InternalIO.glfwGetProcAddress; - IntPtr proc = InternalIO.glfwGetProcAddress("glGetString"); + delegate*, IntPtr> loader = &GraphicFramework.glfwGetProcAddress; + IntPtr proc = GraphicFramework.glfwGetProcAddress("glGetString"u8); if (proc == IntPtr.Zero) { #if DEBUG @@ -102,7 +102,7 @@ namespace StgSharp.Graphics.OpenGL string coreVersion; if (context->glGetString(glVersion) == IntPtr.Zero) { - InternalIO.InternalWriteLog("Failed to call glGetString", LogType.Error); + DefaultLog.InternalWriteLog("Failed to call glGetString", LogType.Error); } coreVersion = Marshal.PtrToStringAnsi(context->glGetString(glVersion)) ?? string.Empty; @@ -117,38 +117,26 @@ namespace StgSharp.Graphics.OpenGL int minorVersion = int.Parse(versionSep[1]); CheckCoreVersion(majorVersion, minorVersion); - try - { - #region load_core_gl - LoadGLcore10(context, loader); - LoadGLcore11(context, loader); - LoadGLcore12(context, loader); - LoadGLcore13(context, loader); - LoadGLcore14(context, loader); - LoadGLcore15(context, loader); - LoadGLcore20(context, loader); - LoadGLcore21(context, loader); - LoadGLcore30(context, loader); - LoadGLcore31(context, loader); - LoadGLcore32(context, loader); - LoadGLcore33(context, loader); - LoadGLcore40(context, loader); - LoadGLcore41(context, loader); - LoadGLcore42(context, loader); - LoadGLcore43(context, loader); - LoadGLcore44(context, loader); - LoadGLcore45(context, loader); - LoadGLcore46(context, loader); - - #endregion load_core_gl - } - catch (Exception ex) - { - if (ex.Message != "Final Version") { - throw; - } - } + if (LoadGLcore10(context, loader) && + LoadGLcore11(context, loader) && + LoadGLcore12(context, loader) && + LoadGLcore13(context, loader) && + LoadGLcore14(context, loader) && + LoadGLcore15(context, loader) && + LoadGLcore20(context, loader) && + LoadGLcore21(context, loader) && + LoadGLcore30(context, loader) && + LoadGLcore31(context, loader) && + LoadGLcore32(context, loader) && + LoadGLcore33(context, loader) && + LoadGLcore40(context, loader) && + LoadGLcore41(context, loader) && + LoadGLcore42(context, loader) && + LoadGLcore43(context, loader) && + LoadGLcore44(context, loader) && + LoadGLcore45(context, loader) && + LoadGLcore46(context, loader)) { } uint code = context->glGetError(); if (code != 0) @@ -161,7 +149,7 @@ namespace StgSharp.Graphics.OpenGL context->glGetIntegerv(glConst.NUM_EXTENSIONS, &extensionCount); if (extensionCount == 0) { - InternalIO.InternalWriteLog( + DefaultLog.InternalWriteLog( "No supported OpenGL extensions are found.", LogType.Info); return; } @@ -174,7 +162,7 @@ namespace StgSharp.Graphics.OpenGL extensions.Add(Marshal.PtrToStringAnsi((IntPtr)strPtr) ?? string.Empty); } - InternalIO.InternalWriteLog( + DefaultLog.InternalWriteLog( $"{$"Find OpenGL extensions:"}{Environment.NewLine}{string.Join(';', extensions)}", LogType.Info); @@ -3440,7 +3428,7 @@ namespace StgSharp.Graphics.OpenGL log: { - InternalIO.InternalWriteLog("Find core OpenGL version.", LogType.Info); + DefaultLog.InternalWriteLog("Find core OpenGL version.", LogType.Info); return; } } @@ -3450,7 +3438,7 @@ namespace StgSharp.Graphics.OpenGL if (context.glGetString == null) { return string.Empty; } - return Marshal.PtrToStringAnsi(context.glGetString(glExtension)); + return Marshal.PtrToStringAnsi(context.glGetString(glExtension))!; } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -3466,1508 +3454,12 @@ namespace StgSharp.Graphics.OpenGL } catch (Exception ex) { - InternalIO.InternalWriteLog( + DefaultLog.InternalWriteLog( $"{$"Failed to convert the api {typeof(T).Name}.\n"}{ex.Message}", LogType.Warning); return default; } } - internal static unsafe void LoadGLcore10(OpenglContext* contextPtr, delegate* load) - { - if (!core10) - { - InternalIO.InternalAppendLog("The core version 1.0 is not supported."); - throw new Exception("Final Version"); - } - - #region load - - contextPtr->glBlendFunc = (delegate*)load("glBlendFunc"); - contextPtr->glClear = (delegate*)load("glClear"); - contextPtr->glClearColor = (delegate*)load( - "glClearColor"); - contextPtr->glClearDepth = (delegate*)load("glClearDepth"); - contextPtr->glClearStencil = (delegate*)load("glClearStencil"); - contextPtr->glColorMask = (delegate*)load( - "glColorMask"); - contextPtr->glCullFace = (delegate*)load("glCullFace"); - contextPtr->glDepthFunc = (delegate*)load("glDepthFunc"); - contextPtr->glDepthMask = (delegate*)load("glDepthMask"); - contextPtr->glDepthRange = (delegate*)load("glDepthRange"); - contextPtr->glDisable = (delegate*)load("glDisable"); - contextPtr->glDrawBuffer = (delegate*)load("glDrawBuffer"); - contextPtr->glEnable = (delegate*)load("glEnable"); - contextPtr->glFinish = (delegate*)load("glFinish"); - contextPtr->glFlush = (delegate*)load("glFlush"); - contextPtr->glFrontFace = (delegate*)load("glFrontFace"); - contextPtr->glGetBooleanv = (delegate*)load("glGetBooleanv"); - contextPtr->glGetDoublev = (delegate*)load("glGetDoublev"); - contextPtr->glGetError = (delegate*)load("glGetError"); - contextPtr->glGetFloatv = (delegate*)load("glGetFloatv"); - contextPtr->glGetIntegerv = (delegate*)load("glGetIntegerv"); - contextPtr->glGetString = (delegate*)load("glGetString"); - contextPtr->glGetTexImage = (delegate*)load( - "glGetTexImage"); - contextPtr->glGetTexLevelParameterfv = (delegate*)load( - "glGetTexLevelParameterfv"); - contextPtr->glGetTexLevelParameteriv = (delegate*)load( - "glGetTexLevelParameteriv"); - contextPtr->glGetTexParameterfv = (delegate*)load( - "glGetTexParameterfv"); - contextPtr->glGetTexParameteriv = (delegate*)load( - "glGetTexParameteriv"); - contextPtr->glHint = (delegate*)load("glHint"); - contextPtr->glIsEnabled = (delegate*)load("glIsEnabled"); - contextPtr->glLineWidth = (delegate*)load("glLineWidth"); - contextPtr->glLogicOp = (delegate*)load("glLogicOp"); - contextPtr->glPixelStoref = (delegate*)load("glPixelStoref"); - contextPtr->glPixelStorei = (delegate*)load("glPixelStorei"); - contextPtr->glPointSize = (delegate*)load("glPointSize"); - contextPtr->glPolygonMode = (delegate*)load("glPolygonMode"); - contextPtr->glReadBuffer = (delegate*)load("glReadBuffer"); - contextPtr->glReadPixels = (delegate*)load( - "glReadPixels"); - contextPtr->glScissor = (delegate*)load("glScissor"); - contextPtr->glStencilFunc = (delegate*)load("glStencilFunc"); - contextPtr->glStencilMask = (delegate*)load("glStencilMask"); - contextPtr->glStencilOp = (delegate*)load("glStencilOp"); - contextPtr->glTexImage1D = (delegate*)load( - "glTexImage1D"); - contextPtr->glTexImage2D = (delegate*)load( - "glTexImage2D"); - contextPtr->glTexParameterf = (delegate*)load( - "glTexParameterf"); - contextPtr->glTexParameterfv = (delegate*)load( - "glTexParameterfv"); - contextPtr->glTexParameteri = (delegate*)load( - "glTexParameteri"); - contextPtr->glTexParameteriv = (delegate*)load( - "glTexParameteriv"); - contextPtr->glViewport = (delegate*)load("glViewport"); - - #endregion load - - InternalIO.InternalAppendLog("Successfully load all OpenGL 1.0 APIs"); - } - - internal static unsafe void LoadGLcore11(OpenglContext* contextPtr, delegate* load) - { - if (!core11) - { - InternalIO.InternalAppendLog("The core version 1.1 is not supported."); - throw new Exception("Final Version"); - } - - #region load - - contextPtr->glBindTexture = (delegate*)load("glBindTexture"); - contextPtr->glCopyTexImage1D = (delegate*)load( - "glCopyTexImage1D"); - contextPtr->glCopyTexImage2D = (delegate*)load( - "glCopyTexImage2D"); - contextPtr->glCopyTexSubImage1D = (delegate*)load( - "glCopyTexSubImage1D"); - contextPtr->glCopyTexSubImage2D = (delegate*)load( - "glCopyTexSubImage2D"); - contextPtr->glDeleteTextures = (delegate*)load( - "glDeleteTextures"); - contextPtr->glDrawArrays = (delegate*)load("glDrawArrays"); - contextPtr->glDrawElements = (delegate*)load( - "glDrawElements"); - contextPtr->glGenTextures = (delegate*)load("glGenTextures"); - contextPtr->glGetPointerv = (delegate*)load("glGetPointerv"); - contextPtr->glIsTexture = (delegate*)load("glIsTexture"); - contextPtr->glPolygonOffset = (delegate*)load("glPolygonOffset"); - contextPtr->glTexSubImage1D = (delegate*)load( - "glTexSubImage1D"); - contextPtr->glTexSubImage2D = (delegate*)load( - "glTexSubImage2D"); - - #endregion load - - InternalIO.InternalAppendLog("Successfully load all OpenGL 1.1 APIs"); - } - - internal static unsafe void LoadGLcore12(OpenglContext* contextPtr, delegate* load) - { - if (!core12) - { - InternalIO.InternalAppendLog("The core version 1.2 is not supported."); - throw new Exception("Final Version"); - } - - #region load - - contextPtr->glCopyTexSubImage3D = (delegate*)load( - "glCopyTexSubImage3D"); - contextPtr->glDrawRangeElements = (delegate*)load( - "glDrawRangeElements"); - contextPtr->glTexImage3D = (delegate*)load( - "glTexImage3D"); - contextPtr->glTexSubImage3D = (delegate*)load( - "glTexSubImage3D"); - - #endregion load - - InternalIO.InternalAppendLog("Successfully load all OpenGL 1.2 APIs"); - } - - internal static unsafe void LoadGLcore13(OpenglContext* contextPtr, delegate* load) - { - if (!core13) - { - InternalIO.InternalAppendLog("The core version 1.3 is not supported."); - throw new Exception("Final Version"); - } - - #region load - - contextPtr->glActiveTexture = (delegate*)load("glActiveTexture"); - contextPtr->glCompressedTexImage1D = (delegate*)load( - "glCompressedTexImage1D"); - contextPtr->glCompressedTexImage2D = (delegate*)load( - "glCompressedTexImage2D"); - contextPtr->glCompressedTexImage3D = (delegate*)load( - "glCompressedTexImage3D"); - contextPtr->glCompressedTexSubImage1D = (delegate*)load( - "glCompressedTexSubImage1D"); - contextPtr->glCompressedTexSubImage2D = (delegate*)load( - "glCompressedTexSubImage2D"); - contextPtr->glCompressedTexSubImage3D = (delegate*)load( - "glCompressedTexSubImage3D"); - contextPtr->glGetCompressedTexImage = (delegate*)load( - "glGetCompressedTexImage"); - contextPtr->glSampleCoverage = (delegate*)load( - "glSampleCoverage"); - - #endregion load - - InternalIO.InternalAppendLog("Successfully load all OpenGL 1.3 APIs"); - } - - internal static unsafe void LoadGLcore14(OpenglContext* contextPtr, delegate* load) - { - if (!core14) - { - InternalIO.InternalAppendLog("The core version 1.4 is not supported."); - throw new Exception("Final Version"); - } - - #region load - - contextPtr->glBlendColor = (delegate*)load( - "glBlendColor"); - contextPtr->glBlendEquation = (delegate*)load("glBlendEquation"); - contextPtr->glBlendFuncSeparate = (delegate*)load( - "glBlendFuncSeparate"); - contextPtr->glMultiDrawArrays = (delegate*)load( - "glMultiDrawArrays"); - contextPtr->glMultiDrawElements = (delegate*)load( - "glMultiDrawElements"); - contextPtr->glPointParameterf = (delegate*)load( - "glPointParameterf"); - contextPtr->glPointParameterfv = (delegate*)load( - "glPointParameterfv"); - contextPtr->glPointParameteri = (delegate*)load( - "glPointParameteri"); - contextPtr->glPointParameteriv = (delegate*)load( - "glPointParameteriv"); - - #endregion load - - InternalIO.InternalAppendLog("Successfully load all OpenGL 1.4 APIs"); - } - - internal static unsafe void LoadGLcore15(OpenglContext* contextPtr, delegate* load) - { - if (!core15) - { - InternalIO.InternalAppendLog("The core version 1.5 is not supported."); - throw new Exception("Final Version"); - } - - #region load - - contextPtr->glBeginQuery = (delegate*)load("glBeginQuery"); - contextPtr->glBindBuffer = (delegate*)load("glBindBuffer"); - contextPtr->glBufferData = (delegate*)load( - "glBufferData"); - contextPtr->glBufferSubData = (delegate*)load( - "glBufferSubData"); - contextPtr->glDeleteBuffers = (delegate*)load("glDeleteBuffers"); - contextPtr->glDeleteQueries = (delegate*)load("glDeleteQueries"); - contextPtr->glEndQuery = (delegate*)load("glEndQuery"); - contextPtr->glGenBuffers = (delegate*)load("glGenBuffers"); - contextPtr->glGenQueries = (delegate*)load("glGenQueries"); - contextPtr->glGetBufferParameteriv = (delegate*)load( - "glGetBufferParameteriv"); - contextPtr->glGetBufferPointerv = (delegate*)load( - "glGetBufferPointerv"); - contextPtr->glGetBufferSubData = (delegate*)load( - "glGetBufferSubData"); - contextPtr->glGetQueryObjectiv = (delegate*)load( - "glGetQueryObjectiv"); - contextPtr->glGetQueryObjectuiv = (delegate*)load( - "glGetQueryObjectuiv"); - contextPtr->glGetQueryiv = (delegate*)load("glGetQueryiv"); - contextPtr->glIsBuffer = (delegate*)load("glIsBuffer"); - contextPtr->glIsQuery = (delegate*)load("glIsQuery"); - contextPtr->glMapBuffer = (delegate*)load("glMapBuffer"); - contextPtr->glUnmapBuffer = (delegate*)load("glUnmapBuffer"); - - #endregion load - - InternalIO.InternalAppendLog("Successfully load all OpenGL 1.5 APIs"); - } - - internal static unsafe void LoadGLcore20(OpenglContext* contextPtr, delegate* load) - { - if (!core20) - { - InternalIO.InternalAppendLog("The core version 2.0 is not supported."); - throw new Exception("Final Version"); - } - - #region load - - contextPtr->glAttachShader = (delegate*)load("glAttachShader"); - contextPtr->glBindAttribLocation = (delegate*)load( - "glBindAttribLocation"); - contextPtr->glBlendEquationSeparate = (delegate*)load( - "glBlendEquationSeparate"); - contextPtr->glCompileShader = (delegate*)load("glCompileShader"); - contextPtr->glCreateProgram = (delegate*)load("glCreateProgram"); - contextPtr->glCreateShader = (delegate*)load("glCreateShader"); - contextPtr->glDeleteProgram = (delegate*)load("glDeleteProgram"); - contextPtr->glDeleteShader = (delegate*)load("glDeleteShader"); - contextPtr->glDetachShader = (delegate*)load("glDetachShader"); - contextPtr->glDisableVertexAttribArray = (delegate*)load( - "glDisableVertexAttribArray"); - contextPtr->glDrawBuffers = (delegate*)load("glDrawBuffers"); - contextPtr->glEnableVertexAttribArray = (delegate*)load( - "glEnableVertexAttribArray"); - contextPtr->glGetActiveAttrib = (delegate*)load( - "glGetActiveAttrib"); - contextPtr->glGetActiveUniform = (delegate*)load( - "glGetActiveUniform"); - contextPtr->glGetAttachedShaders = (delegate*)load( - "glGetAttachedShaders"); - contextPtr->glGetAttribLocation = (delegate*)load( - "glGetAttribLocation"); - contextPtr->glGetProgramInfoLog = (delegate*)load( - "glGetProgramInfoLog"); - contextPtr->glGetProgramiv = (delegate*)load( - "glGetProgramiv"); - contextPtr->glGetShaderInfoLog = (delegate*)load( - "glGetShaderInfoLog"); - contextPtr->glGetShaderSource = (delegate*)load( - "glGetShaderSource"); - contextPtr->glGetShaderiv = (delegate*)load("glGetShaderiv"); - contextPtr->glGetUniformLocation = (delegate*)load( - "glGetUniformLocation"); - contextPtr->glGetUniformfv = (delegate*)load( - "glGetUniformfv"); - contextPtr->glGetUniformiv = (delegate*)load( - "glGetUniformiv"); - contextPtr->glGetVertexAttribPointerv = (delegate*)load( - "glGetVertexAttribPointerv"); - contextPtr->glGetVertexAttribdv = (delegate*)load( - "glGetVertexAttribdv"); - contextPtr->glGetVertexAttribfv = (delegate*)load( - "glGetVertexAttribfv"); - contextPtr->glGetVertexAttribiv = (delegate*)load( - "glGetVertexAttribiv"); - contextPtr->glIsProgram = (delegate*)load("glIsProgram"); - contextPtr->glIsShader = (delegate*)load("glIsShader"); - contextPtr->glLinkProgram = (delegate*)load("glLinkProgram"); - contextPtr->glShaderSource = (delegate* unmanaged[Stdcall])load( - "glShaderSource"); - contextPtr->glStencilFuncSeparate = (delegate*)load( - "glStencilFuncSeparate"); - contextPtr->glStencilMaskSeparate = (delegate*)load( - "glStencilMaskSeparate"); - contextPtr->glStencilOpSeparate = (delegate*)load( - "glStencilOpSeparate"); - contextPtr->glUniform1f = (delegate*)load("glUniform1f"); - contextPtr->glUniform1fv = (delegate*)load("glUniform1fv"); - contextPtr->glUniform1i = (delegate*)load("glUniform1i"); - contextPtr->glUniform1iv = (delegate*)load("glUniform1iv"); - contextPtr->glUniform2f = (delegate*)load("glUniform2f"); - contextPtr->glUniform2fv = (delegate*)load("glUniform2fv"); - contextPtr->glUniform2i = (delegate*)load("glUniform2i"); - contextPtr->glUniform2iv = (delegate*)load("glUniform2iv"); - contextPtr->glUniform3f = (delegate*)load( - "glUniform3f"); - contextPtr->glUniform3fv = (delegate*)load("glUniform3fv"); - contextPtr->glUniform3i = (delegate*)load("glUniform3i"); - contextPtr->glUniform3iv = (delegate*)load("glUniform3iv"); - contextPtr->glUniform4f = (delegate*)load( - "glUniform4f"); - contextPtr->glUniform4fv = (delegate*)load("glUniform4fv"); - contextPtr->glUniform4i = (delegate*)load( - "glUniform4i"); - contextPtr->glUniform4iv = (delegate*)load("glUniform4iv"); - contextPtr->glUniformMatrix2fv = (delegate*)load( - "glUniformMatrix2fv"); - contextPtr->glUniformMatrix3fv = (delegate*)load( - "glUniformMatrix3fv"); - contextPtr->glUniformMatrix4fv = (delegate*)load( - "glUniformMatrix4fv"); - contextPtr->glUseProgram = (delegate*)load("glUseProgram"); - contextPtr->glValidateProgram = (delegate*)load("glValidateProgram"); - contextPtr->glVertexAttrib1d = (delegate*)load( - "glVertexAttrib1d"); - contextPtr->glVertexAttrib1dv = (delegate*)load( - "glVertexAttrib1dv"); - contextPtr->glVertexAttrib1f = (delegate*)load( - "glVertexAttrib1f"); - contextPtr->glVertexAttrib1fv = (delegate*)load( - "glVertexAttrib1fv"); - contextPtr->glVertexAttrib1s = (delegate*)load( - "glVertexAttrib1s"); - contextPtr->glVertexAttrib1sv = (delegate*)load( - "glVertexAttrib1sv"); - contextPtr->glVertexAttrib2d = (delegate*)load( - "glVertexAttrib2d"); - contextPtr->glVertexAttrib2dv = (delegate*)load( - "glVertexAttrib2dv"); - contextPtr->glVertexAttrib2f = (delegate*)load( - "glVertexAttrib2f"); - contextPtr->glVertexAttrib2fv = (delegate*)load( - "glVertexAttrib2fv"); - contextPtr->glVertexAttrib2s = (delegate*)load( - "glVertexAttrib2s"); - contextPtr->glVertexAttrib2sv = (delegate*)load( - "glVertexAttrib2sv"); - contextPtr->glVertexAttrib3d = (delegate*)load( - "glVertexAttrib3d"); - contextPtr->glVertexAttrib3dv = (delegate*)load( - "glVertexAttrib3dv"); - contextPtr->glVertexAttrib3f = (delegate*)load( - "glVertexAttrib3f"); - contextPtr->glVertexAttrib3fv = (delegate*)load( - "glVertexAttrib3fv"); - contextPtr->glVertexAttrib3s = (delegate*)load( - "glVertexAttrib3s"); - contextPtr->glVertexAttrib3sv = (delegate*)load( - "glVertexAttrib3sv"); - contextPtr->glVertexAttrib4Nbv = (delegate*)load( - "glVertexAttrib4Nbv"); - contextPtr->glVertexAttrib4Niv = (delegate*)load( - "glVertexAttrib4Niv"); - contextPtr->glVertexAttrib4Nsv = (delegate*)load( - "glVertexAttrib4Nsv"); - contextPtr->glVertexAttrib4Nub = (delegate*)load( - "glVertexAttrib4Nub"); - contextPtr->glVertexAttrib4Nubv = (delegate*)load( - "glVertexAttrib4Nubv"); - contextPtr->glVertexAttrib4Nuiv = (delegate*)load( - "glVertexAttrib4Nuiv"); - contextPtr->glVertexAttrib4Nusv = (delegate*)load( - "glVertexAttrib4Nusv"); - contextPtr->glVertexAttrib4bv = (delegate*)load( - "glVertexAttrib4bv"); - contextPtr->glVertexAttrib4d = (delegate*)load( - "glVertexAttrib4d"); - contextPtr->glVertexAttrib4dv = (delegate*)load( - "glVertexAttrib4dv"); - contextPtr->glVertexAttrib4f = (delegate*)load( - "glVertexAttrib4f"); - contextPtr->glVertexAttrib4fv = (delegate*)load( - "glVertexAttrib4fv"); - contextPtr->glVertexAttrib4iv = (delegate*)load( - "glVertexAttrib4iv"); - contextPtr->glVertexAttrib4s = (delegate*)load( - "glVertexAttrib4s"); - contextPtr->glVertexAttrib4sv = (delegate*)load( - "glVertexAttrib4sv"); - contextPtr->glVertexAttrib4ubv = (delegate*)load( - "glVertexAttrib4ubv"); - contextPtr->glVertexAttrib4uiv = (delegate*)load( - "glVertexAttrib4uiv"); - contextPtr->glVertexAttrib4usv = (delegate*)load( - "glVertexAttrib4usv"); - contextPtr->glVertexAttribPointer = (delegate*)load( - "glVertexAttribPointer"); - - #endregion load - - InternalIO.InternalAppendLog("Successfully load all OpenGL 2.0 APIs"); - } - - internal static unsafe void LoadGLcore21(OpenglContext* contextPtr, delegate* load) - { - if (!core21) - { - InternalIO.InternalAppendLog("The core version 2.1 is not supported."); - throw new Exception("Final Version"); - } - - #region load - - contextPtr->glUniformMatrix2x3fv = (delegate*)load( - "glUniformMatrix2x3fv"); - contextPtr->glUniformMatrix2x4fv = (delegate*)load( - "glUniformMatrix2x4fv"); - contextPtr->glUniformMatrix3x2fv = (delegate*)load( - "glUniformMatrix3x2fv"); - contextPtr->glUniformMatrix3x4fv = (delegate*)load( - "glUniformMatrix3x4fv"); - contextPtr->glUniformMatrix4x2fv = (delegate*)load( - "glUniformMatrix4x2fv"); - contextPtr->glUniformMatrix4x3fv = (delegate*)load( - "glUniformMatrix4x3fv"); - - #endregion load - - InternalIO.InternalAppendLog("Successfully load all OpenGL 2.1 APIs"); - } - - internal static unsafe void LoadGLcore30(OpenglContext* contextPtr, delegate* load) - { - if (!core30) - { - InternalIO.InternalAppendLog("The core version 3.0 is not supported."); - throw new Exception("Final Version"); - } - - #region load - - contextPtr->glBeginConditionalRender = (delegate*)load( - "glBeginConditionalRender"); - contextPtr->glBeginTransformFeedback = (delegate*)load( - "glBeginTransformFeedback"); - contextPtr->glBindBufferBase = (delegate*)load( - "glBindBufferBase"); - contextPtr->glBindBufferRange = (delegate*)load( - "glBindBufferRange"); - contextPtr->glBindFragDataLocation = (delegate*)load( - "glBindFragDataLocation"); - contextPtr->glBindFramebuffer = (delegate*)load( - "glBindFramebuffer"); - contextPtr->glBindRenderbuffer = (delegate*)load( - "glBindRenderbuffer"); - contextPtr->glBindVertexArray = (delegate*)load("glBindVertexArray"); - contextPtr->glBlitFramebuffer = (delegate*)load( - "glBlitFramebuffer"); - contextPtr->glCheckFramebufferStatus = (delegate*)load( - "glCheckFramebufferStatus"); - contextPtr->glClampColor = (delegate*)load("glClampColor"); - contextPtr->glClearBufferfi = (delegate*)load( - "glClearBufferfi"); - contextPtr->glClearBufferfv = (delegate*)load( - "glClearBufferfv"); - contextPtr->glClearBufferiv = (delegate*)load( - "glClearBufferiv"); - contextPtr->glClearBufferuiv = (delegate*)load( - "glClearBufferuiv"); - contextPtr->glColorMaski = (delegate*)load( - "glColorMaski"); - contextPtr->glDeleteFramebuffers = (delegate*)load( - "glDeleteFramebuffers"); - contextPtr->glDeleteRenderbuffers = (delegate*)load( - "glDeleteRenderbuffers"); - contextPtr->glDeleteVertexArrays = (delegate*)load( - "glDeleteVertexArrays"); - contextPtr->glDisablei = (delegate*)load("glDisablei"); - contextPtr->glEnablei = (delegate*)load("glEnablei"); - contextPtr->glEndConditionalRender = (delegate*)load("glEndConditionalRender"); - contextPtr->glEndTransformFeedback = (delegate*)load("glEndTransformFeedback"); - contextPtr->glFlushMappedBufferRange = (delegate*)load( - "glFlushMappedBufferRange"); - contextPtr->glFramebufferRenderbuffer = (delegate*)load( - "glFramebufferRenderbuffer"); - contextPtr->glFramebufferTexture1D = (delegate*)load( - "glFramebufferTexture1D"); - contextPtr->glFramebufferTexture2D = (delegate*)load( - "glFramebufferTexture2D"); - contextPtr->glFramebufferTexture3D = (delegate*)load( - "glFramebufferTexture3D"); - contextPtr->glFramebufferTextureLayer = (delegate*)load( - "glFramebufferTextureLayer"); - contextPtr->glGenFramebuffers = (delegate*)load( - "glGenFramebuffers"); - contextPtr->glGenRenderbuffers = (delegate*)load( - "glGenRenderbuffers"); - contextPtr->glGenVertexArrays = (delegate*)load( - "glGenVertexArrays"); - contextPtr->glGenerateMipmap = (delegate*)load("glGenerateMipmap"); - contextPtr->glGetBooleani_v = (delegate*)load( - "glGetBooleani_v"); - contextPtr->glGetFragDataLocation = (delegate*)load( - "glGetFragDataLocation"); - contextPtr->glGetFramebufferAttachmentParameteriv = (delegate*)load( - "glGetFramebufferAttachmentParameteriv"); - contextPtr->glGetIntegeri_v = (delegate*)load( - "glGetIntegeri_v"); - contextPtr->glGetRenderbufferParameteriv = (delegate*)load( - "glGetRenderbufferParameteriv"); - contextPtr->glGetStringi = (delegate*)load("glGetStringi"); - contextPtr->glGetTexParameterIiv = (delegate*)load( - "glGetTexParameterIiv"); - contextPtr->glGetTexParameterIuiv = (delegate*)load( - "glGetTexParameterIuiv"); - contextPtr->glGetTransformFeedbackVarying = (delegate*)load( - "glGetTransformFeedbackVarying"); - contextPtr->glGetUniformuiv = (delegate*)load( - "glGetUniformuiv"); - contextPtr->glGetVertexAttribIiv = (delegate*)load( - "glGetVertexAttribIiv"); - contextPtr->glGetVertexAttribIuiv = (delegate*)load( - "glGetVertexAttribIuiv"); - contextPtr->glIsEnabledi = (delegate*)load("glIsEnabledi"); - contextPtr->glIsFramebuffer = (delegate*)load("glIsFramebuffer"); - contextPtr->glIsRenderbuffer = (delegate*)load("glIsRenderbuffer"); - contextPtr->glIsVertexArray = (delegate*)load("glIsVertexArray"); - contextPtr->glMapBufferRange = (delegate*)load( - "glMapBufferRange"); - contextPtr->glRenderbufferStorage = (delegate*)load( - "glRenderbufferStorage"); - contextPtr->glRenderbufferStorageMultisample = (delegate*)load( - "glRenderbufferStorageMultisample"); - contextPtr->glTexParameterIiv = (delegate*)load( - "glTexParameterIiv"); - contextPtr->glTexParameterIuiv = (delegate*)load( - "glTexParameterIuiv"); - contextPtr->glTransformFeedbackVaryings = (delegate*)load( - "glTransformFeedbackVaryings"); - contextPtr->glUniform1ui = (delegate*)load("glUniform1ui"); - contextPtr->glUniform1uiv = (delegate*)load("glUniform1uiv"); - contextPtr->glUniform2ui = (delegate*)load("glUniform2ui"); - contextPtr->glUniform2uiv = (delegate*)load("glUniform2uiv"); - contextPtr->glUniform3ui = (delegate*)load( - "glUniform3ui"); - contextPtr->glUniform3uiv = (delegate*)load("glUniform3uiv"); - contextPtr->glUniform4ui = (delegate*)load( - "glUniform4ui"); - contextPtr->glUniform4uiv = (delegate*)load("glUniform4uiv"); - contextPtr->glVertexAttribI1i = (delegate*)load( - "glVertexAttribI1i"); - contextPtr->glVertexAttribI1iv = (delegate*)load( - "glVertexAttribI1iv"); - contextPtr->glVertexAttribI1ui = (delegate*)load( - "glVertexAttribI1ui"); - contextPtr->glVertexAttribI1uiv = (delegate*)load( - "glVertexAttribI1uiv"); - contextPtr->glVertexAttribI2i = (delegate*)load( - "glVertexAttribI2i"); - contextPtr->glVertexAttribI2iv = (delegate*)load( - "glVertexAttribI2iv"); - contextPtr->glVertexAttribI2ui = (delegate*)load( - "glVertexAttribI2ui"); - contextPtr->glVertexAttribI2uiv = (delegate*)load( - "glVertexAttribI2uiv"); - contextPtr->glVertexAttribI3i = (delegate*)load( - "glVertexAttribI3i"); - contextPtr->glVertexAttribI3iv = (delegate*)load( - "glVertexAttribI3iv"); - contextPtr->glVertexAttribI3ui = (delegate*)load( - "glVertexAttribI3ui"); - contextPtr->glVertexAttribI3uiv = (delegate*)load( - "glVertexAttribI3uiv"); - contextPtr->glVertexAttribI4bv = (delegate*)load( - "glVertexAttribI4bv"); - contextPtr->glVertexAttribI4i = (delegate*)load( - "glVertexAttribI4i"); - contextPtr->glVertexAttribI4iv = (delegate*)load( - "glVertexAttribI4iv"); - contextPtr->glVertexAttribI4sv = (delegate*)load( - "glVertexAttribI4sv"); - contextPtr->glVertexAttribI4ubv = (delegate*)load( - "glVertexAttribI4ubv"); - contextPtr->glVertexAttribI4ui = (delegate*)load( - "glVertexAttribI4ui"); - contextPtr->glVertexAttribI4uiv = (delegate*)load( - "glVertexAttribI4uiv"); - contextPtr->glVertexAttribI4usv = (delegate*)load( - "glVertexAttribI4usv"); - contextPtr->glVertexAttribIPointer = (delegate*)load( - "glVertexAttribIPointer"); - - #endregion load - - InternalIO.InternalAppendLog("Successfully load all OpenGL 3.0 APIs"); - } - - internal static unsafe void LoadGLcore31(OpenglContext* contextPtr, delegate* load) - { - if (!core31) - { - InternalIO.InternalAppendLog("The core version 3.1 is not supported."); - throw new Exception("Final Version"); - } - - #region load - - contextPtr->glBindBufferBase = (delegate*)load( - "glBindBufferBase"); - contextPtr->glBindBufferRange = (delegate*)load( - "glBindBufferRange"); - contextPtr->glCopyBufferSubData = (delegate*)load( - "glCopyBufferSubData"); - contextPtr->glDrawArraysInstanced = (delegate*)load( - "glDrawArraysInstanced"); - contextPtr->glDrawElementsInstanced = (delegate*)load( - "glDrawElementsInstanced"); - contextPtr->glGetActiveUniformBlockName = (delegate*)load( - "glGetActiveUniformBlockName"); - contextPtr->glGetActiveUniformBlockiv = (delegate*)load( - "glGetActiveUniformBlockiv"); - contextPtr->glGetActiveUniformName = (delegate*)load( - "glGetActiveUniformName"); - contextPtr->glGetActiveUniformsiv = (delegate*)load( - "glGetActiveUniformsiv"); - contextPtr->glGetIntegeri_v = (delegate*)load( - "glGetIntegeri_v"); - contextPtr->glGetUniformBlockIndex = (delegate*)load( - "glGetUniformBlockIndex"); - contextPtr->glGetUniformIndices = (delegate*)load( - "glGetUniformIndices"); - contextPtr->glPrimitiveRestartIndex = (delegate*)load( - "glPrimitiveRestartIndex"); - contextPtr->glTexBuffer = (delegate*)load("glTexBuffer"); - contextPtr->glUniformBlockBinding = (delegate*)load( - "glUniformBlockBinding"); - - #endregion load - - InternalIO.InternalAppendLog("Successfully load all OpenGL 3.1 APIs"); - } - - internal static unsafe void LoadGLcore32(OpenglContext* contextPtr, delegate* load) - { - if (!core32) - { - InternalIO.InternalAppendLog("The core version 3.2 is not supported."); - throw new Exception("Final Version"); - } - - #region load - - contextPtr->glClientWaitSync = (delegate*)load( - "glClientWaitSync"); - contextPtr->glDeleteSync = (delegate*)load("glDeleteSync"); - contextPtr->glDrawElementsBaseVertex = (delegate*)load( - "glDrawElementsBaseVertex"); - contextPtr->glDrawElementsInstancedBaseVertex = (delegate*)load( - "glDrawElementsInstancedBaseVertex"); - contextPtr->glDrawRangeElementsBaseVertex = (delegate*)load( - "glDrawRangeElementsBaseVertex"); - contextPtr->glFenceSync = (delegate*)load("glFenceSync"); - contextPtr->glFramebufferTexture = (delegate*)load( - "glFramebufferTexture"); - contextPtr->glGetBufferParameteri64v = (delegate*)load( - "glGetBufferParameteri64v"); - contextPtr->glGetInteger64i_v = (delegate*)load( - "glGetInteger64i_v"); - contextPtr->glGetInteger64v = (delegate*)load("glGetInteger64v"); - contextPtr->glGetMultisamplefv = (delegate*)load( - "glGetMultisamplefv"); - contextPtr->glGetSynciv = (delegate*)load( - "glGetSynciv"); - contextPtr->glIsSync = (delegate*)load("glIsSync"); - contextPtr->glMultiDrawElementsBaseVertex = (delegate*)load( - "glMultiDrawElementsBaseVertex"); - contextPtr->glProvokingVertex = (delegate*)load("glProvokingVertex"); - contextPtr->glSampleMaski = (delegate*)load("glSampleMaski"); - contextPtr->glTexImage2DMultisample = (delegate*)load( - "glTexImage2DMultisample"); - contextPtr->glTexImage3DMultisample = (delegate*)load( - "glTexImage3DMultisample"); - contextPtr->glWaitSync = (delegate*)load("glWaitSync"); - - #endregion load - - InternalIO.InternalAppendLog("Successfully load all OpenGL 3.2 APIs"); - } - - internal static unsafe void LoadGLcore33(OpenglContext* contextPtr, delegate* load) - { - if (!core33) - { - InternalIO.InternalAppendLog("The core version 3.3 is not supported."); - throw new Exception("Final Version"); - } - - #region load - - contextPtr->glBindFragDataLocationIndexed = (delegate*)load( - "glBindFragDataLocationIndexed"); - contextPtr->glBindSampler = (delegate*)load("glBindSampler"); - contextPtr->glDeleteSamplers = (delegate*)load( - "glDeleteSamplers"); - contextPtr->glGenSamplers = (delegate*)load("glGenSamplers"); - contextPtr->glGetFragDataIndex = (delegate*)load( - "glGetFragDataIndex"); - contextPtr->glGetQueryObjecti64v = (delegate*)load( - "glGetQueryObjecti64v"); - contextPtr->glGetQueryObjectui64v = (delegate*)load( - "glGetQueryObjectui64v"); - contextPtr->glGetSamplerParameterIiv = (delegate*)load( - "glGetSamplerParameterIiv"); - contextPtr->glGetSamplerParameterIuiv = (delegate*)load( - "glGetSamplerParameterIuiv"); - contextPtr->glGetSamplerParameterfv = (delegate*)load( - "glGetSamplerParameterfv"); - contextPtr->glGetSamplerParameteriv = (delegate*)load( - "glGetSamplerParameteriv"); - contextPtr->glIsSampler = (delegate*)load("glIsSampler"); - contextPtr->glQueryCounter = (delegate*)load("glQueryCounter"); - contextPtr->glSamplerParameterIiv = (delegate*)load( - "glSamplerParameterIiv"); - contextPtr->glSamplerParameterIuiv = (delegate*)load( - "glSamplerParameterIuiv"); - contextPtr->glSamplerParameterf = (delegate*)load( - "glSamplerParameterf"); - contextPtr->glSamplerParameterfv = (delegate*)load( - "glSamplerParameterfv"); - contextPtr->glSamplerParameteri = (delegate*)load( - "glSamplerParameteri"); - contextPtr->glSamplerParameteriv = (delegate*)load( - "glSamplerParameteriv"); - contextPtr->glVertexAttribDivisor = (delegate*)load( - "glVertexAttribDivisor"); - contextPtr->glVertexAttribP1ui = (delegate*)load( - "glVertexAttribP1ui"); - contextPtr->glVertexAttribP1uiv = (delegate*)load( - "glVertexAttribP1uiv"); - contextPtr->glVertexAttribP2ui = (delegate*)load( - "glVertexAttribP2ui"); - contextPtr->glVertexAttribP2uiv = (delegate*)load( - "glVertexAttribP2uiv"); - contextPtr->glVertexAttribP3ui = (delegate*)load( - "glVertexAttribP3ui"); - contextPtr->glVertexAttribP3uiv = (delegate*)load( - "glVertexAttribP3uiv"); - contextPtr->glVertexAttribP4ui = (delegate*)load( - "glVertexAttribP4ui"); - contextPtr->glVertexAttribP4uiv = (delegate*)load( - "glVertexAttribP4uiv"); - - #endregion load - - InternalIO.InternalAppendLog("Successfully load all OpenGL 3.3 APIs"); - } - - internal static unsafe void LoadGLcore40(OpenglContext* contextPtr, delegate* load) - { - if (!core40) - { - InternalIO.InternalAppendLog("The core version 4.0 is not supported."); - throw new Exception("Final Version"); - } - - #region load - - contextPtr->glBeginQueryIndexed = (delegate*)load( - "glBeginQueryIndexed"); - contextPtr->glBindTransformFeedback = (delegate*)load( - "glBindTransformFeedback"); - contextPtr->glBlendEquationSeparatei = (delegate*)load( - "glBlendEquationSeparatei"); - contextPtr->glBlendEquationi = (delegate*)load("glBlendEquationi"); - contextPtr->glBlendFuncSeparatei = (delegate*)load( - "glBlendFuncSeparatei"); - contextPtr->glBlendFunci = (delegate*)load("glBlendFunci"); - contextPtr->glDeleteTransformFeedbacks = (delegate*)load( - "glDeleteTransformFeedbacks"); - contextPtr->glDrawArraysIndirect = (delegate*)load( - "glDrawArraysIndirect"); - contextPtr->glDrawElementsIndirect = (delegate*)load( - "glDrawElementsIndirect"); - contextPtr->glDrawTransformFeedback = (delegate*)load( - "glDrawTransformFeedback"); - contextPtr->glDrawTransformFeedbackStream = (delegate*)load( - "glDrawTransformFeedbackStream"); - contextPtr->glEndQueryIndexed = (delegate*)load( - "glEndQueryIndexed"); - contextPtr->glGenTransformFeedbacks = (delegate*)load( - "glGenTransformFeedbacks"); - contextPtr->glGetActiveSubroutineName = (delegate*)load( - "glGetActiveSubroutineName"); - contextPtr->glGetActiveSubroutineUniformName = (delegate*)load( - "glGetActiveSubroutineUniformName"); - contextPtr->glGetActiveSubroutineUniformiv = (delegate*)load( - "glGetActiveSubroutineUniformiv"); - contextPtr->glGetProgramStageiv = (delegate*)load( - "glGetProgramStageiv"); - contextPtr->glGetQueryIndexediv = (delegate*)load( - "glGetQueryIndexediv"); - contextPtr->glGetSubroutineIndex = (delegate*)load( - "glGetSubroutineIndex"); - contextPtr->glGetSubroutineUniformLocation = (delegate*)load( - "glGetSubroutineUniformLocation"); - contextPtr->glGetUniformSubroutineuiv = (delegate*)load( - "glGetUniformSubroutineuiv"); - contextPtr->glGetUniformdv = (delegate*)load( - "glGetUniformdv"); - contextPtr->glIsTransformFeedback = (delegate*)load( - "glIsTransformFeedback"); - contextPtr->glMinSampleShading = (delegate*)load("glMinSampleShading"); - contextPtr->glPatchParameterfv = (delegate*)load( - "glPatchParameterfv"); - contextPtr->glPatchParameteri = (delegate*)load( - "glPatchParameteri"); - contextPtr->glPauseTransformFeedback = (delegate*)load( - "glPauseTransformFeedback"); - contextPtr->glResumeTransformFeedback = (delegate*)load( - "glResumeTransformFeedback"); - contextPtr->glUniform1d = (delegate*)load("glUniform1d"); - contextPtr->glUniform1dv = (delegate*)load("glUniform1dv"); - contextPtr->glUniform2d = (delegate*)load("glUniform2d"); - contextPtr->glUniform2dv = (delegate*)load("glUniform2dv"); - contextPtr->glUniform3d = (delegate*)load( - "glUniform3d"); - contextPtr->glUniform3dv = (delegate*)load("glUniform3dv"); - contextPtr->glUniform4d = (delegate*)load( - "glUniform4d"); - contextPtr->glUniform4dv = (delegate*)load("glUniform4dv"); - contextPtr->glUniformMatrix2dv = (delegate*)load( - "glUniformMatrix2dv"); - contextPtr->glUniformMatrix2x3dv = (delegate*)load( - "glUniformMatrix2x3dv"); - contextPtr->glUniformMatrix2x4dv = (delegate*)load( - "glUniformMatrix2x4dv"); - contextPtr->glUniformMatrix3dv = (delegate*)load( - "glUniformMatrix3dv"); - contextPtr->glUniformMatrix3x2dv = (delegate*)load( - "glUniformMatrix3x2dv"); - contextPtr->glUniformMatrix3x4dv = (delegate*)load( - "glUniformMatrix3x4dv"); - contextPtr->glUniformMatrix4dv = (delegate*)load( - "glUniformMatrix4dv"); - contextPtr->glUniformMatrix4x2dv = (delegate*)load( - "glUniformMatrix4x2dv"); - contextPtr->glUniformMatrix4x3dv = (delegate*)load( - "glUniformMatrix4x3dv"); - contextPtr->glUniformSubroutinesuiv = (delegate*)load( - "glUniformSubroutinesuiv"); - - #endregion load - - InternalIO.InternalAppendLog("Successfully load all OpenGL 4.0 APIs"); - } - - internal static unsafe void LoadGLcore41(OpenglContext* contextPtr, delegate* load) - { - if (!core41) - { - InternalIO.InternalAppendLog("The core version 4.1 is not supported."); - throw new Exception("Final Version"); - } - - #region load - - contextPtr->glActiveShaderProgram = (delegate*)load( - "glActiveShaderProgram"); - contextPtr->glBindProgramPipeline = (delegate*)load( - "glBindProgramPipeline"); - contextPtr->glClearDepthf = (delegate*)load("glClearDepthf"); - contextPtr->glCreateShaderProgramv = (delegate*)load( - "glCreateShaderProgramv"); - contextPtr->glDeleteProgramPipelines = (delegate*)load( - "glDeleteProgramPipelines"); - contextPtr->glDepthRangeArrayv = (delegate*)load( - "glDepthRangeArrayv"); - contextPtr->glDepthRangeIndexed = (delegate*)load( - "glDepthRangeIndexed"); - contextPtr->glDepthRangef = (delegate*)load("glDepthRangef"); - contextPtr->glGenProgramPipelines = (delegate*)load( - "glGenProgramPipelines"); - contextPtr->glGetDoublei_v = (delegate*)load( - "glGetDoublei_v"); - contextPtr->glGetFloati_v = (delegate*)load( - "glGetFloati_v"); - contextPtr->glGetProgramBinary = (delegate*)load( - "glGetProgramBinary"); - contextPtr->glGetProgramPipelineInfoLog = (delegate*)load( - "glGetProgramPipelineInfoLog"); - contextPtr->glGetProgramPipelineiv = (delegate*)load( - "glGetProgramPipelineiv"); - contextPtr->glGetShaderPrecisionFormat = (delegate*)load( - "glGetShaderPrecisionFormat"); - contextPtr->glGetVertexAttribLdv = (delegate*)load( - "glGetVertexAttribLdv"); - contextPtr->glIsProgramPipeline = (delegate*)load("glIsProgramPipeline"); - contextPtr->glProgramBinary = (delegate*)load( - "glProgramBinary"); - contextPtr->glProgramParameteri = (delegate*)load( - "glProgramParameteri"); - contextPtr->glProgramUniform1d = (delegate*)load( - "glProgramUniform1d"); - contextPtr->glProgramUniform1dv = (delegate*)load( - "glProgramUniform1dv"); - contextPtr->glProgramUniform1f = (delegate*)load( - "glProgramUniform1f"); - contextPtr->glProgramUniform1fv = (delegate*)load( - "glProgramUniform1fv"); - contextPtr->glProgramUniform1i = (delegate*)load( - "glProgramUniform1i"); - contextPtr->glProgramUniform1iv = (delegate*)load( - "glProgramUniform1iv"); - contextPtr->glProgramUniform1ui = (delegate*)load( - "glProgramUniform1ui"); - contextPtr->glProgramUniform1uiv = (delegate*)load( - "glProgramUniform1uiv"); - contextPtr->glProgramUniform2d = (delegate*)load( - "glProgramUniform2d"); - contextPtr->glProgramUniform2dv = (delegate*)load( - "glProgramUniform2dv"); - contextPtr->glProgramUniform2f = (delegate*)load( - "glProgramUniform2f"); - contextPtr->glProgramUniform2fv = (delegate*)load( - "glProgramUniform2fv"); - contextPtr->glProgramUniform2i = (delegate*)load( - "glProgramUniform2i"); - contextPtr->glProgramUniform2iv = (delegate*)load( - "glProgramUniform2iv"); - contextPtr->glProgramUniform2ui = (delegate*)load( - "glProgramUniform2ui"); - contextPtr->glProgramUniform2uiv = (delegate*)load( - "glProgramUniform2uiv"); - contextPtr->glProgramUniform3d = (delegate*)load( - "glProgramUniform3d"); - contextPtr->glProgramUniform3dv = (delegate*)load( - "glProgramUniform3dv"); - contextPtr->glProgramUniform3f = (delegate*)load( - "glProgramUniform3f"); - contextPtr->glProgramUniform3fv = (delegate*)load( - "glProgramUniform3fv"); - contextPtr->glProgramUniform3i = (delegate*)load( - "glProgramUniform3i"); - contextPtr->glProgramUniform3iv = (delegate*)load( - "glProgramUniform3iv"); - contextPtr->glProgramUniform3ui = (delegate*)load( - "glProgramUniform3ui"); - contextPtr->glProgramUniform3uiv = (delegate*)load( - "glProgramUniform3uiv"); - contextPtr->glProgramUniform4d = (delegate*)load( - "glProgramUniform4d"); - contextPtr->glProgramUniform4dv = (delegate*)load( - "glProgramUniform4dv"); - contextPtr->glProgramUniform4f = (delegate*)load( - "glProgramUniform4f"); - contextPtr->glProgramUniform4fv = (delegate*)load( - "glProgramUniform4fv"); - contextPtr->glProgramUniform4i = (delegate*)load( - "glProgramUniform4i"); - contextPtr->glProgramUniform4iv = (delegate*)load( - "glProgramUniform4iv"); - contextPtr->glProgramUniform4ui = (delegate*)load( - "glProgramUniform4ui"); - contextPtr->glProgramUniform4uiv = (delegate*)load( - "glProgramUniform4uiv"); - contextPtr->glProgramUniformMatrix2dv = (delegate*)load( - "glProgramUniformMatrix2dv"); - contextPtr->glProgramUniformMatrix2fv = (delegate*)load( - "glProgramUniformMatrix2fv"); - contextPtr->glProgramUniformMatrix2x3dv = (delegate*)load( - "glProgramUniformMatrix2x3dv"); - contextPtr->glProgramUniformMatrix2x3fv = (delegate*)load( - "glProgramUniformMatrix2x3fv"); - contextPtr->glProgramUniformMatrix2x4dv = (delegate*)load( - "glProgramUniformMatrix2x4dv"); - contextPtr->glProgramUniformMatrix2x4fv = (delegate*)load( - "glProgramUniformMatrix2x4fv"); - contextPtr->glProgramUniformMatrix3dv = (delegate*)load( - "glProgramUniformMatrix3dv"); - contextPtr->glProgramUniformMatrix3fv = (delegate*)load( - "glProgramUniformMatrix3fv"); - contextPtr->glProgramUniformMatrix3x2dv = (delegate*)load( - "glProgramUniformMatrix3x2dv"); - contextPtr->glProgramUniformMatrix3x2fv = (delegate*)load( - "glProgramUniformMatrix3x2fv"); - contextPtr->glProgramUniformMatrix3x4dv = (delegate*)load( - "glProgramUniformMatrix3x4dv"); - contextPtr->glProgramUniformMatrix3x4fv = (delegate*)load( - "glProgramUniformMatrix3x4fv"); - contextPtr->glProgramUniformMatrix4dv = (delegate*)load( - "glProgramUniformMatrix4dv"); - contextPtr->glProgramUniformMatrix4fv = (delegate*)load( - "glProgramUniformMatrix4fv"); - contextPtr->glProgramUniformMatrix4x2dv = (delegate*)load( - "glProgramUniformMatrix4x2dv"); - contextPtr->glProgramUniformMatrix4x2fv = (delegate*)load( - "glProgramUniformMatrix4x2fv"); - contextPtr->glProgramUniformMatrix4x3dv = (delegate*)load( - "glProgramUniformMatrix4x3dv"); - contextPtr->glProgramUniformMatrix4x3fv = (delegate*)load( - "glProgramUniformMatrix4x3fv"); - contextPtr->glReleaseShaderCompiler = (delegate*)load( - "glReleaseShaderCompiler"); - contextPtr->glScissorArrayv = (delegate*)load( - "glScissorArrayv"); - contextPtr->glScissorIndexed = (delegate*)load( - "glScissorIndexed"); - contextPtr->glScissorIndexedv = (delegate*)load( - "glScissorIndexedv"); - contextPtr->glShaderBinary = (delegate*)load( - "glShaderBinary"); - contextPtr->glUseProgramStages = (delegate*)load( - "glUseProgramStages"); - contextPtr->glValidateProgramPipeline = (delegate*)load( - "glValidateProgramPipeline"); - contextPtr->glVertexAttribL1d = (delegate*)load( - "glVertexAttribL1d"); - contextPtr->glVertexAttribL1dv = (delegate*)load( - "glVertexAttribL1dv"); - contextPtr->glVertexAttribL2d = (delegate*)load( - "glVertexAttribL2d"); - contextPtr->glVertexAttribL2dv = (delegate*)load( - "glVertexAttribL2dv"); - contextPtr->glVertexAttribL3d = (delegate*)load( - "glVertexAttribL3d"); - contextPtr->glVertexAttribL3dv = (delegate*)load( - "glVertexAttribL3dv"); - contextPtr->glVertexAttribL4d = (delegate*)load( - "glVertexAttribL4d"); - contextPtr->glVertexAttribL4dv = (delegate*)load( - "glVertexAttribL4dv"); - contextPtr->glVertexAttribLPointer = (delegate*)load( - "glVertexAttribLPointer"); - contextPtr->glViewportArrayv = (delegate*)load( - "glViewportArrayv"); - contextPtr->glViewportIndexedf = (delegate*)load( - "glViewportIndexedf"); - contextPtr->glViewportIndexedfv = (delegate*)load( - "glViewportIndexedfv"); - - #endregion load - - InternalIO.InternalAppendLog("Successfully load all OpenGL 4.1 APIs"); - } - - internal static unsafe void LoadGLcore42(OpenglContext* contextPtr, delegate* load) - { - if (!core42) - { - InternalIO.InternalAppendLog("The core version 4.2 is not supported."); - throw new Exception("Final Version"); - } - - #region load - - contextPtr->glBindImageTexture = (delegate*)load( - "glBindImageTexture"); - contextPtr->glDrawArraysInstancedBaseInstance = (delegate*)load( - "glDrawArraysInstancedBaseInstance"); - contextPtr->glDrawElementsInstancedBaseInstance = (delegate*)load( - "glDrawElementsInstancedBaseInstance"); - contextPtr->glDrawElementsInstancedBaseVertexBaseInstance = (delegate*)load( - "glDrawElementsInstancedBaseVertexBaseInstance"); - contextPtr->glDrawTransformFeedbackInstanced = (delegate*)load( - "glDrawTransformFeedbackInstanced"); - contextPtr->glDrawTransformFeedbackStreamInstanced = (delegate*)load( - "glDrawTransformFeedbackStreamInstanced"); - contextPtr->glGetActiveAtomicCounterBufferiv = (delegate*)load( - "glGetActiveAtomicCounterBufferiv"); - contextPtr->glGetInternalformativ = (delegate*)load( - "glGetInternalformativ"); - contextPtr->glMemoryBarrier = (delegate*)load("glMemoryBarrier"); - contextPtr->glTexStorage1D = (delegate*)load( - "glTexStorage1D"); - contextPtr->glTexStorage2D = (delegate*)load( - "glTexStorage2D"); - contextPtr->glTexStorage3D = (delegate*)load( - "glTexStorage3D"); - - #endregion load - - InternalIO.InternalAppendLog("Successfully load all OpenGL 4.2 APIs"); - } - - internal static unsafe void LoadGLcore43(OpenglContext* contextPtr, delegate* load) - { - if (!core43) - { - InternalIO.InternalAppendLog("The core version 4.3 is not supported."); - throw new Exception("Final Version"); - } - - #region load - - contextPtr->glBindVertexBuffer = (delegate*)load( - "glBindVertexBuffer"); - contextPtr->glClearBufferData = (delegate*)load( - "glClearBufferData"); - contextPtr->glClearBufferSubData = (delegate*)load( - "glClearBufferSubData"); - contextPtr->glCopyImageSubData = (delegate*)load( - "glCopyImageSubData"); - contextPtr->glDebugMessageCallback = (delegate*)load( - "glDebugMessageCallback"); - contextPtr->glDebugMessageControl = (delegate*)load( - "glDebugMessageControl"); - contextPtr->glDebugMessageInsert = (delegate*)load( - "glDebugMessageInsert"); - contextPtr->glDispatchCompute = (delegate*)load( - "glDispatchCompute"); - contextPtr->glDispatchComputeIndirect = (delegate*)load( - "glDispatchComputeIndirect"); - contextPtr->glFramebufferParameteri = (delegate*)load( - "glFramebufferParameteri"); - contextPtr->glGetDebugMessageLog = (delegate*)load( - "glGetDebugMessageLog"); - contextPtr->glGetFramebufferParameteriv = (delegate*)load( - "glGetFramebufferParameteriv"); - contextPtr->glGetInternalformati64v = (delegate*)load( - "glGetInternalformati64v"); - contextPtr->glGetObjectLabel = (delegate*)load( - "glGetObjectLabel"); - contextPtr->glGetObjectPtrLabel = (delegate*)load( - "glGetObjectPtrLabel"); - contextPtr->glGetPointerv = (delegate*)load("glGetPointerv"); - contextPtr->glGetProgramInterfaceiv = (delegate*)load( - "glGetProgramInterfaceiv"); - contextPtr->glGetProgramResourceIndex = (delegate*)load( - "glGetProgramResourceIndex"); - contextPtr->glGetProgramResourceLocation = (delegate*)load( - "glGetProgramResourceLocation"); - contextPtr->glGetProgramResourceLocationIndex = (delegate*)load( - "glGetProgramResourceLocationIndex"); - contextPtr->glGetProgramResourceName = (delegate*)load( - "glGetProgramResourceName"); - contextPtr->glGetProgramResourceiv = (delegate*)load( - "glGetProgramResourceiv"); - contextPtr->glInvalidateBufferData = (delegate*)load( - "glInvalidateBufferData"); - contextPtr->glInvalidateBufferSubData = (delegate*)load( - "glInvalidateBufferSubData"); - contextPtr->glInvalidateFramebuffer = (delegate*)load( - "glInvalidateFramebuffer"); - contextPtr->glInvalidateSubFramebuffer = (delegate*)load( - "glInvalidateSubFramebuffer"); - contextPtr->glInvalidateTexImage = (delegate*)load( - "glInvalidateTexImage"); - contextPtr->glInvalidateTexSubImage = (delegate*)load( - "glInvalidateTexSubImage"); - contextPtr->glMultiDrawArraysIndirect = (delegate*)load( - "glMultiDrawArraysIndirect"); - contextPtr->glMultiDrawElementsIndirect = (delegate*)load( - "glMultiDrawElementsIndirect"); - contextPtr->glObjectLabel = (delegate*)load( - "glObjectLabel"); - contextPtr->glObjectPtrLabel = (delegate*)load( - "glObjectPtrLabel"); - contextPtr->glPopDebugGroup = (delegate*)load("glPopDebugGroup"); - contextPtr->glPushDebugGroup = (delegate*)load( - "glPushDebugGroup"); - contextPtr->glShaderStorageBlockBinding = (delegate*)load( - "glShaderStorageBlockBinding"); - contextPtr->glTexBufferRange = (delegate*)load( - "glTexBufferRange"); - contextPtr->glTexStorage2DMultisample = (delegate*)load( - "glTexStorage2DMultisample"); - contextPtr->glTexStorage3DMultisample = (delegate*)load( - "glTexStorage3DMultisample"); - contextPtr->glTextureView = (delegate*)load( - "glTextureView"); - contextPtr->glVertexAttribBinding = (delegate*)load( - "glVertexAttribBinding"); - contextPtr->glVertexAttribFormat = (delegate*)load( - "glVertexAttribFormat"); - contextPtr->glVertexAttribIFormat = (delegate*)load( - "glVertexAttribIFormat"); - contextPtr->glClearBufferData = (delegate*)load( - "glClearBufferData"); - contextPtr->glVertexBindingDivisor = (delegate*)load( - "glVertexBindingDivisor"); - - #endregion load - - InternalIO.InternalAppendLog("Successfully load all OpenGL 4.3 APIs"); - } - - internal static unsafe void LoadGLcore44(OpenglContext* contextPtr, delegate* load) - { - if (!core44) - { - InternalIO.InternalAppendLog("The core version 4.4 is not supported."); - throw new Exception("Final Version"); - } - - #region load - - contextPtr->glBindBuffersBase = (delegate*)load( - "glBindBuffersBase"); - contextPtr->glBindBuffersRange = (delegate*)load( - "glBindBuffersRange"); - contextPtr->glBindImageTextures = (delegate*)load( - "glBindImageTextures"); - contextPtr->glBindSamplers = (delegate*)load( - "glBindSamplers"); - contextPtr->glBindTextures = (delegate*)load( - "glBindTextures"); - contextPtr->glBindVertexBuffers = (delegate*)load( - "glBindVertexBuffers"); - contextPtr->glBufferStorage = (delegate*)load( - "glBufferStorage"); - contextPtr->glClearTexImage = (delegate*)load( - "glClearTexImage"); - contextPtr->glClearTexSubImage = (delegate*)load( - "glClearTexSubImage"); - - #endregion load - - InternalIO.InternalAppendLog("Successfully load all OpenGL 4.4 APIs"); - } - - internal static unsafe void LoadGLcore45(OpenglContext* contextPtr, delegate* load) - { - if (!core45) - { - InternalIO.InternalAppendLog("The core version 4.5 is not supported."); - throw new Exception("Final Version"); - } - - #region load - - contextPtr->glBindTextureUnit = (delegate*)load( - "glBindTextureUnit"); - contextPtr->glBlitNamedFramebuffer = (delegate*)load( - "glBlitNamedFramebuffer"); - contextPtr->glCheckNamedFramebufferStatus = (delegate*)load( - "glCheckNamedFramebufferStatus"); - contextPtr->glClearNamedBufferData = (delegate*)load( - "glClearNamedBufferData"); - contextPtr->glClearNamedBufferSubData = (delegate*)load( - "glClearNamedBufferSubData"); - contextPtr->glClearNamedFramebufferfi = (delegate*)load( - "glClearNamedFramebufferfi"); - contextPtr->glClearNamedFramebufferfv = (delegate*)load( - "glClearNamedFramebufferfv"); - contextPtr->glClearNamedFramebufferiv = (delegate*)load( - "glClearNamedFramebufferiv"); - contextPtr->glClearNamedFramebufferuiv = (delegate*)load( - "glClearNamedFramebufferuiv"); - contextPtr->glClipControl = (delegate*)load("glClipControl"); - contextPtr->glCompressedTextureSubImage1D = (delegate*)load( - "glCompressedTextureSubImage1D"); - contextPtr->glCompressedTextureSubImage2D = (delegate*)load( - "glCompressedTextureSubImage2D"); - contextPtr->glCompressedTextureSubImage3D = (delegate*)load( - "glCompressedTextureSubImage3D"); - contextPtr->glCopyNamedBufferSubData = (delegate*)load( - "glCopyNamedBufferSubData"); - contextPtr->glCopyTextureSubImage1D = (delegate*)load( - "glCopyTextureSubImage1D"); - contextPtr->glCopyTextureSubImage2D = (delegate*)load( - "glCopyTextureSubImage2D"); - contextPtr->glCopyTextureSubImage3D = (delegate*)load( - "glCopyTextureSubImage3D"); - contextPtr->glCreateBuffers = (delegate*)load("glCreateBuffers"); - contextPtr->glCreateFramebuffers = (delegate*)load( - "glCreateFramebuffers"); - contextPtr->glCreateProgramPipelines = (delegate*)load( - "glCreateProgramPipelines"); - contextPtr->glCreateQueries = (delegate*)load( - "glCreateQueries"); - contextPtr->glCreateRenderbuffers = (delegate*)load( - "glCreateRenderbuffers"); - contextPtr->glCreateSamplers = (delegate*)load( - "glCreateSamplers"); - contextPtr->glCreateTextures = (delegate*)load( - "glCreateTextures"); - contextPtr->glCreateTransformFeedbacks = (delegate*)load( - "glCreateTransformFeedbacks"); - contextPtr->glCreateVertexArrays = (delegate*)load( - "glCreateVertexArrays"); - contextPtr->glDisableVertexArrayAttrib = (delegate*)load( - "glDisableVertexArrayAttrib"); - contextPtr->glEnableVertexArrayAttrib = (delegate*)load( - "glEnableVertexArrayAttrib"); - contextPtr->glFlushMappedNamedBufferRange = (delegate*)load( - "glFlushMappedNamedBufferRange"); - contextPtr->glGenerateTextureMipmap = (delegate*)load( - "glGenerateTextureMipmap"); - contextPtr->glGetCompressedTextureImage = (delegate*)load( - "glGetCompressedTextureImage"); - contextPtr->glGetCompressedTextureSubImage = (delegate*)load( - "glGetCompressedTextureSubImage"); - contextPtr->glGetGraphicsResetStatus = (delegate*)load( - "glGetGraphicsResetStatus"); - contextPtr->glGetNamedBufferParameteri64v = (delegate*)load( - "glGetNamedBufferParameteri64v"); - contextPtr->glGetNamedBufferParameteriv = (delegate*)load( - "glGetNamedBufferParameteriv"); - contextPtr->glGetNamedBufferPointerv = (delegate*)load( - "glGetNamedBufferPointerv"); - contextPtr->glGetNamedBufferSubData = (delegate*)load( - "glGetNamedBufferSubData"); - contextPtr->glGetNamedFramebufferAttachmentParameteriv = (delegate*)load( - "glGetNamedFramebufferAttachmentParameteriv"); - contextPtr->glGetNamedFramebufferParameteriv = (delegate*)load( - "glGetNamedFramebufferParameteriv"); - contextPtr->glGetNamedRenderbufferParameteriv = (delegate*)load( - "glGetNamedRenderbufferParameteriv"); - contextPtr->glGetQueryBufferObjecti64v = (delegate*)load( - "glGetQueryBufferObjecti64v"); - contextPtr->glGetQueryBufferObjectiv = (delegate*)load( - "glGetQueryBufferObjectiv"); - contextPtr->glGetQueryBufferObjectui64v = (delegate*)load( - "glGetQueryBufferObjectui64v"); - contextPtr->glGetQueryBufferObjectuiv = (delegate*)load( - "glGetQueryBufferObjectuiv"); - contextPtr->glGetTextureImage = (delegate*)load( - "glGetTextureImage"); - contextPtr->glGetTextureLevelParameterfv = (delegate*)load( - "glGetTextureLevelParameterfv"); - contextPtr->glGetTextureLevelParameteriv = (delegate*)load( - "glGetTextureLevelParameteriv"); - contextPtr->glGetTextureParameterIiv = (delegate*)load( - "glGetTextureParameterIiv"); - contextPtr->glGetTextureParameterIuiv = (delegate*)load( - "glGetTextureParameterIuiv"); - contextPtr->glGetTextureParameterfv = (delegate*)load( - "glGetTextureParameterfv"); - contextPtr->glGetTextureParameteriv = (delegate*)load( - "glGetTextureParameteriv"); - contextPtr->glGetTextureSubImage = (delegate*)load( - "glGetTextureSubImage"); - contextPtr->glGetTransformFeedbacki64_v = (delegate*)load( - "glGetTransformFeedbacki64_v"); - contextPtr->glGetTransformFeedbacki_v = (delegate*)load( - "glGetTransformFeedbacki_v"); - contextPtr->glGetTransformFeedbackiv = (delegate*)load( - "glGetTransformFeedbackiv"); - contextPtr->glGetVertexArrayIndexed64iv = (delegate*)load( - "glGetVertexArrayIndexed64iv"); - contextPtr->glGetVertexArrayIndexediv = (delegate*)load( - "glGetVertexArrayIndexediv"); - contextPtr->glGetVertexArrayiv = (delegate*)load( - "glGetVertexArrayiv"); - contextPtr->glGetnCompressedTexImage = (delegate*)load( - "glGetnCompressedTexImage"); - contextPtr->glGetnTexImage = (delegate*)load( - "glGetnTexImage"); - contextPtr->glGetnUniformdv = (delegate*)load( - "glGetnUniformdv"); - contextPtr->glGetnUniformfv = (delegate*)load( - "glGetnUniformfv"); - contextPtr->glGetnUniformiv = (delegate*)load( - "glGetnUniformiv"); - contextPtr->glGetnUniformuiv = (delegate*)load( - "glGetnUniformuiv"); - contextPtr->glInvalidateNamedFramebufferData = (delegate*)load( - "glInvalidateNamedFramebufferData"); - contextPtr->glInvalidateNamedFramebufferSubData = (delegate*)load( - "glInvalidateNamedFramebufferSubData"); - contextPtr->glMapNamedBuffer = (delegate*)load( - "glMapNamedBuffer"); - contextPtr->glMapNamedBufferRange = (delegate*)load( - "glMapNamedBufferRange"); - contextPtr->glMemoryBarrierByRegion = (delegate*)load( - "glMemoryBarrierByRegion"); - contextPtr->glNamedBufferData = (delegate*)load( - "glNamedBufferData"); - contextPtr->glNamedBufferStorage = (delegate*)load( - "glNamedBufferStorage"); - contextPtr->glNamedBufferSubData = (delegate*)load( - "glNamedBufferSubData"); - contextPtr->glNamedFramebufferDrawBuffer = (delegate*)load( - "glNamedFramebufferDrawBuffer"); - contextPtr->glNamedFramebufferDrawBuffers = (delegate*)load( - "glNamedFramebufferDrawBuffers"); - contextPtr->glNamedFramebufferParameteri = (delegate*)load( - "glNamedFramebufferParameteri"); - contextPtr->glNamedFramebufferReadBuffer = (delegate*)load( - "glNamedFramebufferReadBuffer"); - contextPtr->glNamedFramebufferRenderbuffer = (delegate*)load( - "glNamedFramebufferRenderbuffer"); - contextPtr->glNamedFramebufferTexture = (delegate*)load( - "glNamedFramebufferTexture"); - contextPtr->glNamedFramebufferTextureLayer = (delegate*)load( - "glNamedFramebufferTextureLayer"); - contextPtr->glNamedRenderbufferStorage = (delegate*)load( - "glNamedRenderbufferStorage"); - contextPtr->glNamedRenderbufferStorageMultisample = (delegate*)load( - "glNamedRenderbufferStorageMultisample"); - contextPtr->glReadnPixels = (delegate*)load( - "glReadnPixels"); - contextPtr->glTextureBarrier = (delegate*)load("glTextureBarrier"); - contextPtr->glTextureBuffer = (delegate*)load( - "glTextureBuffer"); - contextPtr->glTextureBufferRange = (delegate*)load( - "glTextureBufferRange"); - contextPtr->glTextureParameterIiv = (delegate*)load( - "glTextureParameterIiv"); - contextPtr->glTextureParameterIuiv = (delegate*)load( - "glTextureParameterIuiv"); - contextPtr->glTextureParameterf = (delegate*)load( - "glTextureParameterf"); - contextPtr->glTextureParameterfv = (delegate*)load( - "glTextureParameterfv"); - contextPtr->glTextureParameteri = (delegate*)load( - "glTextureParameteri"); - contextPtr->glTextureParameteriv = (delegate*)load( - "glTextureParameteriv"); - contextPtr->glTextureStorage1D = (delegate*)load( - "glTextureStorage1D"); - contextPtr->glTextureStorage2D = (delegate*)load( - "glTextureStorage2D"); - contextPtr->glTextureStorage2DMultisample = (delegate*)load( - "glTextureStorage2DMultisample"); - contextPtr->glTextureStorage3D = (delegate*)load( - "glTextureStorage3D"); - contextPtr->glTextureStorage3DMultisample = (delegate*)load( - "glTextureStorage3DMultisample"); - contextPtr->glTextureSubImage1D = (delegate*)load( - "glTextureSubImage1D"); - contextPtr->glTextureSubImage2D = (delegate*)load( - "glTextureSubImage2D"); - contextPtr->glTextureSubImage3D = (delegate*)load( - "glTextureSubImage3D"); - contextPtr->glTransformFeedbackBufferBase = (delegate*)load( - "glTransformFeedbackBufferBase"); - contextPtr->glTransformFeedbackBufferRange = (delegate*)load( - "glTransformFeedbackBufferRange"); - contextPtr->glUnmapNamedBuffer = (delegate*)load("glUnmapNamedBuffer"); - contextPtr->glVertexArrayAttribBinding = (delegate*)load( - "glVertexArrayAttribBinding"); - contextPtr->glVertexArrayAttribFormat = (delegate*)load( - "glVertexArrayAttribFormat"); - contextPtr->glVertexArrayAttribIFormat = (delegate*)load( - "glVertexArrayAttribIFormat"); - contextPtr->glVertexArrayAttribLFormat = (delegate*)load( - "glVertexArrayAttribLFormat"); - contextPtr->glVertexArrayBindingDivisor = (delegate*)load( - "glVertexArrayBindingDivisor"); - contextPtr->glVertexArrayElementBuffer = (delegate*)load( - "glVertexArrayElementBuffer"); - contextPtr->glVertexArrayVertexBuffer = (delegate*)load( - "glVertexArrayVertexBuffer"); - contextPtr->glVertexArrayVertexBuffers = (delegate*)load( - "glVertexArrayVertexBuffers"); - - #endregion load - - InternalIO.InternalAppendLog("Successfully load all OpenGL 4.5 APIs"); - } - - internal static unsafe void LoadGLcore46(OpenglContext* contextPtr, delegate* load) - { - if (!core46) - { - InternalIO.InternalAppendLog("The core version 4.6 is not supported."); - throw new Exception("Final Version"); - } - - #region load - - contextPtr->glMultiDrawArraysIndirectCount = (delegate*)load( - "glMultiDrawArraysIndirectCount"); - contextPtr->glMultiDrawElementsIndirectCount = (delegate*)load( - "glMultiDrawElementsIndirectCount"); - contextPtr->glPolygonOffsetClamp = (delegate*)load( - "glPolygonOffsetClamp"); - contextPtr->glSpecializeShader = (delegate*)load( - "glSpecializeShader"); - - #endregion load - - InternalIO.InternalAppendLog("Successfully load all OpenGL 4.6 APIs"); - } - } } \ No newline at end of file diff --git a/StgSharp.Common/Graphics/OpenGL/glConst.cs b/StgSharp.Common/Graphics/OpenGL/glConst.cs index 08a3f5ab..d2719020 100644 --- a/StgSharp.Common/Graphics/OpenGL/glConst.cs +++ b/StgSharp.Common/Graphics/OpenGL/glConst.cs @@ -35,303 +35,6 @@ namespace StgSharp.Graphics.OpenGL public static unsafe class glConst { - #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 - #region glad public const int _1PASS_EXT = 0x80A1; diff --git a/StgSharp.Common/Graphics/OpenGL/glFunction.cs b/StgSharp.Common/Graphics/OpenGL/glFunction.cs index 1f966752..d2fa560b 100644 --- a/StgSharp.Common/Graphics/OpenGL/glFunction.cs +++ b/StgSharp.Common/Graphics/OpenGL/glFunction.cs @@ -347,7 +347,7 @@ namespace StgSharp.Graphics.OpenGL a = glConst.UNSIGNED_BYTE; break; default: - InternalIO.InternalWriteLog( + DefaultLog.InternalWriteLog( $"{$"Parameter error in parameter {nameof(type)} method DrawElements. "}{$"Only {typeof(uint).Name},{typeof(ushort).Name},{typeof(byte).Name} types are supported."}", LogType.Error); return; @@ -446,7 +446,7 @@ namespace StgSharp.Graphics.OpenGL public string GetShaderStatus(Shader s, int index, int key) { IntPtr sptr = IntPtr.Zero; - if (InternalIO.glCheckShaderStatus(ref Context, s.handle[index].Value, key, + if (GraphicFramework.glCheckShaderStatus(ref Context, s.handle[index].Value, key, ref sptr) == 0) { return Marshal.PtrToStringAnsi(sptr); } @@ -546,8 +546,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 +562,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++; } @@ -683,7 +683,7 @@ namespace StgSharp.Graphics.OpenGL [MethodImpl(MethodImplOptions.AggressiveInlining)] public void SetVertexAttribute(uint index, int size, TypeCode t, bool normalized, uint stride, int pointer) { - uint type = InternalIO.GLtype[t]; + uint type = GraphicFramework.GLtype[(int)t]; Context.glVertexAttribPointer(index, size, type, normalized ? 1 : 0, stride, (void*)pointer); Context.glEnableVertexAttribArray(index); } @@ -704,8 +704,8 @@ namespace StgSharp.Graphics.OpenGL 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 } @@ -725,8 +725,8 @@ namespace StgSharp.Graphics.OpenGL #pragma warning disable CS8500 fixed (T* tptr = pixelSpan) { - 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 } diff --git a/StgSharp.Common/Graphics/OpenGL/glRenderStream.cs b/StgSharp.Common/Graphics/OpenGL/glRenderStream.cs index a9abc101..e499df32 100644 --- a/StgSharp.Common/Graphics/OpenGL/glRenderStream.cs +++ b/StgSharp.Common/Graphics/OpenGL/glRenderStream.cs @@ -81,7 +81,7 @@ namespace StgSharp.Graphics.OpenGL /// public unsafe void MakeAsCurrentContext() { - InternalIO.glfwMakeContextCurrent(CanvasHandle); + GraphicFramework.glfwMakeContextCurrent(CanvasHandle); OpenGLFunction.CurrentGL = this.GL; } @@ -94,7 +94,7 @@ namespace StgSharp.Graphics.OpenGL } SwapBuffers(); renderToThread[this] = ThreadHelper.EmptyThread; - InternalIO.glfwMakeContextCurrent(IntPtr.Zero); + GraphicFramework.glfwMakeContextCurrent(IntPtr.Zero); OpenGLFunction.CurrentGL = null; } @@ -117,7 +117,7 @@ namespace StgSharp.Graphics.OpenGL [MethodImpl(MethodImplOptions.AggressiveInlining)] public override void SetSizeLimit(int minWidth, int minHeight, int maxWidth, int maxHeight) { - InternalIO.glfwSetWindowSizeLimits( + GraphicFramework.glfwSetWindowSizeLimits( this.CanvasHandle, minWidth, minHeight, maxWidth, maxHeight); } @@ -160,17 +160,17 @@ namespace StgSharp.Graphics.OpenGL protected KeyStatus CheckKey(KeyboardKey key) { - return InternalIO.glfwGetKey(this.CanvasHandle, (int)key); + return GraphicFramework.glfwGetKey(this.CanvasHandle, (int)key); } protected KeyStatus CheckKey(Mouse key) { - return InternalIO.glfwGetKey(this.CanvasHandle, (int)key); + return GraphicFramework.glfwGetKey(this.CanvasHandle, (int)key); } protected KeyStatus CheckKey(Joystick key) { - return InternalIO.glfwGetKey(this.CanvasHandle, (int)key); + return GraphicFramework.glfwGetKey(this.CanvasHandle, (int)key); } #endregion diff --git a/StgSharp.Common/Graphics/OpenGL/glType.cs b/StgSharp.Common/Graphics/OpenGL/glType.cs index ef8256ed..cd48064d 100644 --- a/StgSharp.Common/Graphics/OpenGL/glType.cs +++ b/StgSharp.Common/Graphics/OpenGL/glType.cs @@ -46,21 +46,21 @@ namespace StgSharp.Internal.OpenGL { if (value.GetType().Name != "Uint32") { - goto errorlog; + goto errorLog; } this.value = value; } else { if (value.GetType().Name != "IntPtr") { - goto errorlog; + goto errorLog; } this.value = value; } - errorlog: + errorLog: { - InternalIO.InternalWriteLog( + DefaultLog.InternalWriteLog( $"{value.GetType().Name} does not match definination of GLhandlARB on OS {Environment.OSVersion.Platform} ", LogType.Error); } diff --git a/StgSharp.Common/Graphics/RenderStream.cs b/StgSharp.Common/Graphics/RenderStream.cs index 54aa019d..2ab3fa1c 100644 --- a/StgSharp.Common/Graphics/RenderStream.cs +++ b/StgSharp.Common/Graphics/RenderStream.cs @@ -158,12 +158,12 @@ namespace StgSharp.Graphics /**/ protected internal static void PollEvents() { - InternalIO.glfwPollEvents(); + GraphicFramework.glfwPollEvents(); } private protected void SwapBuffers() { - InternalIO.glfwSwapBuffers(CanvasHandle); + GraphicFramework.glfwSwapBuffers(CanvasHandle); } /**/ @@ -209,7 +209,7 @@ namespace StgSharp.Graphics nativeCamera = new Camera(); PlatformSpecifiedInitialize(); CustomizeInit(); - InternalIO.glfwMakeContextCurrent(IntPtr.Zero); + GraphicFramework.glfwMakeContextCurrent(IntPtr.Zero); } internal abstract void PlatformSpecifiedInitialize(); diff --git a/StgSharp.Common/HighPerformance/Lable.cs b/StgSharp.Common/HighPerformance/Lable.cs index bb336db4..00b9cec4 100644 --- a/StgSharp.Common/HighPerformance/Lable.cs +++ b/StgSharp.Common/HighPerformance/Lable.cs @@ -49,7 +49,7 @@ namespace StgSharp.HighPerformance { ReadOnlySpan nameSpan = Name.AsSpan(); fixed (char* cptr = nameSpan) { - return InternalIO.Intrinsic.city_hash_simplify(cptr, Name.Length); + return NativeIntrinsic.Intrinsic.city_hash_simplify(cptr, Name.Length); } } diff --git a/StgSharp.Common/HighPerformance/UnsafeCompute.cs b/StgSharp.Common/HighPerformance/UnsafeCompute.cs index a7c9f845..36664dea 100644 --- a/StgSharp.Common/HighPerformance/UnsafeCompute.cs +++ b/StgSharp.Common/HighPerformance/UnsafeCompute.cs @@ -35,19 +35,19 @@ namespace StgSharp.HighPerformance [MethodImpl(MethodImplOptions.AggressiveInlining)] public static unsafe int CityHashSimplify(char* span, int length) { - return InternalIO.Intrinsic.city_hash_simplify(span, length); + return NativeIntrinsic.Intrinsic.city_hash_simplify(span, length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static unsafe int CityHashSimplify(char* span, int begin, int length) { - return InternalIO.Intrinsic.city_hash_simplify(span + begin, length); + return NativeIntrinsic.Intrinsic.city_hash_simplify(span + begin, length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static unsafe int IndexOfCharPair(char* source, int pairValue, int length) { - return InternalIO.Intrinsic.index_pair(source, pairValue, length); + return NativeIntrinsic.Intrinsic.index_pair(source, pairValue, length); } } diff --git a/StgSharp.Common/Internal/InternalIO.cs b/StgSharp.Common/Internal/DefaultLog.cs similarity index 68% rename from StgSharp.Common/Internal/InternalIO.cs rename to StgSharp.Common/Internal/DefaultLog.cs index ba7635b1..e236e3cd 100644 --- a/StgSharp.Common/Internal/InternalIO.cs +++ b/StgSharp.Common/Internal/DefaultLog.cs @@ -1,6 +1,6 @@ //----------------------------------------------------------------------- // ----------------------------------------------------------------------- -// file="InternalIO" +// file="DefaultLog" // Project: StgSharp // AuthorGroup: Nitload // Copyright (c) Nitload. All rights reserved. @@ -25,62 +25,37 @@ // // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- -using StgSharp.Graphics; using StgSharp.Graphics.OpenGL; using System; using System.Collections.Generic; using System.IO; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; - -using System.Text; using System.Threading; namespace StgSharp.Internal { - internal static unsafe partial class InternalIO + internal static unsafe partial class DefaultLog { private const long MaxLogFileSize = 10 * 1024 * 1024; // 10 MB - internal const string NativeLibName = - "StgSharp.Native"; - - internal const string SS_errorLog = - "SS_errorlog.log"; - private static LogType _currentLogLevel = LogType.Info; - internal static Dictionary GLtype = []; - internal static readonly GCHandle ssc_logHandle = GCHandle.Alloc(new byte[512], GCHandleType.Pinned); - internal static IntPtr _nativeLibPtr = IntPtr.Zero; - internal static SemaphoreSlim logSyncSemaphore = new(1, 1); - static InternalIO() - { - GLtype.Add(TypeCode.Single, glConst.FLOAT); - GLtype.Add(TypeCode.Int32, glConst.INT); - GLtype.Add(TypeCode.UInt32, glConst.UNSIGNED_INT); - GLtype.Add(TypeCode.Int16, glConst.SHORT); - GLtype.Add(TypeCode.UInt16, glConst.UNSIGNED_SHORT); - GLtype.Add(TypeCode.SByte, glConst.BYTE); - GLtype.Add(TypeCode.Byte, glConst.UNSIGNED_BYTE); - } - internal static void InternalAppendLog(string log) { - if (!File.Exists(SS_errorLog)) + if (!File.Exists(Native.LogPath)) { - FileStream stream = File.Create(SS_errorLog); + FileStream stream = File.Create(Native.LogPath); stream.Close(); } - using (StreamWriter logStream = File.AppendText(SS_errorLog)) { + using (StreamWriter logStream = File.AppendText(Native.LogPath)) { logStream.WriteLine(log); } } @@ -96,32 +71,32 @@ namespace StgSharp.Internal { RotateLogFile(); - if (!File.Exists(SS_errorLog)) + if (!File.Exists(Native.LogPath)) { - FileStream stream = File.Create(SS_errorLog); + FileStream stream = File.Create(Native.LogPath); stream.Close(); } - using (StreamWriter logStream = File.AppendText(SS_errorLog)) { + using (StreamWriter logStream = File.AppendText(Native.LogPath)) { logStream.WriteLine($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}] [{logType}] {logLine}"); } } finally { - logSyncSemaphore.Release(); + _ = logSyncSemaphore.Release(); } } internal static void InternalWriteLog(string beforeTime, string logLine, LogType logType) { logSyncSemaphore.Wait(); - if (!File.Exists(SS_errorLog)) + if (!File.Exists(Native.LogPath)) { - FileStream stream = File.Create(SS_errorLog); + FileStream stream = File.Create(Native.LogPath); stream.Close(); } - using (StreamWriter logStream = File.AppendText(SS_errorLog)) + using (StreamWriter logStream = File.AppendText(Native.LogPath)) { logStream.WriteLine(beforeTime); logStream.WriteLine($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}] [{logType}] {logLine}"); @@ -136,13 +111,13 @@ namespace StgSharp.Internal private static void RotateLogFile() { - if (File.Exists(SS_errorLog) && new FileInfo(SS_errorLog).Length > MaxLogFileSize) + if (File.Exists(Native.LogPath) && new FileInfo(Native.LogPath).Length > MaxLogFileSize) { - string backupFile = SS_errorLog + ".backup"; + string backupFile = Native.LogPath + ".backup"; if (File.Exists(backupFile)) { File.Delete(backupFile); } - File.Move(SS_errorLog, backupFile); + File.Move(Native.LogPath, backupFile); } } diff --git a/StgSharp.Common/Internal/InternalResource.cs b/StgSharp.Common/Internal/Graphic/BuiltinShader.cs similarity index 95% rename from StgSharp.Common/Internal/InternalResource.cs rename to StgSharp.Common/Internal/Graphic/BuiltinShader.cs index 30dd8ec5..e95f9a45 100644 --- a/StgSharp.Common/Internal/InternalResource.cs +++ b/StgSharp.Common/Internal/Graphic/BuiltinShader.cs @@ -31,7 +31,7 @@ using System.Text; namespace StgSharp.Internal { - internal partial class InternalIO + internal static class BuiltInShader { #region ControllingItemRender @@ -46,9 +46,7 @@ namespace StgSharp.Internal #region CollisionTexture - internal static ReadOnlySpan CollisionTextureVertexShader - { - get => """ + internal static ReadOnlySpan CollisionTextureVertexShader => """ #version 430 core layout(location = 0) in vec2 localCollisionCoord; layout(location = 1) in vec2 spaceCoord; @@ -75,11 +73,8 @@ namespace StgSharp.Internal gl_Position = vec4(angle, realCoord.y, dist, 1); } """u8; - } - internal static ReadOnlySpan CollisionTextureFragmentShader - { - get => """ + internal static ReadOnlySpan CollisionTextureFragmentShader => """ #version 430 core out vec4 Color; @@ -96,8 +91,7 @@ namespace StgSharp.Internal Color = vec4(dist,0,0,1); } """u8; - } - #endregion + #endregion } } diff --git a/StgSharp.Common/Internal/ClangLoad/gl.cs b/StgSharp.Common/Internal/Graphic/gl.cs similarity index 73% rename from StgSharp.Common/Internal/ClangLoad/gl.cs rename to StgSharp.Common/Internal/Graphic/gl.cs index 676f4f9a..07ac1aaa 100644 --- a/StgSharp.Common/Internal/ClangLoad/gl.cs +++ b/StgSharp.Common/Internal/Graphic/gl.cs @@ -32,14 +32,26 @@ using System; using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using System.Text; namespace StgSharp.Internal { - internal partial class InternalIO + internal static partial class GraphicFramework { - [LibraryImport(NativeLibName, EntryPoint = "glCheckShaderStat")] + internal static uint[] GLtype = []; + + static GraphicFramework() + { + GLtype[(int)TypeCode.Single] = glConst.FLOAT; + GLtype[(int)TypeCode.Int32] = glConst.INT; + GLtype[(int)TypeCode.UInt32] = glConst.UNSIGNED_INT; + GLtype[(int)TypeCode.Int16] = glConst.SHORT; + GLtype[(int)TypeCode.UInt16] = glConst.UNSIGNED_SHORT; + GLtype[(int)TypeCode.SByte] = glConst.BYTE; + GLtype[(int)TypeCode.Byte] = glConst.UNSIGNED_BYTE; + } + + [LibraryImport(Native.LibName, EntryPoint = "glCheckShaderStat")] [UnmanagedCallConv(CallConvs =[ typeof(CallConvCdecl) ])] #pragma warning disable CA5392 internal static partial int glCheckShaderStatus( @@ -52,27 +64,27 @@ namespace StgSharp.Internal #region ssgc api define - [LibraryImport(NativeLibName, EntryPoint = "initGL")] + [LibraryImport(Native.LibName, EntryPoint = "initGL")] [UnmanagedCallConv(CallConvs =[ typeof(CallConvCdecl) ])] internal static partial void InternalInitGL(int majorVersion, int minorVersion); - [LibraryImport(NativeLibName, EntryPoint = "loadGlfuncDefault", StringMarshalling = StringMarshalling.Utf8)] + [LibraryImport(Native.LibName, EntryPoint = "loadGlfuncDefault", StringMarshalling = StringMarshalling.Utf8)] [UnmanagedCallConv(CallConvs =[ typeof(CallConvCdecl) ])] internal static partial IntPtr InternalLoadGlfuncDefault(string name); - [LibraryImport(NativeLibName, EntryPoint = "linkShaderProgram")] + [LibraryImport(Native.LibName, EntryPoint = "linkShaderProgram")] [UnmanagedCallConv(CallConvs =[ typeof(CallConvCdecl) ])] internal static unsafe partial uint InternalLinkShaderProgram(OpenglContext* context, uint shaderProgram); - [LibraryImport(NativeLibName, EntryPoint = "readLog")] + [LibraryImport(Native.LibName, EntryPoint = "readLog")] [UnmanagedCallConv(CallConvs =[ typeof(CallConvCdecl) ])] internal static unsafe partial IntPtr InternalReadSSCLog(); - [LibraryImport(NativeLibName, EntryPoint = "loadImageData", StringMarshalling = StringMarshalling.Utf8)] + [LibraryImport(Native.LibName, EntryPoint = "loadImageData", StringMarshalling = StringMarshalling.Utf8)] [UnmanagedCallConv(CallConvs =[ typeof(CallConvCdecl) ])] internal static unsafe partial void InternalLoadImage(string fileName, ImageInfo* output, ImageLoader loader); - [LibraryImport(NativeLibName, EntryPoint = "unloadImageData")] + [LibraryImport(Native.LibName, EntryPoint = "unloadImageData")] [UnmanagedCallConv(CallConvs =[ typeof(CallConvCdecl) ])] internal static unsafe partial void InternalUnloadImage(ImageInfo* output); diff --git a/StgSharp.Common/Internal/glfw.cs b/StgSharp.Common/Internal/Graphic/glfw.cs similarity index 97% rename from StgSharp.Common/Internal/glfw.cs rename to StgSharp.Common/Internal/Graphic/glfw.cs index 92b67ad7..4379aa9b 100644 --- a/StgSharp.Common/Internal/glfw.cs +++ b/StgSharp.Common/Internal/Graphic/glfw.cs @@ -25,24 +25,21 @@ // // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- -using StgSharp.Graphics; - using System; -using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; namespace StgSharp.Internal { - internal unsafe partial class InternalIO + internal static unsafe partial class GraphicFramework { private static readonly GLFWFunction _glfw = new GLFWFunction(); public static GLFWFunction glfwContext => _glfw; - [LibraryImport(NativeLibName, EntryPoint = "load_glfw_functions")] + [LibraryImport(Native.LibName, EntryPoint = "load_glfw_functions")] internal static unsafe partial void glfwLoadLibrary(GLFWFunction* context); internal static unsafe void LoadGlfw() @@ -116,14 +113,14 @@ namespace StgSharp.Internal } [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static unsafe void glfwGetMonitorWorkarea( + internal static unsafe void glfwGetMonitorWorkArea( IntPtr monitor, - int* xpos, - int* ypos, + int* xPos, + int* yPos, int* width, int* height) { - _glfw.glfwGetMonitorWorkarea(monitor, xpos, ypos, width, height); + _glfw.glfwGetMonitorWorkarea(monitor, xPos, yPos, width, height); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -275,12 +272,12 @@ namespace StgSharp.Internal [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static unsafe void glfwSetWindowSizeLimits( IntPtr window, - int minwidth, - int minheight, - int maxwidth, - int maxheight) + int minWidth, + int minHeight, + int maxWidth, + int maxHeight) { - _glfw.glfwSetWindowSizeLimits(window, minwidth, minheight, maxwidth, maxheight); + _glfw.glfwSetWindowSizeLimits(window, minWidth, minHeight, maxWidth, maxHeight); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -799,6 +796,12 @@ namespace StgSharp.Internal return glfwGetProcAddress(Encoding.UTF8.GetBytes(procName)); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal static unsafe IntPtr glfwGetProcAddress(ReadOnlySpan procName) + { + return glfwGetProcAddress(procName); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static unsafe IntPtr glfwGetProcAddress(Span procName) { diff --git a/StgSharp.Common/Internal/glfwFunction.cs b/StgSharp.Common/Internal/Graphic/glfw.function.cs similarity index 100% rename from StgSharp.Common/Internal/glfwFunction.cs rename to StgSharp.Common/Internal/Graphic/glfw.function.cs diff --git a/StgSharp.Common/Internal/Intrinsic/intrinsicContextProvider.cs b/StgSharp.Common/Internal/Intrinsic/intrinsicContextProvider.cs index d5fa16ad..2fabc0a3 100644 --- a/StgSharp.Common/Internal/Intrinsic/intrinsicContextProvider.cs +++ b/StgSharp.Common/Internal/Intrinsic/intrinsicContextProvider.cs @@ -34,7 +34,7 @@ using System.Runtime.InteropServices; namespace StgSharp.Internal { - internal static unsafe partial class InternalIO + internal static unsafe partial class NativeIntrinsic { private static readonly IntrinsicContext _intrinsicContext = new(); @@ -68,7 +68,7 @@ namespace StgSharp.Internal } } - [LibraryImport(NativeLibName, EntryPoint = "load_intrinsic_function")] + [LibraryImport(Native.LibName, EntryPoint = "load_intrinsic_function")] [UnmanagedCallConv(CallConvs =[ typeof(CallConvCdecl) ])] private static partial int LoadIntrinsicFunction(IntrinsicContext* context); diff --git a/StgSharp.Common/Internal/Native.cs b/StgSharp.Common/Internal/Native.cs new file mode 100644 index 00000000..2e1cb09d --- /dev/null +++ b/StgSharp.Common/Internal/Native.cs @@ -0,0 +1,48 @@ +//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// file="Native" +// 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.Internal +{ + internal static unsafe partial class Native + { + + internal const string LibName = + "StgSharp.Native"; + + internal const string LogPath = + "SS_error.log"; + + internal static IntPtr _libPtr = IntPtr.Zero; + + } +} diff --git a/StgSharp.Common/Internal/StructDefine.cs b/StgSharp.Common/Internal/StructDefine.cs index a23311dd..53fdd0fc 100644 --- a/StgSharp.Common/Internal/StructDefine.cs +++ b/StgSharp.Common/Internal/StructDefine.cs @@ -25,6 +25,7 @@ // // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- +using StgSharp.Graphics; using StgSharp.Graphics.OpenGL; using System; @@ -55,7 +56,7 @@ namespace StgSharp.Internal #region GLFW3 struct [StructLayout(LayoutKind.Sequential)] - public unsafe struct GLFWcontext + public unsafe struct glfwContext { private delegate* extensionSupported; @@ -286,8 +287,8 @@ namespace StgSharp.Internal private IntPtr cursor; // _GLFWcursor* cursor; // glfwVideomode videoMode; // 根据GLFWvidmode的定义转换 private IntPtr monitor; // _GLFWmonitor* monitor; - public fixed byte keys[glConst.GLFW_KEY_LAST + 1]; - public fixed byte mouseButtons[glConst.GLFW_MOUSE_BUTTON_LAST + 1]; + public fixed byte keys[Constant.GLFW_KEY_LAST + 1]; + public fixed byte mouseButtons[Constant.GLFW_MOUSE_BUTTON_LAST + 1]; // _GLFWcontext viewPortDisplay; // 根据_GLFWcontext的定义转换 @@ -496,8 +497,8 @@ namespace StgSharp.Internal internal unsafe struct GLFWlibrary { - [MarshalAs(UnmanagedType.ByValArray, SizeConst = glConst.GLFW_JOYSTICK_LAST + 1)] - private GLFWjoystick[] joysticks = new GLFWjoystick[glConst.GLFW_JOYSTICK_LAST + 1]; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = Constant.GLFW_JOYSTICK_LAST + 1)] + private GLFWjoystick[] joysticks = new GLFWjoystick[Constant.GLFW_JOYSTICK_LAST + 1]; private GLFWallocator allocator; diff --git a/StgSharp.Common/Internal/publicType.cs b/StgSharp.Common/Internal/public.cs similarity index 94% rename from StgSharp.Common/Internal/publicType.cs rename to StgSharp.Common/Internal/public.cs index 06820097..cc575130 100644 --- a/StgSharp.Common/Internal/publicType.cs +++ b/StgSharp.Common/Internal/public.cs @@ -1,6 +1,6 @@ //----------------------------------------------------------------------- // ----------------------------------------------------------------------- -// file="publicType" +// file="public" // Project: StgSharp // AuthorGroup: Nitload // Copyright (c) Nitload. All rights reserved. @@ -25,12 +25,11 @@ // // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- -using StgSharp.Graphics.OpenGL; - using System; using System.Collections.Generic; -using System.Runtime.InteropServices; +using System.Linq; using System.Text; +using System.Threading.Tasks; namespace StgSharp { @@ -44,4 +43,4 @@ namespace StgSharp InfoWarning, } -} +} \ No newline at end of file diff --git a/StgSharp.Common/MVVM/View/ViewBase.cs b/StgSharp.Common/MVVM/View/ViewBase.cs index 2570e8ef..65572c31 100644 --- a/StgSharp.Common/MVVM/View/ViewBase.cs +++ b/StgSharp.Common/MVVM/View/ViewBase.cs @@ -153,7 +153,7 @@ namespace StgSharp.MVVM [MethodImpl(MethodImplOptions.AggressiveInlining)] public KeyStatus GetKeyStatus(KeyboardKey key) { - return InternalIO.glfwGetKey(context.ViewPortHandle, (int)key); + return GraphicFramework.glfwGetKey(context.ViewPortHandle, (int)key); } public void InternalInitialize(string name, (int, int, int) cubeSize, [NotNull]ViewModelBase viewModelBinding) diff --git a/StgSharp.Common/MVVM/View/ViewResponder.cs b/StgSharp.Common/MVVM/View/ViewResponder.cs index 92aed7c9..c760e18c 100644 --- a/StgSharp.Common/MVVM/View/ViewResponder.cs +++ b/StgSharp.Common/MVVM/View/ViewResponder.cs @@ -116,7 +116,7 @@ namespace StgSharp.MVVM { foreach (KeyValuePair pair in keyCallbackIndex) { - if (InternalIO.glfwGetKey(_binding.ViewHandle, + if (GraphicFramework.glfwGetKey(_binding.ViewHandle, pair.Key.TargetKeyOrButtonID) == pair.Key.TriggeredStatus) { pair.Value(); } diff --git a/StgSharp.Common/MVVM/ViewModel/ShowViewPort.cs b/StgSharp.Common/MVVM/ViewModel/ShowViewPort.cs index 477dbe8d..f9d10b6d 100644 --- a/StgSharp.Common/MVVM/ViewModel/ShowViewPort.cs +++ b/StgSharp.Common/MVVM/ViewModel/ShowViewPort.cs @@ -61,7 +61,7 @@ namespace StgSharp.MVVM.ViewModel fpsCountingToken.TimeSpanRefreshed += CountFps; fpsCountingToken.MissTimeSpanRefreshed += CountFps; if (_nextView != _currentView) { - Interlocked.Exchange(ref _currentView, _nextView); + _ = Interlocked.Exchange(ref _currentView, _nextView); } Thread renderThread = new Thread((token) => { try @@ -70,7 +70,7 @@ namespace StgSharp.MVVM.ViewModel } catch (Exception ex) { - InternalIO.InternalWriteLog( + DefaultLog.InternalWriteLog( $"Critical error when rendering:\n" + $"{ex}", LogType.Error); ShouldClose = true; throw; @@ -84,9 +84,9 @@ namespace StgSharp.MVVM.ViewModel while (_closed) { if (_nextView != _currentView) { - Interlocked.Exchange(ref _currentView, _nextView); + _ = Interlocked.Exchange(ref _currentView, _nextView); } - InternalIO.glfwPollEvents(); + GraphicFramework.glfwPollEvents(); eventAwaitingToken.WaitNextSpan(); _closed = !ShouldClose; } @@ -115,7 +115,7 @@ namespace StgSharp.MVVM.ViewModel private unsafe void PrivateShow() { - if (0 == InternalIO.glfwWindowShouldClose(this.viewPortDisplay.ViewPortHandle)) + if (0 == GraphicFramework.glfwWindowShouldClose(this.viewPortDisplay.ViewPortHandle)) { CurrentView.Use(); RenderStream.PollEvents(); diff --git a/StgSharp.Common/MVVM/ViewModel/ViewModel.cs b/StgSharp.Common/MVVM/ViewModel/ViewModel.cs index 3ddc85e4..a31a3faa 100644 --- a/StgSharp.Common/MVVM/ViewModel/ViewModel.cs +++ b/StgSharp.Common/MVVM/ViewModel/ViewModel.cs @@ -45,8 +45,6 @@ using System.Runtime.InteropServices; using System.Text; using System.Threading; -using static StgSharp.Internal.InternalIO; - namespace StgSharp.MVVM.ViewModel { public abstract partial class ViewModelBase @@ -72,7 +70,7 @@ namespace StgSharp.MVVM.ViewModel _frameCount = 0; long frameLength = (FrameSpeed > 0) ? (1000L * 1000L / FrameSpeed) : 0; frameTimeProvider = new TimeSpanProvider(frameLength, TimeSpanProvider.DefaultProvider); - SetFrameSizeCallback(DefaultFrameRewsizeCallback); + SetFrameSizeCallback(DefaultFrameResizeCallback); } protected ViewModelBase(float frameLength) @@ -85,7 +83,7 @@ namespace StgSharp.MVVM.ViewModel long _frameLength = (FrameSpeed > 0) ? ((long)(1000 * frameLength)) : 0; frameTimeProvider = new TimeSpanProvider(_frameLength, TimeSpanProvider.DefaultProvider); - SetFrameSizeCallback(DefaultFrameRewsizeCallback); + SetFrameSizeCallback(DefaultFrameResizeCallback); } public ViewModelBase(ViewPort vBinding, int frameSpeed) @@ -97,7 +95,7 @@ namespace StgSharp.MVVM.ViewModel _frameCount = 0; long frameLength = (frameSpeed > 0) ? (1000L * 1000L / frameSpeed) : 0; frameTimeProvider = new TimeSpanProvider(frameLength, TimeSpanProvider.DefaultProvider); - SetFrameSizeCallback(DefaultFrameRewsizeCallback); + SetFrameSizeCallback(DefaultFrameResizeCallback); } public ViewModelBase(ViewPort vBinding, float frameLength) @@ -110,7 +108,7 @@ namespace StgSharp.MVVM.ViewModel long _frameLength = (frameLength > 0) ? ((long)(1000 * frameLength)) : 0; frameTimeProvider = new TimeSpanProvider(_frameLength, TimeSpanProvider.DefaultProvider); - SetFrameSizeCallback(DefaultFrameRewsizeCallback); + SetFrameSizeCallback(DefaultFrameResizeCallback); } public DataBindingEntry this[string name] @@ -126,8 +124,8 @@ namespace StgSharp.MVVM.ViewModel public bool ShouldClose { - get => InternalIO.glfwWindowShouldClose(viewPortDisplay.ViewPortHandle) != 0; - set => InternalIO.glfwSetWindowShouldClose( + get => GraphicFramework.glfwWindowShouldClose(viewPortDisplay.ViewPortHandle) != 0; + set => GraphicFramework.glfwSetWindowShouldClose( viewPortDisplay.ViewPortHandle, value ? 1 : 0); } @@ -195,7 +193,7 @@ namespace StgSharp.MVVM.ViewModel public void SetSizeLimit(Vec2 minSize, Vec2 maxSize) { ThreadHelper.MainThreadAssert(); - InternalIO.glfwSetWindowSizeLimits( + GraphicFramework.glfwSetWindowSizeLimits( this.viewPortDisplay.ViewPortHandle, (int)minSize.X, (int)minSize.Y, (int)maxSize.X, (int)maxSize.Y); } @@ -219,7 +217,7 @@ namespace StgSharp.MVVM.ViewModel public void SetSizeLimit(int minWidth, int minHeight, int maxWidth, int maxHeight) { ThreadHelper.MainThreadAssert(); - InternalIO.glfwSetWindowSizeLimits( + GraphicFramework.glfwSetWindowSizeLimits( this.viewPortDisplay.ViewPortHandle, minWidth, minHeight, maxWidth, maxHeight); } @@ -229,11 +227,11 @@ namespace StgSharp.MVVM.ViewModel { _resizeCallback = callback; IntPtr handlerPtr = Marshal.GetFunctionPointerForDelegate(callback); - InternalIO.glfwSetFrameBufferSizeCallback( - viewPortDisplay.ViewPortHandle, (delegate* unmanaged[Cdecl])handlerPtr); + _ = GraphicFramework.glfwSetFrameBufferSizeCallback( + viewPortDisplay.ViewPortHandle, (delegate* unmanaged[Cdecl])handlerPtr); } - private void DefaultFrameRewsizeCallback(IntPtr windowHandle, int width, int height) + private void DefaultFrameResizeCallback(IntPtr windowHandle, int width, int height) { ViewPort.GetExistedViewPort(windowHandle, out ViewPort vp); vp.RequestFlushSizeInNextFrame(width, height); diff --git a/StgSharp.Common/MVVM/ViewPort.cs b/StgSharp.Common/MVVM/ViewPort.cs index f166677e..2ab91dda 100644 --- a/StgSharp.Common/MVVM/ViewPort.cs +++ b/StgSharp.Common/MVVM/ViewPort.cs @@ -49,7 +49,7 @@ namespace StgSharp.MVVM Name = new StackFrame(1, false). GetMethod()!.DeclaringType!.Name; Monitor = IntPtr.Zero; - ViewPortHandle = InternalIO.glfwCreateWindow( + ViewPortHandle = GraphicFramework.glfwCreateWindow( _newWidth, _newHeight, Encoding.UTF8.GetBytes(Name), Monitor, IntPtr.Zero); if (ViewPortHandle == IntPtr.Zero) { throw new InvalidOperationException("Unable to create viewport handle."); @@ -64,7 +64,7 @@ namespace StgSharp.MVVM FlushSize(); Name = name; Monitor = monitor; - ViewPortHandle = InternalIO.glfwCreateWindow( + ViewPortHandle = GraphicFramework.glfwCreateWindow( _newWidth, _newHeight, Encoding.UTF8.GetBytes(Name), Monitor, IntPtr.Zero); if (ViewPortHandle == IntPtr.Zero) { throw new InvalidOperationException("Unable to create viewport handle."); diff --git a/StgSharp.Common/Mathematics/Graphic/Matrix44.cs b/StgSharp.Common/Mathematics/Graphic/Matrix44.cs index 0db3ef2c..e747948e 100644 --- a/StgSharp.Common/Mathematics/Graphic/Matrix44.cs +++ b/StgSharp.Common/Mathematics/Graphic/Matrix44.cs @@ -196,7 +196,7 @@ namespace StgSharp.Mathematics.Graphic { fixed (ColumnSet4* source = &mat, target = &transpose) { - InternalIO.Intrinsic.f32_transpose(source, target); + NativeIntrinsic.Intrinsic.f32_transpose(source, target); // InternalIO.Intrinsic.transpose44(source, target); } diff --git a/StgSharp.Common/Mathematics/Scalar/Factorial.cs b/StgSharp.Common/Mathematics/Scalar/Factorial.cs index df68247a..fdc3f233 100644 --- a/StgSharp.Common/Mathematics/Scalar/Factorial.cs +++ b/StgSharp.Common/Mathematics/Scalar/Factorial.cs @@ -26,10 +26,6 @@ // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace StgSharp.Mathematics { @@ -59,7 +55,7 @@ namespace StgSharp.Mathematics return factorialResult[n]; } if (n < 30) { - return InternalIO.Intrinsic.factorial_simd(n); + return NativeIntrinsic.Intrinsic.factorial_simd(n); } double dn = n, diff --git a/StgSharp.Common/State/IState.cs b/StgSharp.Common/State/IState.cs new file mode 100644 index 00000000..788c9995 --- /dev/null +++ b/StgSharp.Common/State/IState.cs @@ -0,0 +1,37 @@ +//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// file="IState" +// 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.State +{ + public interface IState { } +} diff --git a/StgSharp.Common/State/IStateMachine.cs b/StgSharp.Common/State/IStateMachine.cs new file mode 100644 index 00000000..5084cfec --- /dev/null +++ b/StgSharp.Common/State/IStateMachine.cs @@ -0,0 +1,46 @@ +//----------------------------------------------------------------------- +// ----------------------------------------------------------------------- +// file="IStateMachine" +// 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.State +{ + public interface IStateMachine where TState: IState + { + + TState CurrentState { get; set; } + + TState RootState { get; } + + void GotoNextState(TInput input); + + } +} diff --git a/StgSharp.Common/Stg/CollisionTexture.cs b/StgSharp.Common/Stg/CollisionTexture.cs index 11f3c4a2..d6241532 100644 --- a/StgSharp.Common/Stg/CollisionTexture.cs +++ b/StgSharp.Common/Stg/CollisionTexture.cs @@ -82,7 +82,7 @@ namespace StgSharp.Stg { IGeometry g = item.TypicalShape; - if (!(g is PlainGeometry)) { + if (g is not PlainGeometry) { throw new InvalidOperationException( "The current particle buffer contains non-planar geometry,"); } @@ -135,8 +135,8 @@ namespace StgSharp.Stg Shader vertexShader = CreateShaderSegment(ShaderType.Vertex, 1); Shader fragmentShader = CreateShaderSegment(ShaderType.Fragment, 1); - vertexShader.Compile(0, InternalIO.CollisionTextureVertexShader); - fragmentShader.Compile(0, InternalIO.CollisionTextureFragmentShader); + vertexShader.Compile(0, BuiltInShader.CollisionTextureVertexShader); + fragmentShader.Compile(0, BuiltInShader.CollisionTextureFragmentShader); vertexShader.AttachTo(0, generatingShader); fragmentShader.AttachTo(0, generatingShader); @@ -155,9 +155,9 @@ namespace StgSharp.Stg t = CreateTexture(1); t.Bind2D(0); - GL.TextureImage2d( - Texture2DTarget.Texture2D, 0, ImageChannel.WithAlphaChannel, (uint)Width, (uint)Height, - ImageChannel.WithAlphaChannel, PixelChannelLayout.Byte, Array.Empty()); + GL.TextureImage2d + (Texture2DTarget.Texture2D, 0, ImageChannel.WithAlphaChannel, (uint)Width, (uint)Height + , ImageChannel.WithAlphaChannel, PixelChannelLayout.Byte, Array.Empty()); t.Set2dWrapProperty(0, TextureWrap.Repeat, TextureWrap.Repeat); t.Set2dFilterProperty(0, TextureFilter.Nearest, TextureFilter.Nearest); diff --git a/StgSharp.Common/Timing/TimeProvider.cs b/StgSharp.Common/Timing/TimeProvider.cs index 84d0e813..cedae21c 100644 --- a/StgSharp.Common/Timing/TimeProvider.cs +++ b/StgSharp.Common/Timing/TimeProvider.cs @@ -131,7 +131,7 @@ namespace StgSharp if (!subscriber.CheckTime(totalMS)) { toRemoveList.Add(subscriber); - InternalIO.InternalWriteLog( + DefaultLog.InternalWriteLog( $"Time subscriber {subscriber} is to be removed.", LogType.Info); } ; diff --git a/StgSharp.Common/Timing/TimeSpanProvider.cs b/StgSharp.Common/Timing/TimeSpanProvider.cs index f41ba563..4eb4bfa2 100644 --- a/StgSharp.Common/Timing/TimeSpanProvider.cs +++ b/StgSharp.Common/Timing/TimeSpanProvider.cs @@ -189,13 +189,13 @@ namespace StgSharp.Timing return true; } foreach (TimeSpanAwaitingToken tokenAdd in _tokenToAdd) { - _awaitingTokens.Add(tokenAdd); + _ = _awaitingTokens.Add(tokenAdd); } _tokenToAdd.Clear(); foreach (TimeSpanAwaitingToken tokenQuit in _tokenToQuit) { - _awaitingTokens.Remove(tokenQuit); - InternalIO.InternalWriteLog( + _ = _awaitingTokens.Remove(tokenQuit); + DefaultLog.InternalWriteLog( $"Awaiting token {tokenQuit!.TokenID} has been removed.", LogType.Info); } _tokenToQuit.Clear(); diff --git a/StgSharp.Mathematics/Numeric/MatrixCompute.Basic.cs b/StgSharp.Mathematics/Numeric/MatrixCompute.Basic.cs index 6383713a..29fd591e 100644 --- a/StgSharp.Mathematics/Numeric/MatrixCompute.Basic.cs +++ b/StgSharp.Mathematics/Numeric/MatrixCompute.Basic.cs @@ -1,33 +1,32 @@ //----------------------------------------------------------------------- // ----------------------------------------------------------------------- -// file="Matrix.Basic.cs" +// file="MatrixCompute.Basic" // 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 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. +// 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 StgSharp.Internal; using System; using System.Collections.Generic; using System.Linq; @@ -40,20 +39,31 @@ namespace StgSharp.Mathematics.Numeric public static class MatrixCompute { - public static Matrix Add(Matrix left, Matrix right) + public static unsafe Matrix Add(Matrix left, Matrix right) { if (left.ColumnLength != right.ColumnLength || left.RowLength != right.RowLength) { throw new IndexOutOfRangeException("Matrix dimensions must agree."); } - MatrixParallel.LeadParallel(); - try + Matrix ans = Matrix.FromDefault(left.ColumnLength, left.RowLength); + if (left.KernelColumnLength * left.KernelRowLength <= 1024) { - throw new NotImplementedException(); - } - finally - { - MatrixParallel.EndParallel(); + MatrixParallelPool pool = MatrixParallel.LeadParallel(); + if (!pool.TryRentIndividualHandle(out MatrixParallelWrap.Handle? handle)) { } + MatrixSegmentEnumeration.Enumerator leftEnum = left.GetColumnEnumeration().GetEnumerator(); + MatrixSegmentEnumeration.Enumerator rightEnum = right.GetColumnEnumeration().GetEnumerator(); + MatrixSegmentEnumeration.Enumerator ansEnum = ans.GetColumnEnumeration().GetEnumerator(); + + for (int i = 0; i < left.KernelColumnLength; i++) + { + MatrixSegment.Enumerator leftColumEnum = leftEnum.Current.GetEnumerator(); + MatrixSegment.Enumerator rightColumEnum = rightEnum.Current.GetEnumerator(); + MatrixSegment.Enumerator ansColumEnum = ansEnum.Current.GetEnumerator(); + } + return ans; } + Stack taskGroup = MatrixParallel.PublicTask(left.GetColumnEnumeration(), right.GetColumnEnumeration(), ans.GetColumnEnumeration(), + (delegate**, MatrixKernel*, MatrixKernel*, void>)NativeIntrinsic.Intrinsic.f32_add); + return ans; } } diff --git a/StgSharp.Mathematics/Numeric/MatrixComputeModel.cs b/StgSharp.Mathematics/Numeric/MatrixComputeModel.cs index 86075ae0..99aaf6ab 100644 --- a/StgSharp.Mathematics/Numeric/MatrixComputeModel.cs +++ b/StgSharp.Mathematics/Numeric/MatrixComputeModel.cs @@ -42,25 +42,24 @@ namespace StgSharp.Mathematics.Numeric nint l = p->Left, r = p->Right, a = p->Result; long - // set beginning value to counters for primary offsets lCount = (long)p->LeftPrimOffset * p->LeftPrimStride, rCount = (long)p->RightPrimOffset * p->RightPrimStride, aCount = (long)p->ResultPrimOffset * p->ResultPrimStride, - pCount = int.Min(p->PrimCount, p->PrimColumnCountInTile + p->PrimTileOffset)/*count of tile may be too much*/, + pCount = int.Min(p->PrimCount, p->PrimCountInTile + p->PrimTileOffset) /*count of tile may be too much*/, //edge to reset counters lLimit = pCount - p->LeftPrimOffset, rLimit = pCount - p->RightPrimOffset, aLimit = pCount - p->ResultPrimOffset; delegate* unmanaged[Cdecl] op = (delegate* unmanaged[Cdecl])p->ComputeHandle; - for (long i = p->PrimTileOffset; i < pCount; i++) + for (long i = p->PrimTileOffset % pCount; i < pCount; i++) { // update primary counters // if reaches edge, reset to zero - lCount = i < lLimit ? lCount + p->LeftPrimOffset : 0; - rCount = i < rLimit ? rCount + p->RightPrimOffset : 0; - aCount = i < rLimit ? aCount + p->ResultPrimOffset : 0; + lCount = i < lLimit ? lCount + p->LeftPrimStride : 0; + rCount = i < rLimit ? rCount + p->RightPrimStride : 0; + aCount = i < rLimit ? aCount + p->ResultPrimStride : 0; // get kernel column pointers nint left = l + (nint)(lCount * eSize); @@ -70,16 +69,16 @@ namespace StgSharp.Mathematics.Numeric lc = (long)p->LeftSecOffset * p->LeftSecStride, rc = (long)p->RightSecOffset * p->RightSecStride, ac = (long)p->ResultSecOffset * p->ResultSecStride, - sCount = int.Min(p->SecCount, p->SecColumnCountInTile + p->SecTileOffset); + sCount = int.Min(p->SecCount, p->SecCountInTile * p->SecTileOffset); long ll = sCount - p->LeftSecOffset, rl = sCount - p->RightSecOffset, al = sCount - p->ResultSecOffset; - for (int j = p->SecTileOffset; j < sCount; j++) + for (long j = p->SecTileOffset % sCount; j < sCount; j++) { - lc = j < ll ? lc + p->LeftSecOffset : 0; - rc = j < rl ? rc + p->RightSecOffset : 0; - ac = j < al ? ac + p->ResultSecOffset : 0; + lc = j < ll ? lc + p->LeftSecStride : 0; + rc = j < rl ? rc + p->RightSecStride : 0; + ac = j < al ? ac + p->ResultSecStride : 0; op(left + (nint)lc, right + (nint)rc, ans + (nint)ac); } } @@ -88,42 +87,50 @@ namespace StgSharp.Mathematics.Numeric [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static unsafe void Compute_BinaryScalar(MatrixParallelTaskPackageNonGeneric* p) { + int eSize = p->ElementSize; + + // base pointer to matrix kernels nint l = p->Left, r = p->Right, a = p->Result; long - lCount = p->LeftPrimOffset * p->LeftPrimStride, - rCount = p->RightPrimOffset * p->RightPrimStride, - aCount = p->ResultPrimOffset * p->ResultPrimStride, - pCount = p->PrimCount; - long + + // set beginning value to counters for primary offsets + lCount = (long)p->LeftPrimOffset * p->LeftPrimStride, + rCount = (long)p->RightPrimOffset * p->RightPrimStride, + aCount = (long)p->ResultPrimOffset * p->ResultPrimStride, + pCount = int.Min(p->PrimCount, p->PrimCountInTile + p->PrimTileOffset) /*count of tile may be too much*/, + //edge to reset counters lLimit = pCount - p->LeftPrimOffset, rLimit = pCount - p->RightPrimOffset, aLimit = pCount - p->ResultPrimOffset; - delegate* unmanaged[Cdecl] op = - (delegate* unmanaged[Cdecl])p->ComputeHandle; - ScalarPacket* scalar = p->Scalar; - for (long i = 0; i < pCount; i++) + delegate* unmanaged[Cdecl] op = + (delegate* unmanaged[Cdecl])p->ComputeHandle; + for (long i = p->PrimTileOffset % pCount; i < pCount; i++) { - lCount = i < lLimit ? lCount + p->LeftPrimOffset : 0; - rCount = i < rLimit ? rCount + p->RightPrimOffset : 0; - aCount = i < rLimit ? aCount + p->ResultPrimOffset : 0; - nint - left = l + (nint)lCount, - right = r + (nint)rCount, - ans = a + (nint)aCount; + // update primary counters + // if reaches edge, reset to zero + lCount = i < lLimit ? lCount + p->LeftPrimStride : 0; + rCount = i < rLimit ? rCount + p->RightPrimStride : 0; + aCount = i < rLimit ? aCount + p->ResultPrimStride : 0; + + // get kernel column pointers + nint left = l + (nint)(lCount * eSize); + nint right = r + (nint)(rCount * eSize); + nint ans = a + (nint)(aCount * eSize); + long + lc = (long)p->LeftSecOffset * p->LeftSecStride, + rc = (long)p->RightSecOffset * p->RightSecStride, + ac = (long)p->ResultSecOffset * p->ResultSecStride, + sCount = int.Min(p->SecCount, p->SecCountInTile * p->SecTileOffset); long - lc = p->LeftSecOffset * p->LeftSecStride, - rc = p->RightSecOffset * p->RightSecStride, - ac = p->ResultSecOffset * p->ResultSecStride, - sCount = p->SecCount, ll = sCount - p->LeftSecOffset, rl = sCount - p->RightSecOffset, al = sCount - p->ResultSecOffset; - for (int j = 0; j < sCount; j++) + for (long j = p->SecTileOffset % sCount; j < sCount; j++) { - lc = j < ll ? lc + p->LeftSecOffset : 0; - rc = j < rl ? rc + p->RightSecOffset : 0; - ac = j < al ? ac + p->ResultSecOffset : 0; - op(left + (nint)lc, right + (nint)rc, ans + (nint)ac, scalar); + lc = j < ll ? lc + p->LeftSecStride : 0; + rc = j < rl ? rc + p->RightSecStride : 0; + ac = j < al ? ac + p->ResultSecStride : 0; + op(left + (nint)lc, right + (nint)rc, ans + (nint)ac, p->Scalar); } } } @@ -131,29 +138,43 @@ namespace StgSharp.Mathematics.Numeric [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static unsafe void Compute_Unary(MatrixParallelTaskPackageNonGeneric* p) { - nint s = p->Right, a = p->Result; - long rCount = p->RightPrimOffset * p->RightPrimStride, - aCount = p->ResultPrimOffset * p->ResultPrimStride, - pCount = p->PrimCount; - long rLimit = pCount - p->RightPrimOffset, - aLimit = pCount - p->ResultPrimOffset; - delegate* unmanaged[Cdecl] op = - (delegate* unmanaged[Cdecl])p->ComputeHandle; - for (long i = 0; i < pCount; i++) + int eSize = p->ElementSize; + + // base pointer to matrix kernels + nint r = p->Right, a = p->Result; + long + + // set beginning value to counters for primary offsets + rCount = (long)p->RightPrimOffset * p->RightPrimStride, + aCount = (long)p->ResultPrimOffset * p->ResultPrimStride, + pCount = int.Min(p->PrimCount, p->PrimCountInTile + p->PrimTileOffset) /*count of tile may be too much*/, + //edge to reset counters + rLimit = pCount - p->RightPrimOffset, + aLimit = pCount - p->ResultPrimOffset; + delegate* unmanaged[Cdecl] op = + (delegate* unmanaged[Cdecl])p->ComputeHandle; + for (long i = p->PrimTileOffset % pCount; i < pCount; i++) { - rCount = i < rLimit ? rCount + p->RightPrimOffset : 0; - aCount = i < rLimit ? aCount + p->ResultPrimOffset : 0; - nint source = s + (nint)rCount, ans = a + (nint)aCount; - long rc = p->RightSecOffset * p->RightSecStride, - ac = p->ResultSecOffset * p->ResultSecStride, - sCount = p->SecCount; - long rl = sCount - p->RightSecOffset, - al = sCount - p->ResultSecOffset; - for (int j = 0; j < sCount; j++) + // update primary counters + // if reaches edge, reset to zero + rCount = i < rLimit ? rCount + p->RightPrimStride : 0; + aCount = i < rLimit ? aCount + p->ResultPrimStride : 0; + + // get kernel column pointers + nint right = r + (nint)(rCount * eSize); + nint ans = a + (nint)(aCount * eSize); + long + rc = (long)p->RightSecOffset * p->RightSecStride, + ac = (long)p->ResultSecOffset * p->ResultSecStride, + sCount = int.Min(p->SecCount, p->SecCountInTile * p->SecTileOffset); + long + rl = sCount - p->RightSecOffset, + al = sCount - p->ResultSecOffset; + for (long j = p->SecTileOffset % sCount; j < sCount; j++) { - rc = j < rl ? rc + p->RightSecOffset : 0; - ac = j < al ? ac + p->ResultSecOffset : 0; - op(source + (nint)rc, ans + (nint)ac); + rc = j < rl ? rc + p->RightSecStride : 0; + ac = j < al ? ac + p->ResultSecStride : 0; + op(right + (nint)rc, ans + (nint)ac); } } } @@ -161,34 +182,46 @@ namespace StgSharp.Mathematics.Numeric [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static unsafe void Compute_UnaryScalar(MatrixParallelTaskPackageNonGeneric* p) { - nint s = p->Right, a = p->Result; - long rCount = p->RightPrimOffset * p->RightPrimStride, - aCount = p->ResultPrimOffset * p->ResultPrimStride, - pCount = p->PrimCount; - long rLimit = pCount - p->RightPrimOffset, - aLimit = pCount - p->ResultPrimOffset; - delegate* unmanaged[Cdecl] op = - (delegate* unmanaged[Cdecl])p->ComputeHandle; - ScalarPacket* scalar = p->Scalar; - for (long i = 0; i < pCount; i++) + int eSize = p->ElementSize; + + // base pointer to matrix kernels + nint r = p->Right, a = p->Result; + long + + // set beginning value to counters for primary offsets + rCount = (long)p->RightPrimOffset * p->RightPrimStride, + aCount = (long)p->ResultPrimOffset * p->ResultPrimStride, + pCount = int.Min(p->PrimCount, p->PrimCountInTile + p->PrimTileOffset) /*count of tile may be too much*/, + //edge to reset counters + rLimit = pCount - p->RightPrimOffset, + aLimit = pCount - p->ResultPrimOffset; + delegate* unmanaged[Cdecl] op = + (delegate* unmanaged[Cdecl])p->ComputeHandle; + for (long i = p->PrimTileOffset % pCount; i < pCount; i++) { - rCount = i < rLimit ? rCount + p->RightPrimOffset : 0; - aCount = i < rLimit ? aCount + p->ResultPrimOffset : 0; - nint source = s + (nint)rCount; - nint ans = a + (nint)aCount; - long rc = p->RightSecOffset * p->RightSecStride, - ac = p->ResultSecOffset * p->ResultSecStride, - sCount = p->SecCount; - long rl = sCount - p->RightSecOffset, - al = sCount - p->ResultSecOffset; - for (int j = 0; j < sCount; j++) + // update primary counters + // if reaches edge, reset to zero + rCount = i < rLimit ? rCount + p->RightPrimStride : 0; + aCount = i < rLimit ? aCount + p->ResultPrimStride : 0; + + // get kernel column pointers + nint right = r + (nint)(rCount * eSize); + nint ans = a + (nint)(aCount * eSize); + long + rc = (long)p->RightSecOffset * p->RightSecStride, + ac = (long)p->ResultSecOffset * p->ResultSecStride, + sCount = int.Min(p->SecCount, p->SecCountInTile * p->SecTileOffset); + long + rl = sCount - p->RightSecOffset, + al = sCount - p->ResultSecOffset; + for (long j = p->SecTileOffset % sCount; j < sCount; j++) { - rc = j < rl ? rc + p->RightSecOffset : 0; - ac = j < al ? ac + p->ResultSecOffset : 0; - op(source + (nint)rc, ans + (nint)ac, scalar); + rc = j < rl ? rc + p->RightSecStride : 0; + ac = j < al ? ac + p->ResultSecStride : 0; + op(right + (nint)rc, ans + (nint)ac, p->Scalar); } } } } -} +} \ No newline at end of file diff --git a/StgSharp.Mathematics/Numeric/MatrixParallel.Publish.cs b/StgSharp.Mathematics/Numeric/MatrixParallel.Publish.cs index 66000df8..be8d2684 100644 --- a/StgSharp.Mathematics/Numeric/MatrixParallel.Publish.cs +++ b/StgSharp.Mathematics/Numeric/MatrixParallel.Publish.cs @@ -40,10 +40,10 @@ namespace StgSharp.Mathematics.Numeric public static partial class MatrixParallel { - public static unsafe void PublicTask( - MatrixSegmentEnumeration source, - MatrixSegmentEnumeration ans, - delegate**, MatrixKernel*, MatrixKernel*, void> Operation) + public static unsafe Stack PublicTask( + MatrixSegmentEnumeration source, + MatrixSegmentEnumeration ans, + delegate**, MatrixKernel*, MatrixKernel*, void> Operation) where T: unmanaged, INumber { MatrixParallelTaskPackage* package = MatrixParallelFactory.CreateBaseTask(); @@ -63,14 +63,14 @@ namespace StgSharp.Mathematics.Numeric package->ElementSize = sizeof(T); package->ComputeMode = 1; // Unary - PublicTaskPrivate(package); + return PublicTaskPrivate(package); } - public static unsafe void PublicTask( - MatrixSegmentEnumeration left, - MatrixSegmentEnumeration right, - MatrixSegmentEnumeration ans, - delegate**, MatrixKernel*, MatrixKernel*, void> Operation) + public static unsafe Stack PublicTask( + MatrixSegmentEnumeration left, + MatrixSegmentEnumeration right, + MatrixSegmentEnumeration ans, + delegate**, MatrixKernel*, MatrixKernel*, void> Operation) where T: unmanaged, INumber { MatrixParallelTaskPackage* package = MatrixParallelFactory.CreateBaseTask(); @@ -95,15 +95,15 @@ namespace StgSharp.Mathematics.Numeric package->ElementSize = sizeof(T); package->ComputeMode = 3; // Binary - PublicTaskPrivate(package); + return PublicTaskPrivate(package); } // Unary with 1..8 scalars (each scalar is independent generic type) - public static unsafe void PublicTask( - MatrixSegmentEnumeration source, - MatrixSegmentEnumeration ans, - delegate**, MatrixKernel*, MatrixKernel*, void> Operation, - TScalar0 s0) + public static unsafe Stack PublicTask( + MatrixSegmentEnumeration source, + MatrixSegmentEnumeration ans, + delegate**, MatrixKernel*, MatrixKernel*, void> Operation, + TScalar0 s0) where T: unmanaged, INumber where TScalar0: unmanaged, INumber { @@ -127,15 +127,15 @@ namespace StgSharp.Mathematics.Numeric sp->Data(0) = s0; package->Scalar = sp; - PublicTaskPrivate(package); + return PublicTaskPrivate(package); } - public static unsafe void PublicTask( - MatrixSegmentEnumeration source, - MatrixSegmentEnumeration ans, - delegate**, MatrixKernel*, MatrixKernel*, void> Operation, - TScalar0 s0, - TScalar1 s1) + public static unsafe Stack PublicTask( + MatrixSegmentEnumeration source, + MatrixSegmentEnumeration ans, + delegate**, MatrixKernel*, MatrixKernel*, void> Operation, + TScalar0 s0, + TScalar1 s1) where T: unmanaged, INumber where TScalar0: unmanaged, INumber where TScalar1: unmanaged, INumber @@ -161,16 +161,16 @@ namespace StgSharp.Mathematics.Numeric sp->Data(0) = s0; sp->Data(1) = s1; package->Scalar = sp; - PublicTaskPrivate(package); + return PublicTaskPrivate(package); } // Binary with 1..8 scalars (each scalar is independent generic type) - public static unsafe void PublicTask( - MatrixSegmentEnumeration left, - MatrixSegmentEnumeration right, - MatrixSegmentEnumeration ans, - delegate**, MatrixKernel*, MatrixKernel*, void> Operation, - TScalar0 s0) + public static unsafe Stack PublicTask( + MatrixSegmentEnumeration left, + MatrixSegmentEnumeration right, + MatrixSegmentEnumeration ans, + delegate**, MatrixKernel*, MatrixKernel*, void> Operation, + TScalar0 s0) where T: unmanaged, INumber where TScalar0: unmanaged, INumber { @@ -199,16 +199,16 @@ namespace StgSharp.Mathematics.Numeric sp->Data(0) = s0; package->Scalar = sp; - PublicTaskPrivate(package); + return PublicTaskPrivate(package); } - public static unsafe void PublicTask( - MatrixSegmentEnumeration source, - MatrixSegmentEnumeration ans, - delegate**, MatrixKernel*, MatrixKernel*, void> Operation, - TScalar0 s0, - TScalar1 s1, - TScalar2 s2) + public static unsafe Stack PublicTask( + MatrixSegmentEnumeration source, + MatrixSegmentEnumeration ans, + delegate**, MatrixKernel*, MatrixKernel*, void> Operation, + TScalar0 s0, + TScalar1 s1, + TScalar2 s2) where T: unmanaged, INumber where TScalar0: unmanaged, INumber where TScalar1: unmanaged, INumber @@ -236,16 +236,16 @@ namespace StgSharp.Mathematics.Numeric sp->Data(1) = s1; sp->Data(2) = s2; package->Scalar = sp; - PublicTaskPrivate(package); + return PublicTaskPrivate(package); } - public static unsafe void PublicTask( - MatrixSegmentEnumeration left, - MatrixSegmentEnumeration right, - MatrixSegmentEnumeration ans, - delegate**, MatrixKernel*, MatrixKernel*, void> Operation, - TScalar0 s0, - TScalar1 s1) + public static unsafe Stack PublicTask( + MatrixSegmentEnumeration left, + MatrixSegmentEnumeration right, + MatrixSegmentEnumeration ans, + delegate**, MatrixKernel*, MatrixKernel*, void> Operation, + TScalar0 s0, + TScalar1 s1) where T: unmanaged, INumber where TScalar0: unmanaged, INumber where TScalar1: unmanaged, INumber @@ -276,17 +276,17 @@ namespace StgSharp.Mathematics.Numeric sp->Data(0) = s0; sp->Data(1) = s1; package->Scalar = sp; - PublicTaskPrivate(package); + return PublicTaskPrivate(package); } - public static unsafe void PublicTask( - MatrixSegmentEnumeration source, - MatrixSegmentEnumeration ans, - delegate**, MatrixKernel*, MatrixKernel*, void> Operation, - TScalar0 s0, - TScalar1 s1, - TScalar2 s2, - TScalar3 s3) + public static unsafe Stack PublicTask( + MatrixSegmentEnumeration source, + MatrixSegmentEnumeration ans, + delegate**, MatrixKernel*, MatrixKernel*, void> Operation, + TScalar0 s0, + TScalar1 s1, + TScalar2 s2, + TScalar3 s3) where T: unmanaged, INumber where TScalar0: unmanaged, INumber where TScalar1: unmanaged, INumber @@ -316,17 +316,17 @@ namespace StgSharp.Mathematics.Numeric sp->Data(2) = s2; sp->Data(3) = s3; package->Scalar = sp; - PublicTaskPrivate(package); + return PublicTaskPrivate(package); } - public static unsafe void PublicTask( - MatrixSegmentEnumeration left, - MatrixSegmentEnumeration right, - MatrixSegmentEnumeration ans, - delegate**, MatrixKernel*, MatrixKernel*, void> Operation, - TScalar0 s0, - TScalar1 s1, - TScalar2 s2) + public static unsafe Stack PublicTask( + MatrixSegmentEnumeration left, + MatrixSegmentEnumeration right, + MatrixSegmentEnumeration ans, + delegate**, MatrixKernel*, MatrixKernel*, void> Operation, + TScalar0 s0, + TScalar1 s1, + TScalar2 s2) where T: unmanaged, INumber where TScalar0: unmanaged, INumber where TScalar1: unmanaged, INumber @@ -359,18 +359,18 @@ namespace StgSharp.Mathematics.Numeric sp->Data(1) = s1; sp->Data(2) = s2; package->Scalar = sp; - PublicTaskPrivate(package); + return PublicTaskPrivate(package); } - public static unsafe void PublicTask( - MatrixSegmentEnumeration source, - MatrixSegmentEnumeration ans, - delegate**, MatrixKernel*, MatrixKernel*, void> Operation, - TScalar0 s0, - TScalar1 s1, - TScalar2 s2, - TScalar3 s3, - TScalar4 s4) + public static unsafe Stack PublicTask( + MatrixSegmentEnumeration source, + MatrixSegmentEnumeration ans, + delegate**, MatrixKernel*, MatrixKernel*, void> Operation, + TScalar0 s0, + TScalar1 s1, + TScalar2 s2, + TScalar3 s3, + TScalar4 s4) where T: unmanaged, INumber where TScalar0: unmanaged, INumber where TScalar1: unmanaged, INumber @@ -402,18 +402,18 @@ namespace StgSharp.Mathematics.Numeric sp->Data(3) = s3; sp->Data(4) = s4; package->Scalar = sp; - PublicTaskPrivate(package); + return PublicTaskPrivate(package); } - public static unsafe void PublicTask( - MatrixSegmentEnumeration left, - MatrixSegmentEnumeration right, - MatrixSegmentEnumeration ans, - delegate**, MatrixKernel*, MatrixKernel*, void> Operation, - TScalar0 s0, - TScalar1 s1, - TScalar2 s2, - TScalar3 s3) + public static unsafe Stack PublicTask( + MatrixSegmentEnumeration left, + MatrixSegmentEnumeration right, + MatrixSegmentEnumeration ans, + delegate**, MatrixKernel*, MatrixKernel*, void> Operation, + TScalar0 s0, + TScalar1 s1, + TScalar2 s2, + TScalar3 s3) where T: unmanaged, INumber where TScalar0: unmanaged, INumber where TScalar1: unmanaged, INumber @@ -448,19 +448,19 @@ namespace StgSharp.Mathematics.Numeric sp->Data(2) = s2; sp->Data(3) = s3; package->Scalar = sp; - PublicTaskPrivate(package); + return PublicTaskPrivate(package); } - public static unsafe void PublicTask( - MatrixSegmentEnumeration source, - MatrixSegmentEnumeration ans, - delegate**, MatrixKernel*, MatrixKernel*, void> Operation, - TScalar0 s0, - TScalar1 s1, - TScalar2 s2, - TScalar3 s3, - TScalar4 s4, - TScalar5 s5) + public static unsafe Stack PublicTask( + MatrixSegmentEnumeration source, + MatrixSegmentEnumeration ans, + delegate**, MatrixKernel*, MatrixKernel*, void> Operation, + TScalar0 s0, + TScalar1 s1, + TScalar2 s2, + TScalar3 s3, + TScalar4 s4, + TScalar5 s5) where T: unmanaged, INumber where TScalar0: unmanaged, INumber where TScalar1: unmanaged, INumber @@ -494,19 +494,19 @@ namespace StgSharp.Mathematics.Numeric sp->Data(4) = s4; sp->Data(5) = s5; package->Scalar = sp; - PublicTaskPrivate(package); + return PublicTaskPrivate(package); } - public static unsafe void PublicTask( - MatrixSegmentEnumeration left, - MatrixSegmentEnumeration right, - MatrixSegmentEnumeration ans, - delegate**, MatrixKernel*, MatrixKernel*, void> Operation, - TScalar0 s0, - TScalar1 s1, - TScalar2 s2, - TScalar3 s3, - TScalar4 s4) + public static unsafe Stack PublicTask( + MatrixSegmentEnumeration left, + MatrixSegmentEnumeration right, + MatrixSegmentEnumeration ans, + delegate**, MatrixKernel*, MatrixKernel*, void> Operation, + TScalar0 s0, + TScalar1 s1, + TScalar2 s2, + TScalar3 s3, + TScalar4 s4) where T: unmanaged, INumber where TScalar0: unmanaged, INumber where TScalar1: unmanaged, INumber @@ -543,20 +543,20 @@ namespace StgSharp.Mathematics.Numeric sp->Data(3) = s3; sp->Data(4) = s4; package->Scalar = sp; - PublicTaskPrivate(package); + return PublicTaskPrivate(package); } - public static unsafe void PublicTask( - MatrixSegmentEnumeration source, - MatrixSegmentEnumeration ans, - delegate**, MatrixKernel*, MatrixKernel*, void> Operation, - TScalar0 s0, - TScalar1 s1, - TScalar2 s2, - TScalar3 s3, - TScalar4 s4, - TScalar5 s5, - TScalar6 s6) + public static unsafe Stack PublicTask( + MatrixSegmentEnumeration source, + MatrixSegmentEnumeration ans, + delegate**, MatrixKernel*, MatrixKernel*, void> Operation, + TScalar0 s0, + TScalar1 s1, + TScalar2 s2, + TScalar3 s3, + TScalar4 s4, + TScalar5 s5, + TScalar6 s6) where T: unmanaged, INumber where TScalar0: unmanaged, INumber where TScalar1: unmanaged, INumber @@ -592,20 +592,20 @@ namespace StgSharp.Mathematics.Numeric sp->Data(5) = s5; sp->Data(6) = s6; package->Scalar = sp; - PublicTaskPrivate(package); + return PublicTaskPrivate(package); } - public static unsafe void PublicTask( - MatrixSegmentEnumeration left, - MatrixSegmentEnumeration right, - MatrixSegmentEnumeration ans, - delegate**, MatrixKernel*, MatrixKernel*, void> Operation, - TScalar0 s0, - TScalar1 s1, - TScalar2 s2, - TScalar3 s3, - TScalar4 s4, - TScalar5 s5) + public static unsafe Stack PublicTask( + MatrixSegmentEnumeration left, + MatrixSegmentEnumeration right, + MatrixSegmentEnumeration ans, + delegate**, MatrixKernel*, MatrixKernel*, void> Operation, + TScalar0 s0, + TScalar1 s1, + TScalar2 s2, + TScalar3 s3, + TScalar4 s4, + TScalar5 s5) where T: unmanaged, INumber where TScalar0: unmanaged, INumber where TScalar1: unmanaged, INumber @@ -644,21 +644,21 @@ namespace StgSharp.Mathematics.Numeric sp->Data(4) = s4; sp->Data(5) = s5; package->Scalar = sp; - PublicTaskPrivate(package); + return PublicTaskPrivate(package); } - public static unsafe void PublicTask( - MatrixSegmentEnumeration source, - MatrixSegmentEnumeration ans, - delegate**, MatrixKernel*, MatrixKernel*, void> Operation, - TScalar0 s0, - TScalar1 s1, - TScalar2 s2, - TScalar3 s3, - TScalar4 s4, - TScalar5 s5, - TScalar6 s6, - TScalar7 s7) + public static unsafe Stack PublicTask( + MatrixSegmentEnumeration source, + MatrixSegmentEnumeration ans, + delegate**, MatrixKernel*, MatrixKernel*, void> Operation, + TScalar0 s0, + TScalar1 s1, + TScalar2 s2, + TScalar3 s3, + TScalar4 s4, + TScalar5 s5, + TScalar6 s6, + TScalar7 s7) where T: unmanaged, INumber where TScalar0: unmanaged, INumber where TScalar1: unmanaged, INumber @@ -696,21 +696,21 @@ namespace StgSharp.Mathematics.Numeric sp->Data(6) = s6; sp->Data(7) = s7; package->Scalar = sp; - PublicTaskPrivate(package); + return PublicTaskPrivate(package); } - public static unsafe void PublicTask( - MatrixSegmentEnumeration left, - MatrixSegmentEnumeration right, - MatrixSegmentEnumeration ans, - delegate**, MatrixKernel*, MatrixKernel*, void> Operation, - TScalar0 s0, - TScalar1 s1, - TScalar2 s2, - TScalar3 s3, - TScalar4 s4, - TScalar5 s5, - TScalar6 s6) + public static unsafe Stack PublicTask( + MatrixSegmentEnumeration left, + MatrixSegmentEnumeration right, + MatrixSegmentEnumeration ans, + delegate**, MatrixKernel*, MatrixKernel*, void> Operation, + TScalar0 s0, + TScalar1 s1, + TScalar2 s2, + TScalar3 s3, + TScalar4 s4, + TScalar5 s5, + TScalar6 s6) where T: unmanaged, INumber where TScalar0: unmanaged, INumber where TScalar1: unmanaged, INumber @@ -751,22 +751,22 @@ namespace StgSharp.Mathematics.Numeric sp->Data(5) = s5; sp->Data(6) = s6; package->Scalar = sp; - PublicTaskPrivate(package); + return PublicTaskPrivate(package); } - public static unsafe void PublicTask( - MatrixSegmentEnumeration left, - MatrixSegmentEnumeration right, - MatrixSegmentEnumeration ans, - delegate**, MatrixKernel*, MatrixKernel*, void> Operation, - TScalar0 s0, - TScalar1 s1, - TScalar2 s2, - TScalar3 s3, - TScalar4 s4, - TScalar5 s5, - TScalar6 s6, - TScalar7 s7) + public static unsafe Stack PublicTask( + MatrixSegmentEnumeration left, + MatrixSegmentEnumeration right, + MatrixSegmentEnumeration ans, + delegate**, MatrixKernel*, MatrixKernel*, void> Operation, + TScalar0 s0, + TScalar1 s1, + TScalar2 s2, + TScalar3 s3, + TScalar4 s4, + TScalar5 s5, + TScalar6 s6, + TScalar7 s7) where T: unmanaged, INumber where TScalar0: unmanaged, INumber where TScalar1: unmanaged, INumber @@ -809,7 +809,7 @@ namespace StgSharp.Mathematics.Numeric sp->Data(6) = s6; sp->Data(7) = s7; package->Scalar = sp; - PublicTaskPrivate(package); + return PublicTaskPrivate(package); } private static unsafe Stack PublicTaskPrivate(MatrixParallelTaskPackage* package) @@ -860,7 +860,7 @@ namespace StgSharp.Mathematics.Numeric // update current task current->PrimColumnCountInTile = columnInWrap; current->SecColumnCountInTile = current->SecCount; - current->SecTileBegin = 0; + current->SecTileOffset = 0; // remove tiles count extraColumnCount--; @@ -877,7 +877,7 @@ namespace StgSharp.Mathematics.Numeric break; } current = MatrixParallelFactory.FromExistPackage(current); - current->PrimTileBegin += columnInWrap; + current->PrimTileOffset += columnInWrap; } ReleaseParallelLeadership(ref pool); diff --git a/StgSharp.Mathematics/Numeric/MatrixParallelTask.cs b/StgSharp.Mathematics/Numeric/MatrixParallelTask.cs index 19318215..0addf485 100644 --- a/StgSharp.Mathematics/Numeric/MatrixParallelTask.cs +++ b/StgSharp.Mathematics/Numeric/MatrixParallelTask.cs @@ -116,10 +116,10 @@ namespace StgSharp.Mathematics.Numeric #region count offset - public readonly int PrimTileOffset; // 4 - public readonly int SecTileOffset; // 4 - public readonly int PrimColumnCountInTile; // 4 - public readonly int SecColumnCountInTile; // 4 + public readonly int PrimTileOffset; // 4 + public readonly int SecTileOffset; // 4 + public readonly int PrimCountInTile; // 4 + public readonly int SecCountInTile; // 4 #endregion } @@ -205,8 +205,8 @@ namespace StgSharp.Mathematics.Numeric #region count offset - public int PrimTileBegin; // 4 - public int SecTileBegin; // 4 + public int PrimTileOffset; // 4 + public int SecTileOffset; // 4 public int PrimColumnCountInTile; // 4 public int SecColumnCountInTile; // 4