daily update on 20231111 by nitload youmu

This commit is contained in:
Nitload
2023-11-11 17:12:37 +08:00
parent 26c7dafc2c
commit dac5f2455b
98 changed files with 10065 additions and 6029 deletions
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -113,8 +113,8 @@ namespace StgSharp.Graphics
glContext = (GLcontext*)ptr;
}
InternalIO.glfw.MakeContextCurrent(windowID);
GL.gl = glContext;
InternalIO.InternalSetCurrentGLContext(windowID, glContext);
}
/// <summary>
@@ -41,8 +41,9 @@ namespace StgSharp.Graphics
log = log.Replace("\0", "");
InternalIO.InternalWriteLog(log, LogType.Error);
}
catch (Exception)
catch (Exception ex)
{
InternalIO.InternalWriteLog(ex.Message, LogType.Error);
}
}
}
+2 -12
View File
@@ -48,15 +48,11 @@ namespace StgSharp.Graphics
/// <param name="shaderType">An <see cref="ShaderType"/> enum represent the type of the shader to
/// conpile, including vertex shader and fragment shader.</param>
/// <returns>An uint value as the only mark of conpiled shader</returns>
public static unsafe uint CompileShader(string shaderCode, ShaderType shaderType)
public static uint CompileShader(string shaderCode, ShaderType shaderType)
{
uint shaderID;
shaderCode += '\0';
byte[] buffer = Encoding.ASCII.GetBytes(shaderCode);
fixed (byte* data = &buffer[0])
{
shaderID = InternalIO.InternalLoadShaderCode(data, (int)shaderType);
}
shaderID = InternalIO.InternalLoadShaderCode(shaderCode, (int)shaderType);
if (shaderID == 0)
{
IntPtr logPtr = InternalIO.InternalReadLog();
@@ -84,7 +80,6 @@ namespace StgSharp.Graphics
catch (Exception)
{
log = "Failed to compile shader.\nFailed to get GLSL compiler log";
}
InternalIO.InternalWriteLog(log, LogType.Error);
@@ -165,11 +160,6 @@ namespace StgSharp.Graphics
}
public static unsafe IntPtr GetProcAddress(string name)
{
IntPtr ret = InternalIO.glfw.GetProcAddress(name);
return ret;
}
public static unsafe bool GetWindowShouldClose(Form form)
+18 -25
View File
@@ -15,15 +15,14 @@ namespace StgSharp.Graphics
private int problemAPIcount = 0;
public unsafe IntPtr LoadGLfunc([MarshalAs(UnmanagedType.LPStr)] string name)
public unsafe IntPtr LoadGLfunc(string name)
{
string log = $"Attempt to load ";
IntPtr ret = InternalIO.glfw.GetProcAddress(name);
if (ret == default)
{
InternalIO.InternalWriteLog(
$"Cannot load OpenGL api called {name}, this api may not exist or supported.",
LogType.Warning);
InternalIO.InternalAppendLog(
$"Cannot load OpenGL api called {name}, this api may not exist or supported.");
missingAPIcount++;
return ret;
}
@@ -33,16 +32,13 @@ namespace StgSharp.Graphics
public unsafe void LoadGlapi()
{
GLcontext* context = (GLcontext*)InternalIO.internalCreatGLcontext(LoadGLfunc);
if ((ulong)context == 0)
{
throw new Exception($"Failed to load OpenGL api for current context \"{(ulong)glContext}\"");
}
InternalIO.InternalLoaderLoadGLapi(glContext, LoadGLfunc);
//check out if all api is converted correctely.
FieldInfo[] fieldInfos = typeof(GLcontext).GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
FieldInfo[] target = typeof(GLcontext).GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
string problemLog = "Have problem in converting the fallowing GL API to C# delegates:\n";
foreach (FieldInfo item in fieldInfos)
foreach (FieldInfo item in target)
{
if (item.FieldType.Name.Contains("PFNG"))
{
@@ -62,23 +58,23 @@ namespace StgSharp.Graphics
InternalIO.InternalWriteLog("Attempt to reload GL APIs", LogType.Info);
//use IntPtr as interface
GLcontextIO* iopack = (GLcontextIO*)context;
TypedReference contextref = __makeref(*glContext);
GLcontextIO* iopack = (GLcontextIO*)glContext;
TypedReference iosource = __makeref(*iopack);
FieldInfo[] source = typeof(GLcontextIO).GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
foreach (FieldInfo item in source)
foreach (FieldInfo item in target)
{
if (item.FieldType.IsSubclassOf(typeof(Delegate))
&& item.GetValue(*context) == null)
&& item.GetValueDirect(contextref) == null)
{
IntPtr funcPtr = LoadGLfunc(item.Name);
if (funcPtr != IntPtr.Zero)
IntPtr proc = default;
proc = LoadGLfunc("gl" + item.Name);
if (proc != IntPtr.Zero)
{
try
{
Delegate dele = Marshal.GetDelegateForFunctionPointer(funcPtr, item.FieldType);
item.SetValue(*context, dele);
Delegate dele = Marshal.GetDelegateForFunctionPointer(proc, item.FieldType);
item.SetValueDirect(contextref, dele);
}
catch (Exception ex)
{
@@ -87,13 +83,10 @@ namespace StgSharp.Graphics
LogType.Error);
}
}
}
}
}
glContext = context;
GL.gl = glContext;
}
File diff suppressed because it is too large Load Diff