daily update on 20240209 by nitload youmu

This commit is contained in:
Nitload
2024-02-09 23:31:33 +08:00
parent 6fe6b3b3cf
commit 8391569482
159 changed files with 948 additions and 2431 deletions
@@ -34,53 +34,9 @@ namespace StgSharp
/// This method should be called before other
/// graphic methods, after LoadGL method.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void InitGL(int majorVersion, int minorVersion)
{
if (InternalIO.glfw == null)
{
try
{
InternalIO.glfw = new glFramework_PInvoke();
InternalIO.glfw.Init();
InternalIO.InternalWriteLog("Successfully load GLFW APIs. StgSharp is now working on p/invoke mode", LogType.Info);
}
catch (Exception sig)
{
string log = $"Failed to load GLFW APIs by P/Invoke," +
$"StgSharp will switch to delegate mode. The detailed info is:\n" +
$"{sig.Message}\n";
if (InternalIO.SSClibPtr == default)
{
InternalIO.SSClibPtr =
InternalIO.InternalLoadWINlib(InternalIO.SSC_libname + ".dll");
}
InternalIO.glfw = new glFramework_Delegate();
InternalIO.SSClibPtr = InternalIO.InternalLoadWINlib(InternalIO.SSC_libname);
FieldInfo[] glfwApis = typeof(glFramework_Delegate).GetFields();
foreach (FieldInfo item in glfwApis)
{
if (item.FieldType.BaseType == typeof(Delegate))
{
try
{
IntPtr funcptr = InternalIO.InternalGetWINproc(
InternalIO.SSClibPtr, item.Name);
item.SetValue(null, ConvertAPI(funcptr, item.FieldType));
log += $"Successfully load GLFW API called {item.Name}";
}
catch (Exception ex)
{
log += $"Failed to load GLFW API called {item.Name}, the detailed info is\n" +
$"{ex.Message}";
continue;
}
}
}
InternalIO.InternalWriteLog(log, LogType.Warning);
}
}
InternalIO.InternalInitGL(majorVersion, minorVersion);
}