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
+15 -16
View File
@@ -32,7 +32,7 @@ namespace StgSharp
else
{
windowPtr = glIO.internalGLcreateWindow(
width, height, tittle, monitor, (IntPtr)share.windowPtr);
width, height, tittle, monitor, (IntPtr)share.windowID);
}
@@ -44,7 +44,7 @@ namespace StgSharp
{
Form form = new Form();
form.Size = new vec2d(width, height);
form.windowPtr = windowPtr;
form.windowID = (long)windowPtr;
return form;
}
}
@@ -61,41 +61,40 @@ namespace StgSharp
/// <exception cref="Exception"></exception>
public static unsafe Form GLcreateWindow(int width, int height, string tittle, IntPtr monitor, IntPtr share)
{
Form form = new Form();
form.Size = new vec2d(width, height);
byte[] tittleCharArray = System.Text.Encoding.UTF8.GetBytes(tittle);
IntPtr windowPtr = glIO.internalGLcreateWindow(width, height, tittleCharArray, monitor, share);
form.info.name = tittleCharArray;
form.windowPtr = windowPtr;
Console.WriteLine(windowPtr);
long windowPtr = (long)glIO.internalGLcreateWindow
(width, height, tittleCharArray, monitor, share);
if ((int)windowPtr == -1 || (int)windowPtr == -2)
{
throw new Exception("Cannot create window instance!");
throw new Exception("Cannot create the form!");
}
else
{
Form form = new Form();
form.Size = new vec2d(width, height);
form.windowID = windowPtr;
return form;
}
return form;
}
public static unsafe void GLmakeContexCurrent(Form form)
{
glIO.internalGLmakeContextCurrent((IntPtr)form.windowPtr);
glIO.internalGLmakeContextCurrent((IntPtr)form.windowID);
}
public static unsafe bool GLwindowShouldClose(Form form)
{
int a = glIO.internalGLwindowShouldClose((IntPtr)form.windowPtr);
int a = glIO.internalGLwindowShouldClose((IntPtr)form.windowID);
return a != 0;
}
public static unsafe void GLswapBuffers(Form form)
{
glIO.internalGLswapBuffers((IntPtr)form.windowPtr);
glIO.internalGLswapBuffers((IntPtr)form.windowID);
}
}