daily update on 20230628 by nitload youmu, new debug and graphic lib added

This commit is contained in:
Nitload
2023-06-29 02:10:56 +08:00
parent f99a0674b0
commit 04b166771c
277 changed files with 19879 additions and 12406 deletions
+3 -31
View File
@@ -1,5 +1,4 @@
using StgSharp.Graphics.GL;
using StgSharp.Math;
using StgSharp.Math;
using System;
using System.Runtime.InteropServices;
@@ -11,7 +10,7 @@ namespace StgSharp.Graphics
public int width;
public int height;
public vec4d color;
public string name;
public byte[] name;
}
public unsafe class Form
@@ -19,7 +18,7 @@ namespace StgSharp.Graphics
internal IntPtr windowPtr;
internal formInfo info;
internal IntPtr shader;
internal LinkedList<Pool> allControl;
internal LinkedList<Pool> allControl = new LinkedList<Pool>();
public vec2d Size
{
@@ -55,35 +54,8 @@ namespace StgSharp.Graphics
/// </summary>
public Form()
{
info = new formInfo();
allControl = new LinkedList<Pool>();
Init();
//StgSharp.Graphic.LoadForm(this);
}
//used for internal control purpose
internal Form(int instruction)
{
}
internal unsafe void defualtInit()
{
//IntPtr windowPtr = Graphic.InitWindow(this);
}
public virtual void Init()
{
info.color = new vec4d(0.95, 0.93, 0.92, 0);
info.width = 800;
info.height = 600;
//this.windowPtr = Graphic.InitWindow(this);
}
public void Show()
{
}
}
}
+49 -31
View File
@@ -9,7 +9,7 @@ namespace StgSharp.Graphics
//strucs defined in glfw3.h
[StructLayout(LayoutKind.Sequential)]
public unsafe struct GLFWcontext
{
int client;
@@ -69,7 +69,7 @@ namespace StgSharp.Graphics
//GLFW_PLATFORM_CONTEXT_STATE
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct GLFWvidmode
{
/*! The width, in screen coordinates, of the video mode.
@@ -92,6 +92,7 @@ namespace StgSharp.Graphics
int refreshRate;
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct GLFWgammaramp
{
@@ -109,6 +110,7 @@ namespace StgSharp.Graphics
uint size;
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct GLFWimage
{
@@ -123,6 +125,7 @@ namespace StgSharp.Graphics
byte* pixels;
}
[StructLayout(LayoutKind.Sequential)]
public struct GLFWgamepadstate
{
@@ -140,6 +143,7 @@ namespace StgSharp.Graphics
}
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct GLFWallocator
{
//GLFWallocatefun allocate;
@@ -151,6 +155,7 @@ namespace StgSharp.Graphics
void* user;
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct GLFWmonitor
{
@@ -178,47 +183,48 @@ namespace StgSharp.Graphics
public GLFWmonitor() { }
}
public unsafe struct _GLFWwindow
[StructLayout(LayoutKind.Sequential)]
public unsafe struct GLFWwindow
{
//struct _GLFWwindow* next in GLFW
public IntPtr next;
public IntPtr next = IntPtr.Zero;
public bool resizable;
public bool decorated;
public bool autoIconify;
public bool floating;
public bool focusOnShow;
public bool mousePassthrough;
public bool shouldClose;
public void* userPointer;
public bool doublebuffer;
public GLFWvidmode videoMode;
//public GLFWmonitor* monitor;
public IntPtr monitor;
public GLFWcursor* cursor;
public bool resizable = false;
public bool decorated = false;
public bool autoIconify = false;
public bool floating = false;
public bool focusOnShow = false;
public bool mousePassthrough = false;
public bool shouldClose = false;
public void* userPointer = (void*)0;
public bool doublebuffer = false;
public GLFWvidmode videoMode = default;
public IntPtr monitor = IntPtr.Zero; //public GLFWmonitor* monitor;
public GLFWcursor* cursor = (GLFWcursor*)0;
public int minwidth, minheight;
public int maxwidth, maxheight;
public int numer, denom;
public int minwidth = 0, minheight = 0;
public int maxwidth = 0, maxheight = 0;
public int numer = 0, denom = 0;
public bool stickyKeys;
public bool stickyMouseButtons;
public bool lockKeyMods;
public int cursorMode;
public bool stickyKeys = false;
public bool stickyMouseButtons = false;
public bool lockKeyMods = false;
public int cursorMode = 0;
public char[] mouseButtons = new char[8];
public char[] keys = new char[349];
// Virtual cursor position when cursor is disabled
public double virtualCursorPosX, virtualCursorPosY;
public bool rawMouseMotion;
public double virtualCursorPosX = 0, virtualCursorPosY = 0;
public bool rawMouseMotion = false;
public GLFWcontext context;
public GLFWcontext context = default;
public _GLFWwindow()
public GLFWwindow()
{
}
}
[StructLayout(LayoutKind.Sequential)]
public struct GLFWcursor
{
//_GLFWcursor* next;
@@ -229,6 +235,7 @@ namespace StgSharp.Graphics
// GLFW_PLATFORM_CURSOR_STATE;
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct GLFWerror
{
@@ -242,6 +249,7 @@ namespace StgSharp.Graphics
}
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct GLFWinitconfig
{
@@ -265,6 +273,7 @@ namespace StgSharp.Graphics
}
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct GLFWwndconfig
{
@@ -286,7 +295,7 @@ namespace StgSharp.Graphics
GLFWbool scaleToMonitor;
internal struct Ns
{
GLFWbool retina;
GLFWbool retina = false;
char[] frameName = new char[256];
public Ns()
@@ -327,6 +336,7 @@ namespace StgSharp.Graphics
}
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct GLFWctxconfig
{
int client;
@@ -352,6 +362,7 @@ namespace StgSharp.Graphics
}
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct GLFWfbconfig
{
@@ -374,7 +385,7 @@ namespace StgSharp.Graphics
uintptr_t handle;
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct _GLFWlibrary
{
GLFWbool initialized;
@@ -519,6 +530,7 @@ namespace StgSharp.Graphics
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct _GLFWmapelement
{
byte type;
@@ -527,6 +539,7 @@ namespace StgSharp.Graphics
sbyte axisOffset;
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct _GLFWmapping
{
@@ -538,6 +551,7 @@ namespace StgSharp.Graphics
public _GLFWmapping() { }
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct _GLFWjoystick
{
@@ -562,6 +576,7 @@ namespace StgSharp.Graphics
public _GLFWjoystick() { }
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct _GLFWtls
{
// This is defined in platform.h
@@ -569,7 +584,7 @@ namespace StgSharp.Graphics
//GLFW_PLATFORM_TLS_STATE
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct GLFWplatform
{
@@ -733,6 +748,7 @@ namespace StgSharp.Graphics
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct _GLFWmutex
{
// This is defined in platform.h
@@ -741,6 +757,7 @@ namespace StgSharp.Graphics
//public unsafe struct VkAllocationCallbacks { }
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct VkExtensionProperties
{
char[] extensionName = new char[256];
@@ -751,6 +768,7 @@ namespace StgSharp.Graphics
}
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct _GLFWerror
{
IntPtr next;
+56 -12
View File
@@ -1,6 +1,9 @@
using StgSharp.Control;
using StgSharp.Graphics;
using StgSharp.Math;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace StgSharp
@@ -8,29 +11,42 @@ namespace StgSharp
public static unsafe partial class Graphic
{
/// <summary>
/// Creates a window and its associated context.
/// Creates a form 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>
/// <returns>The instance of created form</returns>
/// <exception cref="Exception"></exception>
public static unsafe IntPtr GLcreateWindow(int width, int height, char[] tittle, IntPtr monitor, IntPtr share)
public static unsafe Form GLcreateWindow(int width, int height, byte[] tittle, IntPtr monitor, Form share)
{
IntPtr windowPtr = glIO.InternalGLcreateWindow(width, height, tittle, monitor, share);
IntPtr windowPtr;
if (share == null)
{
windowPtr = glIO.internalGLcreateWindow(
width, height, tittle, monitor, (IntPtr)0);
}
else
{
windowPtr = glIO.internalGLcreateWindow(
width, height, tittle, monitor, (IntPtr)share.windowPtr);
}
if ((int)windowPtr == -1 || (int)windowPtr == -2)
{
throw new Exception("Cannot create window instance!");
}
return windowPtr;
else
{
Form form = new Form();
form.Size = new vec2d(width, height);
form.windowPtr = windowPtr;
return form;
}
}
/// <summary>
@@ -43,15 +59,43 @@ namespace StgSharp
/// <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)
public static unsafe Form GLcreateWindow(int width, int height, string tittle, IntPtr monitor, IntPtr share)
{
IntPtr windowPtr = glIO.InternalGLcreateWindow(width, height, null, monitor, 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);
if ((int)windowPtr == -1 || (int)windowPtr == -2)
{
throw new Exception("Cannot create window instance!");
}
return windowPtr;
return form;
}
public static unsafe void GLmakeContexCurrent(Form form)
{
glIO.internalGLmakeContextCurrent((IntPtr)form.windowPtr);
}
public static unsafe bool GLwindowShouldClose(Form form)
{
int a = glIO.internalGLwindowShouldClose((IntPtr)form.windowPtr);
return a != 0;
}
public static unsafe void GLswapBuffers(Form form)
{
glIO.internalGLswapBuffers((IntPtr)form.windowPtr);
}
}
+10
View File
@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Control
{
public delegate void FrameBufferSizeCallback(IntPtr window, int width, int height);
}
+5 -1
View File
@@ -43,13 +43,17 @@ namespace StgSharp
/// and before other graphic method.
/// </summary>
/// <exception cref="Exception">The accident that program cannot attach GLFW to GLAD</exception>
public static unsafe void LoadGLAD()
public static unsafe void InitGLAD()
{
int a = internalIO.InternalInitGLAD();
if (a!=0)
{
throw new Exception("Cannot attach GLFW to GLAD!");
}
else
{
return;
}
}
@@ -0,0 +1,147 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
namespace StgSharp.Graphics
{
/// <summary>
/// A window struct that has nearly no differencr with GLFWwindow,
/// but only can be referred by pointers.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public unsafe struct SSGwindow
{
//struct _GLFWwindow* next in GLFW
internal SSGwindow* next;
internal bool resizable;
internal bool decorated;
internal bool autoIconify;
internal bool floating;
internal bool focusOnShow;
internal bool mousePassthrough;
internal bool shouldClose;
internal void* userPointer;
internal bool doublebuffer;
internal GLFWvidmode videoMode;
internal IntPtr monitor; //internal GLFWmonitor* monitor;
internal GLFWcursor* cursor;
internal int minwidth, minheight;
internal int maxwidth, maxheight;
internal int numer, denom;
internal bool stickyKeys;
internal bool stickyMouseButtons;
internal bool lockKeyMods;
internal int cursorMode;
internal long mouseButtons; //internal char[] mouseButtons = new char[8];
internal CharArray349 keys; //internal char[] keys = new char[349];
// Virtual cursor position when cursor is disabled
internal double virtualCursorPosX, virtualCursorPosY;
internal bool rawMouseMotion;
internal GLFWcontext context;
[StructLayout(LayoutKind.Sequential)]
internal struct CharArray349
{
internal long charGroup1;
internal long charGroup2;
internal long charGroup3;
internal long charGroup4;
internal long charGroup5;
internal long charGroup6;
internal long charGroup7;
internal long charGroup8;
internal long charGroup9;
internal long charGroup10;
internal long charGroup11;
internal long charGroup12;
internal long charGroup13;
internal long charGroup14;
internal long charGroup15;
internal long charGroup16;
internal long charGroup17;
internal long charGroup18;
internal long charGroup19;
internal long charGroup20;
internal long charGroup21;
internal long charGroup22;
internal long charGroup23;
internal long charGroup24;
internal long charGroup25;
internal long charGroup26;
internal long charGroup27;
internal long charGroup28;
internal long charGroup29;
internal long charGroup30;
internal long charGroup31;
internal long charGroup32;
internal long charGroup33;
internal long charGroup34;
internal long charGroup35;
internal long charGroup36;
internal long charGroup37;
internal long charGroup38;
internal long charGroup39;
internal long charGroup40;
internal long charGroup41;
internal long charGroup42;
internal long charGroup43;
internal byte char345;
internal byte char346;
internal byte char347;
internal byte char348;
internal byte char349;
}
public SSGwindow()
{
}
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct SSGmonitor
{
char[] name = new char[128];
void* userPointer;
// Physical dimensions in millimeters.
int widthMM, heightMM;
// The window whose video mode is current on this monitor
//_GLFWwindow* window;
IntPtr window;
//GLFWvidmode* modes;
IntPtr modes;
int modeCount;
GLFWvidmode currentMode;
GLFWgammaramp originalRamp;
GLFWgammaramp currentRamp;
// not transformed
//GLFW_PLATFORM_MONITOR_STATE;
[StructLayout(LayoutKind.Sequential)]
internal struct monitorName
{
internal int byte1to4;
internal int byte5to8;
internal int byte9to12;
internal int byte13to16;
}
public SSGmonitor() { }
}
}