daily update on 20230911 by nitload youmu, uncertain bug of gl api loading

This commit is contained in:
Nitload
2023-09-11 23:34:34 +08:00
parent c6f4b3dd53
commit 5d701bce0c
172 changed files with 15161 additions and 9614 deletions
+12 -26
View File
@@ -1,33 +1,16 @@
using StgSharp.Control;
using StgSharp.Controlling;
using StgSharp.Graphics;
using System;
using System.Runtime.InteropServices;
namespace StgSharp
{
public static unsafe partial class Graphic
{
internal static GraphicIOPack glIO;
private static bool isGLSet = false;
private static bool isGLADset = false;
private static bool isGLready = false;
/// <summary>
/// Load OpenGL API to StgSharp core programm,
/// please call this method before call any other
/// graphic APIs in StgSharp.
/// </summary>
/// <exception cref="Exception">If run this method twice, will throw exception</exception>
public static unsafe void LoadGL()
{
if (!isGLADset)
{
glIO = internalIO.InternalInitGraphicApi();
}
else
{
throw new Exception("Do not load GL api twice.");
}
}
/// <summary>
@@ -35,11 +18,11 @@ namespace StgSharp
/// This method should be called before other
/// graphic methods, after LoadGL method.
/// </summary>
public static void InitGL()
public static void InitGL(int majorVersion, int minorVersion)
{
if (!isGLSet)
{
internalIO.InternalInitGL();
internalIO.InternalInitGL(majorVersion, minorVersion);
isGLready = isGLSet && isGLADset;
}
else
@@ -48,7 +31,7 @@ namespace StgSharp
}
}
/// <summary>
/// Attach GLFW API to GLAD,
@@ -56,19 +39,22 @@ namespace StgSharp
/// and before other graphic method.
/// </summary>
/// <exception cref="Exception">The accident that program cannot attach GLFW to GLAD</exception>
public static unsafe void InitGLAD()
public static unsafe void InitGLAD(glLoader loader)
{
if (!isGLADset)
{
int a = internalIO.InternalInitGLAD();
if (a != 0)
if (a == 0)
{
throw new Exception("Cannot attach GLFW to GLAD!");
}
else
{
isGLready = isGLSet && isGLADset;
LoadGLLoader(loader);
return;
}
}
@@ -110,7 +96,7 @@ namespace StgSharp
*/
}
}