bug of overflow due to IntPtr solved

This commit is contained in:
Nitload
2023-07-03 05:16:51 +08:00
parent 04b166771c
commit 2a78a60358
27 changed files with 58 additions and 66 deletions
+37 -29
View File
@@ -8,16 +8,8 @@ namespace StgSharp
{
internal static GraphicIOPack glIO;
private static bool isGLSet = false;
/// <summary>
/// Init an instance of OpenGL program,
/// This method should be called before other
/// graphic methods, after LoadGL method.
/// </summary>
public static void InitGL()
{
internalIO.InternalInitGL();
}
private static bool isGLADset = false;
private static bool isGLready = false;
/// <summary>
/// Load OpenGL API to StgSharp core programm,
@@ -27,7 +19,7 @@ namespace StgSharp
/// <exception cref="Exception">If run this method twice, will throw exception</exception>
public static unsafe void LoadGL()
{
if (!isGLSet)
if (!isGLADset)
{
glIO = internalIO.InternalInitGraphicApi();
}
@@ -37,6 +29,27 @@ namespace StgSharp
}
}
/// <summary>
/// Init an instance of OpenGL program,
/// This method should be called before other
/// graphic methods, after LoadGL method.
/// </summary>
public static void InitGL()
{
if (!isGLSet)
{
internalIO.InternalInitGL();
isGLready = isGLSet && isGLADset;
}
else
{
throw new Exception("Do not init GL twice");
}
}
/// <summary>
/// Attach GLFW API to GLAD,
/// this method should be called after LoadGL
@@ -45,32 +58,27 @@ namespace StgSharp
/// <exception cref="Exception">The accident that program cannot attach GLFW to GLAD</exception>
public static unsafe void InitGLAD()
{
int a = internalIO.InternalInitGLAD();
if (a!=0)
if (!isGLADset)
{
throw new Exception("Cannot attach GLFW to GLAD!");
int a = internalIO.InternalInitGLAD();
if (a != 0)
{
throw new Exception("Cannot attach GLFW to GLAD!");
}
else
{
isGLready = isGLSet && isGLADset;
return;
}
}
else
{
return;
throw new Exception("Do not init GLAD twice.");
}
}
internal static byte[] loadShaderCodeStr(string str)
{
byte[] cahrStr;
try
{
cahrStr = System.Text.Encoding.ASCII.GetBytes(str);
return cahrStr;
}
catch (Exception)
{
throw;
}
}