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

This commit is contained in:
Youmu Liu
2025-11-11 18:22:28 +08:00
parent 678a846e54
commit 44bf78b937
65 changed files with 1328 additions and 1814 deletions
+15 -1
View File
@@ -32,10 +32,23 @@ using System.Text;
namespace StgSharp.Internal
{
public class GraphicModule : IStaticModule
{
public string ModuleName => "Graphic";
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void InitializeModule()
{
GraphicFramework.LoadGlfw();
}
}
internal static unsafe partial class GraphicFramework
{
private static readonly GLFWFunction _glfw = new GLFWFunction();
private static GLFWFunction _glfw ;
public static GLFWFunction glfwContext => _glfw;
@@ -44,6 +57,7 @@ namespace StgSharp.Internal
internal static unsafe void LoadGlfw()
{
_glfw = new GLFWFunction();
fixed (GLFWFunction* func = &_glfw) {
glfwLoadLibrary(func);
}
+4 -4
View File
@@ -287,8 +287,8 @@ namespace StgSharp.Internal
private IntPtr cursor; // _GLFWcursor* cursor;
// glfwVideomode videoMode; // 根据GLFWvidmode的定义转换
private IntPtr monitor; // _GLFWmonitor* monitor;
public fixed byte keys[Constant.GLFW_KEY_LAST + 1];
public fixed byte mouseButtons[Constant.GLFW_MOUSE_BUTTON_LAST + 1];
public fixed byte keys[FrameworkConstant.GLFW_KEY_LAST + 1];
public fixed byte mouseButtons[FrameworkConstant.GLFW_MOUSE_BUTTON_LAST + 1];
// _GLFWcontext viewPortDisplay; // 根据_GLFWcontext的定义转换
@@ -497,8 +497,8 @@ namespace StgSharp.Internal
internal unsafe struct GLFWlibrary
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = Constant.GLFW_JOYSTICK_LAST + 1)]
private GLFWjoystick[] joysticks = new GLFWjoystick[Constant.GLFW_JOYSTICK_LAST + 1];
[MarshalAs(UnmanagedType.ByValArray, SizeConst = FrameworkConstant.GLFW_JOYSTICK_LAST + 1)]
private GLFWjoystick[] joysticks = new GLFWjoystick[FrameworkConstant.GLFW_JOYSTICK_LAST + 1];
private GLFWallocator allocator;