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
+33 -12
View File
@@ -1,9 +1,10 @@
using StgSharp.Control;
using StgSharp.Controlling;
using StgSharp.Graphics;
using StgSharp.Math;
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
namespace StgSharp
@@ -21,22 +22,24 @@ namespace StgSharp
/// <param name="share"></param>
/// <returns>The instance of created form</returns>
/// <exception cref="Exception"></exception>
public static unsafe Form GLcreateWindow(int width, int height, byte[] tittle, IntPtr monitor, Form share)
public static unsafe Form GLcreateWindow(
int width, int height, string tittle, IntPtr monitor, Form share)
{
byte[] tittleBytes = Encoding.UTF8.GetBytes(tittle);
IntPtr windowPtr;
if (share == null)
{
windowPtr = glIO.internalGLcreateWindow(
width, height, tittle, monitor, (IntPtr)0);
windowPtr = internalIO.glfwCreateWindow(
800, 600, tittleBytes, monitor, IntPtr.Zero);
}
else
{
windowPtr = glIO.internalGLcreateWindow(
width, height, tittle, monitor, (IntPtr)share.windowID);
windowPtr = internalIO.glfwCreateWindow(
width, height, tittleBytes, monitor, share.windowID);
}
if ((int)windowPtr == -1 || (int)windowPtr == -2)
if ((long)windowPtr == -1 || (long)windowPtr == -2)
{
throw new Exception("Cannot create window instance!");
}
@@ -44,7 +47,7 @@ namespace StgSharp
{
Form form = new Form();
form.Size = new Vec2d(width, height);
form.windowID = (long)windowPtr;
form.windowID = windowPtr;
return form;
}
}
@@ -62,7 +65,7 @@ namespace StgSharp
public static unsafe Form GLcreateWindow(int width, int height, string tittle, IntPtr monitor, IntPtr share)
{
byte[] tittleCharArray = System.Text.Encoding.UTF8.GetBytes(tittle);
long windowPtr = (long)glIO.internalGLcreateWindow
IntPtr windowPtr = internalIO.glfwCreateWindow
(width, height, tittleCharArray, monitor, share);
if ((int)windowPtr == -1 || (int)windowPtr == -2)
@@ -81,20 +84,38 @@ namespace StgSharp
public static unsafe void GLmakeContexCurrent(Form form)
{
glIO.internalGLmakeContextCurrent((IntPtr)form.windowID);
internalIO.glfwMakeContextCurrent(form.windowID);
}
public static unsafe bool GLwindowShouldClose(Form form)
{
int a = glIO.internalGLwindowShouldClose((IntPtr)form.windowID);
int a = internalIO.glfwWindowShouldClose(form.windowID);
return a != 0;
}
public static unsafe void GLswapBuffers(Form form)
{
glIO.internalGLswapBuffers((IntPtr)form.windowID);
internalIO.glfwSwapBuffers(form.windowID);
}
public static IntPtr GetProcAddress(string name)
{
IntPtr ret = internalIO.glfwGetProcAddress(name);
if (ret == IntPtr.Zero)
{
#if DEBUG
Console.WriteLine(name);
#endif
return (IntPtr)0b1111111111;
}
else
{
return ret;
}
}
}