New IO structure, unexpexted error in C code

This commit is contained in:
Nitload
2023-06-22 03:33:24 +08:00
parent 50b4965e54
commit ee8132c149
172 changed files with 1344 additions and 4023 deletions
+15 -24
View File
@@ -1,11 +1,7 @@
using StgSharp.Graphics.GL;
using StgSharp.Math;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
namespace StgSharp.Graphics
{
@@ -18,18 +14,18 @@ namespace StgSharp.Graphics
public string name;
}
public unsafe class Form:INode<Form>
public unsafe class Form
{
internal IntPtr windowPtr;
internal formInfo info;
internal shaderObject shader;
internal IntPtr shader;
internal LinkedList<Pool> allControl;
public vec2d Size
{
get { return new vec2d(info.width,info.height); }
set
{
get { return new vec2d(info.width, info.height); }
set
{
info.width = (int)value.X;
info.height = (int)value.Y;
}
@@ -41,7 +37,7 @@ namespace StgSharp.Graphics
set => info.width = value;
}
public int Height
public int Height
{
get => info.height;
set => info.height = value;
@@ -69,18 +65,16 @@ namespace StgSharp.Graphics
//used for internal control purpose
internal Form(int instruction)
{
}
internal unsafe void defualtInit()
{
fixed (shaderObject* shaderObj = &this.shader)
{
IntPtr windowPtr = Graphic.InitWindow(this);
internalIO.InternalCompileShader(shaderObj);
internalIO.InternalRenderWindow(windowPtr, this.info, shaderObj);
internalIO.TerminateWindow(shaderObj);
}
IntPtr windowPtr = Graphic.InitWindow(this);
internalIO.InternalCompileShader((shaderObject*)this.shader);
internalIO.InternalRenderWindow(windowPtr, this.info, (shaderObject*)this.shader);
internalIO.TerminateWindow((shaderObject*)shader);
}
public virtual void Init()
@@ -93,12 +87,9 @@ namespace StgSharp.Graphics
public void Show()
{
fixed (shaderObject* shaderObj = &this.shader)
{
internalIO.InternalCompileShader(shaderObj);
internalIO.InternalRenderWindow(this.windowPtr, this.info, shaderObj);
internalIO.TerminateWindow(shaderObj);
}
internalIO.InternalCompileShader((shaderObject*)shader);
internalIO.InternalRenderWindow(this.windowPtr, this.info, (shaderObject*)shader);
internalIO.TerminateWindow((shaderObject*)shader);
}
+1 -5
View File
@@ -1,16 +1,12 @@
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
namespace StgSharp.Graphics
{
//rename types in style of GLFW
using GLFWbool = Boolean;
using _glfw = _GLFWlibrary;
public unsafe static partial class GLFW
public static unsafe partial class GLFW
{
internal static _glfw glfw = new _glfw();
+2 -6
View File
@@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Graphics
namespace StgSharp.Graphics
{
internal enum VkStructureType:uint
internal enum VkStructureType : uint
{
VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR = 1000004000,
VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR = 1000005000,
+7 -11
View File
@@ -1,15 +1,11 @@
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
namespace StgSharp.Graphics
{
//rename types in style of GLFW
using GLFWbool = Boolean;
using _glfw = _GLFWlibrary;
//strucs defined in glfw3.h
@@ -96,7 +92,7 @@ namespace StgSharp.Graphics
int refreshRate;
}
public unsafe struct GLFWgammaramp
public unsafe struct GLFWgammaramp
{
/*! An array of value describing the response of the red channel.
@@ -113,7 +109,7 @@ namespace StgSharp.Graphics
uint size;
}
public unsafe struct GLFWimage
public unsafe struct GLFWimage
{
/*! The width, in pixels, of this image.
@@ -127,7 +123,7 @@ namespace StgSharp.Graphics
byte* pixels;
}
public struct GLFWgamepadstate
public struct GLFWgamepadstate
{
/*! The states of each [gamepad button](@ref gamepad_buttons), `GLFW_PRESS`
@@ -144,7 +140,7 @@ namespace StgSharp.Graphics
}
}
public unsafe struct GLFWallocator
public unsafe struct GLFWallocator
{
//GLFWallocatefun allocate;
IntPtr allocate;
@@ -233,7 +229,7 @@ namespace StgSharp.Graphics
// GLFW_PLATFORM_CURSOR_STATE;
}
public unsafe struct GLFWerror
public unsafe struct GLFWerror
{
//_GLFWerror* next;
@@ -356,7 +352,7 @@ namespace StgSharp.Graphics
}
}
public unsafe struct GLFWfbconfig
public unsafe struct GLFWfbconfig
{
int redBits;
@@ -767,7 +763,7 @@ namespace StgSharp.Graphics
}
[StructLayout(LayoutKind.Explicit,Size = 16)]
[StructLayout(LayoutKind.Explicit, Size = 16)]
public struct uintptr_t
{
[FieldOffset(0)]
+1 -4
View File
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using System.Runtime.InteropServices;
namespace StgSharp.Graphics.GL
{
+14
View File
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp
{
public static unsafe partial class Graphic
{
public static void InitGL()
{
InternalInitGL();
}
}
}
+16
View File
@@ -0,0 +1,16 @@
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;
}
}
+28 -9
View File
@@ -1,17 +1,31 @@
using StgSharp.Control;
using StgSharp.Graphics;
using StgSharp.Graphics.GL;
using StgSharp.Math;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
namespace StgSharp
{
public static unsafe class Graphic
public static unsafe partial class Graphic
{
public static unsafe void LoadGL()
{
GraphicIOPack GLpack = internalIO.InternalInitGraphicApi();
}
internal static byte[] loadShaderCodeStr(string str)
{
byte[] cahrStr;
try
{
cahrStr = System.Text.Encoding.ASCII.GetBytes(str);
return cahrStr;
}
catch (Exception)
{
throw;
}
}
/// <summary>
/// Init a form, attach its data to GLFW program,
/// and return the pointer of the GLFW package of the form.
@@ -22,7 +36,7 @@ namespace StgSharp
/// or GLAD program fail to init</exception>
public static unsafe IntPtr InitWindow(Form form)
{
IntPtr a= internalIO.InternalInitWindow(form.info);
IntPtr a = internalIO.InternalInitWindow(form.info);
if ((long)a == -1)
{
throw new Exception("Failed to init form.");
@@ -39,9 +53,14 @@ namespace StgSharp
public static unsafe void LoadForm(Form form)
{
ProgramTimeLine.allForm.Add(form);
TimeLine.allForm.Add(form);
}
public static unsafe bool ShouldFormClose(Form form)
{
int a = internalIO.InternalShouldFormClose(form.windowPtr);
return a != 0;
}
}
}