daily update on 20230623 by nitload youmu, SSG lib rewrite

This commit is contained in:
Nitload
2023-06-24 01:03:48 +08:00
parent ee8132c149
commit f99a0674b0
193 changed files with 16115 additions and 8972 deletions
+3 -11
View File
@@ -58,7 +58,7 @@ namespace StgSharp.Graphics
info = new formInfo();
allControl = new LinkedList<Pool>();
Init();
StgSharp.Graphic.LoadForm(this);
//StgSharp.Graphic.LoadForm(this);
}
@@ -70,11 +70,7 @@ namespace StgSharp.Graphics
internal unsafe void defualtInit()
{
IntPtr windowPtr = Graphic.InitWindow(this);
internalIO.InternalCompileShader((shaderObject*)this.shader);
internalIO.InternalRenderWindow(windowPtr, this.info, (shaderObject*)this.shader);
internalIO.TerminateWindow((shaderObject*)shader);
//IntPtr windowPtr = Graphic.InitWindow(this);
}
public virtual void Init()
@@ -82,15 +78,11 @@ namespace StgSharp.Graphics
info.color = new vec4d(0.95, 0.93, 0.92, 0);
info.width = 800;
info.height = 600;
this.windowPtr = Graphic.InitWindow(this);
//this.windowPtr = Graphic.InitWindow(this);
}
public void Show()
{
internalIO.InternalCompileShader((shaderObject*)shader);
internalIO.InternalRenderWindow(this.windowPtr, this.info, (shaderObject*)shader);
internalIO.TerminateWindow((shaderObject*)shader);
}
}
+47 -3
View File
@@ -1,4 +1,5 @@
using System;
using StgSharp.Control;
using System;
using System.Collections.Generic;
using System.Text;
@@ -6,9 +7,52 @@ namespace StgSharp
{
public static unsafe partial class Graphic
{
public static void InitGL()
/// <summary>
/// Creates a window and its associated context.
/// </summary>
/// <param name="width">Required width</param>
/// <param name="height">Required width</param>
/// <param name="tittle">Tittle of the window </param>
/// <param name="monitor"></param>
/// <param name="share"></param>
/// <returns>The handle of created window</returns>
/// <exception cref="Exception"></exception>
public static unsafe IntPtr GLcreateWindow(int width, int height, char[] tittle, IntPtr monitor, IntPtr share)
{
InternalInitGL();
IntPtr windowPtr = glIO.InternalGLcreateWindow(width, height, tittle, monitor, share);
if ((int)windowPtr == -1 || (int)windowPtr == -2)
{
throw new Exception("Cannot create window instance!");
}
return windowPtr;
}
/// <summary>
/// Creates a window and its associated context.
/// </summary>
/// <param name="width">Required width</param>
/// <param name="height">Required width</param>
/// <param name="tittle">Tittle of the window </param>
/// <param name="monitor"></param>
/// <param name="share"></param>
/// <returns>The handle of created window</returns>
/// <exception cref="Exception"></exception>
public static unsafe IntPtr GLcreateWindow(int width, int height, string tittle, IntPtr monitor, IntPtr share)
{
IntPtr windowPtr = glIO.InternalGLcreateWindow(width, height, null, monitor, share);
if ((int)windowPtr == -1 || (int)windowPtr == -2)
{
throw new Exception("Cannot create window instance!");
}
return windowPtr;
}
}
}
-16
View File
@@ -1,16 +0,0 @@
using StgSharp.Control;
namespace StgSharp
{
public static unsafe partial class Graphic
{
internal static InternalInitGLDelegate InternalInitGL;
internal static InternalGLcreateWindowDelegate InternalGLcreatWindow;
internal static InternalGLmakeContextCurrent InternalGLmakeContextCurrent;
internal static InternalGLswapInterval InternalGLswapInterval;
internal static InternalGLclearColorDelegate InternalGLclearColor;
}
}
+49 -11
View File
@@ -6,11 +6,53 @@ namespace StgSharp
{
public static unsafe partial class Graphic
{
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();
}
/// <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()
{
GraphicIOPack GLpack = internalIO.InternalInitGraphicApi();
if (!isGLSet)
{
glIO = internalIO.InternalInitGraphicApi();
}
else
{
throw new Exception("Do not load GL api twice.");
}
}
/// <summary>
/// Attach GLFW API to GLAD,
/// this method should be called after LoadGL
/// and before other graphic method.
/// </summary>
/// <exception cref="Exception">The accident that program cannot attach GLFW to GLAD</exception>
public static unsafe void LoadGLAD()
{
int a = internalIO.InternalInitGLAD();
if (a!=0)
{
throw new Exception("Cannot attach GLFW to GLAD!");
}
}
internal static byte[] loadShaderCodeStr(string str)
{
byte[] cahrStr;
@@ -21,11 +63,14 @@ namespace StgSharp
}
catch (Exception)
{
throw;
}
}
/*
/// <summary>
/// Init a form, attach its data to GLFW program,
/// and return the pointer of the GLFW package of the form.
@@ -50,17 +95,10 @@ namespace StgSharp
return a;
}
}
*/
public static unsafe void LoadForm(Form form)
{
TimeLine.allForm.Add(form);
}
public static unsafe bool ShouldFormClose(Form form)
{
int a = internalIO.InternalShouldFormClose(form.windowPtr);
return a != 0;
}
}
}