diff --git a/源代码/.vs/ProjectEvaluation/stgsharp.metadata.v5.1 b/源代码/.vs/ProjectEvaluation/stgsharp.metadata.v5.1 index 2ccef950..7c172b3d 100644 Binary files a/源代码/.vs/ProjectEvaluation/stgsharp.metadata.v5.1 and b/源代码/.vs/ProjectEvaluation/stgsharp.metadata.v5.1 differ diff --git a/源代码/.vs/ProjectEvaluation/stgsharp.projects.v5.1 b/源代码/.vs/ProjectEvaluation/stgsharp.projects.v5.1 index d44544d3..49e22384 100644 Binary files a/源代码/.vs/ProjectEvaluation/stgsharp.projects.v5.1 and b/源代码/.vs/ProjectEvaluation/stgsharp.projects.v5.1 differ diff --git a/源代码/.vs/StgSharp/DesignTimeBuild/.dtbcache.v2 b/源代码/.vs/StgSharp/DesignTimeBuild/.dtbcache.v2 index f44432f3..6c6a031c 100644 Binary files a/源代码/.vs/StgSharp/DesignTimeBuild/.dtbcache.v2 and b/源代码/.vs/StgSharp/DesignTimeBuild/.dtbcache.v2 differ diff --git a/源代码/.vs/StgSharp/FileContentIndex/162eaa0c-4c9f-412c-ac37-7351d9c667b3.vsidx b/源代码/.vs/StgSharp/FileContentIndex/162eaa0c-4c9f-412c-ac37-7351d9c667b3.vsidx deleted file mode 100644 index e6d6c485..00000000 Binary files a/源代码/.vs/StgSharp/FileContentIndex/162eaa0c-4c9f-412c-ac37-7351d9c667b3.vsidx and /dev/null differ diff --git a/源代码/.vs/StgSharp/FileContentIndex/2109e89b-a837-4cfb-84e5-86d94e1d40ae.vsidx b/源代码/.vs/StgSharp/FileContentIndex/2109e89b-a837-4cfb-84e5-86d94e1d40ae.vsidx new file mode 100644 index 00000000..b651a08f Binary files /dev/null and b/源代码/.vs/StgSharp/FileContentIndex/2109e89b-a837-4cfb-84e5-86d94e1d40ae.vsidx differ diff --git a/源代码/.vs/StgSharp/FileContentIndex/2eadbc99-2a6a-4c2d-ad8a-45f91416e531.vsidx b/源代码/.vs/StgSharp/FileContentIndex/2eadbc99-2a6a-4c2d-ad8a-45f91416e531.vsidx deleted file mode 100644 index 1146d4e9..00000000 Binary files a/源代码/.vs/StgSharp/FileContentIndex/2eadbc99-2a6a-4c2d-ad8a-45f91416e531.vsidx and /dev/null differ diff --git a/源代码/.vs/StgSharp/FileContentIndex/412e5ef1-d067-4061-95fa-300e4a776f25.vsidx b/源代码/.vs/StgSharp/FileContentIndex/412e5ef1-d067-4061-95fa-300e4a776f25.vsidx deleted file mode 100644 index 7c088bc9..00000000 Binary files a/源代码/.vs/StgSharp/FileContentIndex/412e5ef1-d067-4061-95fa-300e4a776f25.vsidx and /dev/null differ diff --git a/源代码/.vs/StgSharp/FileContentIndex/4699035e-56a9-47f6-b39b-3a8d18d33e64.vsidx b/源代码/.vs/StgSharp/FileContentIndex/4699035e-56a9-47f6-b39b-3a8d18d33e64.vsidx new file mode 100644 index 00000000..703c0ac3 Binary files /dev/null and b/源代码/.vs/StgSharp/FileContentIndex/4699035e-56a9-47f6-b39b-3a8d18d33e64.vsidx differ diff --git a/源代码/.vs/StgSharp/FileContentIndex/788df2a1-b690-457c-a1d9-31dd172f6045.vsidx b/源代码/.vs/StgSharp/FileContentIndex/788df2a1-b690-457c-a1d9-31dd172f6045.vsidx new file mode 100644 index 00000000..9bbea6ad Binary files /dev/null and b/源代码/.vs/StgSharp/FileContentIndex/788df2a1-b690-457c-a1d9-31dd172f6045.vsidx differ diff --git a/源代码/.vs/StgSharp/FileContentIndex/a5051375-47ce-4541-b169-ff2c72dc2224.vsidx b/源代码/.vs/StgSharp/FileContentIndex/a5051375-47ce-4541-b169-ff2c72dc2224.vsidx new file mode 100644 index 00000000..6a8ebd37 Binary files /dev/null and b/源代码/.vs/StgSharp/FileContentIndex/a5051375-47ce-4541-b169-ff2c72dc2224.vsidx differ diff --git a/源代码/.vs/StgSharp/FileContentIndex/e800380e-d869-48f4-a33b-891f828d04d1.vsidx b/源代码/.vs/StgSharp/FileContentIndex/e800380e-d869-48f4-a33b-891f828d04d1.vsidx deleted file mode 100644 index b009d3dd..00000000 Binary files a/源代码/.vs/StgSharp/FileContentIndex/e800380e-d869-48f4-a33b-891f828d04d1.vsidx and /dev/null differ diff --git a/源代码/.vs/StgSharp/v17/.futdcache.v2 b/源代码/.vs/StgSharp/v17/.futdcache.v2 index eb4e67c0..45f4d1bd 100644 Binary files a/源代码/.vs/StgSharp/v17/.futdcache.v2 and b/源代码/.vs/StgSharp/v17/.futdcache.v2 differ diff --git a/源代码/.vs/StgSharp/v17/.suo b/源代码/.vs/StgSharp/v17/.suo index d07a2766..871fa68b 100644 Binary files a/源代码/.vs/StgSharp/v17/.suo and b/源代码/.vs/StgSharp/v17/.suo differ diff --git a/源代码/.vs/StgSharp/v17/Browse.VC.db b/源代码/.vs/StgSharp/v17/Browse.VC.db index 3f43d963..6139a7f8 100644 Binary files a/源代码/.vs/StgSharp/v17/Browse.VC.db and b/源代码/.vs/StgSharp/v17/Browse.VC.db differ diff --git a/源代码/.vs/StgSharp/v17/ipch/AutoPCH/8caf4239ea6f0775/STGSHARPGRAPHIC.ipch b/源代码/.vs/StgSharp/v17/ipch/AutoPCH/8caf4239ea6f0775/STGSHARPGRAPHIC.ipch new file mode 100644 index 00000000..b7f33f84 Binary files /dev/null and b/源代码/.vs/StgSharp/v17/ipch/AutoPCH/8caf4239ea6f0775/STGSHARPGRAPHIC.ipch differ diff --git a/源代码/StgSharp/Graphics/Form.cs b/源代码/StgSharp/Graphics/Form.cs index d180c1ab..9f2c7f7a 100644 --- a/源代码/StgSharp/Graphics/Form.cs +++ b/源代码/StgSharp/Graphics/Form.cs @@ -15,10 +15,11 @@ namespace StgSharp.Graphics public unsafe class Form { - internal IntPtr windowPtr; - internal formInfo info; + + internal long windowID; //pointer to the form + internal formInfo info = new formInfo() ; internal IntPtr shader; - internal LinkedList allControl = new LinkedList(); + internal LinkedList allControl; public vec2d Size { diff --git a/源代码/StgSharp/Graphics/GLFunc.cs b/源代码/StgSharp/Graphics/GLFunc.cs index cd289336..cceb5006 100644 --- a/源代码/StgSharp/Graphics/GLFunc.cs +++ b/源代码/StgSharp/Graphics/GLFunc.cs @@ -32,7 +32,7 @@ namespace StgSharp else { windowPtr = glIO.internalGLcreateWindow( - width, height, tittle, monitor, (IntPtr)share.windowPtr); + width, height, tittle, monitor, (IntPtr)share.windowID); } @@ -44,7 +44,7 @@ namespace StgSharp { Form form = new Form(); form.Size = new vec2d(width, height); - form.windowPtr = windowPtr; + form.windowID = (long)windowPtr; return form; } } @@ -61,41 +61,40 @@ namespace StgSharp /// public static unsafe Form GLcreateWindow(int width, int height, string tittle, IntPtr monitor, IntPtr 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); + long windowPtr = (long)glIO.internalGLcreateWindow + (width, height, tittleCharArray, monitor, share); if ((int)windowPtr == -1 || (int)windowPtr == -2) { - throw new Exception("Cannot create window instance!"); + throw new Exception("Cannot create the form!"); + } + else + { + Form form = new Form(); + form.Size = new vec2d(width, height); + form.windowID = windowPtr; + return form; } - return form; } public static unsafe void GLmakeContexCurrent(Form form) { - glIO.internalGLmakeContextCurrent((IntPtr)form.windowPtr); + glIO.internalGLmakeContextCurrent((IntPtr)form.windowID); } public static unsafe bool GLwindowShouldClose(Form form) { - int a = glIO.internalGLwindowShouldClose((IntPtr)form.windowPtr); + int a = glIO.internalGLwindowShouldClose((IntPtr)form.windowID); return a != 0; } public static unsafe void GLswapBuffers(Form form) { - glIO.internalGLswapBuffers((IntPtr)form.windowPtr); + glIO.internalGLswapBuffers((IntPtr)form.windowID); } } diff --git a/源代码/StgSharp/Graphics/Graphic.cs b/源代码/StgSharp/Graphics/Graphic.cs index b1d5e922..c0689898 100644 --- a/源代码/StgSharp/Graphics/Graphic.cs +++ b/源代码/StgSharp/Graphics/Graphic.cs @@ -8,16 +8,8 @@ namespace StgSharp { internal static GraphicIOPack glIO; private static bool isGLSet = false; - - /// - /// Init an instance of OpenGL program, - /// This method should be called before other - /// graphic methods, after LoadGL method. - /// - public static void InitGL() - { - internalIO.InternalInitGL(); - } + private static bool isGLADset = false; + private static bool isGLready = false; /// /// Load OpenGL API to StgSharp core programm, @@ -27,7 +19,7 @@ namespace StgSharp /// If run this method twice, will throw exception public static unsafe void LoadGL() { - if (!isGLSet) + if (!isGLADset) { glIO = internalIO.InternalInitGraphicApi(); } @@ -37,6 +29,27 @@ namespace StgSharp } } + + /// + /// Init an instance of OpenGL program, + /// This method should be called before other + /// graphic methods, after LoadGL method. + /// + public static void InitGL() + { + if (!isGLSet) + { + internalIO.InternalInitGL(); + isGLready = isGLSet && isGLADset; + } + else + { + throw new Exception("Do not init GL twice"); + } + } + + + /// /// Attach GLFW API to GLAD, /// this method should be called after LoadGL @@ -45,32 +58,27 @@ namespace StgSharp /// The accident that program cannot attach GLFW to GLAD public static unsafe void InitGLAD() { - int a = internalIO.InternalInitGLAD(); - if (a!=0) + + if (!isGLADset) { - throw new Exception("Cannot attach GLFW to GLAD!"); + int a = internalIO.InternalInitGLAD(); + if (a != 0) + { + throw new Exception("Cannot attach GLFW to GLAD!"); + } + else + { + isGLready = isGLSet && isGLADset; + return; + } } else { - return; + throw new Exception("Do not init GLAD twice."); } } - internal static byte[] loadShaderCodeStr(string str) - { - byte[] cahrStr; - try - { - cahrStr = System.Text.Encoding.ASCII.GetBytes(str); - return cahrStr; - } - catch (Exception) - { - throw; - } - } - diff --git a/源代码/StgSharpDebug/Debug.cs b/源代码/StgSharpDebug/Debug.cs index 92295062..5cebdb15 100644 --- a/源代码/StgSharpDebug/Debug.cs +++ b/源代码/StgSharpDebug/Debug.cs @@ -12,8 +12,6 @@ namespace StgSharp { private unsafe static void Main(string[] args) { - - Console.WriteLine(sizeof(int*)); Graphic.LoadGL(); Graphic.InitGL(); Graphic.InitGLAD(); diff --git a/源代码/StgSharpDebug/StgSharpDebug.csproj b/源代码/StgSharpDebug/StgSharpDebug.csproj index bc7ec937..1fcbc6ff 100644 --- a/源代码/StgSharpDebug/StgSharpDebug.csproj +++ b/源代码/StgSharpDebug/StgSharpDebug.csproj @@ -124,6 +124,7 @@ + diff --git a/源代码/StgSharpDebug/bin/x64/Release/net6.0/StgSharpDebug.dll b/源代码/StgSharpDebug/bin/x64/Release/net6.0/StgSharpDebug.dll index bd0c1027..6818e1a2 100644 Binary files a/源代码/StgSharpDebug/bin/x64/Release/net6.0/StgSharpDebug.dll and b/源代码/StgSharpDebug/bin/x64/Release/net6.0/StgSharpDebug.dll differ diff --git a/源代码/StgSharpDebug/obj/x64/Debug/net6.0/StgSharpDebug.GeneratedMSBuildEditorConfig.editorconfig b/源代码/StgSharpDebug/obj/x64/Debug/net6.0/StgSharpDebug.GeneratedMSBuildEditorConfig.editorconfig index 6543a41b..e1bc5568 100644 --- a/源代码/StgSharpDebug/obj/x64/Debug/net6.0/StgSharpDebug.GeneratedMSBuildEditorConfig.editorconfig +++ b/源代码/StgSharpDebug/obj/x64/Debug/net6.0/StgSharpDebug.GeneratedMSBuildEditorConfig.editorconfig @@ -7,5 +7,5 @@ build_property.InvariantGlobalization = build_property.PlatformNeutralAssembly = build_property.EnforceExtendedAnalyzerRules = build_property._SupportedPlatformList = Linux,macOS,Windows -build_property.RootNamespace = StgSharpDebug +build_property.RootNamespace = StgSharp build_property.ProjectDir = D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgSharpDebug\ diff --git a/源代码/StgSharpDebug/obj/x64/Release/net6.0/StgSharpDebug.dll b/源代码/StgSharpDebug/obj/x64/Release/net6.0/StgSharpDebug.dll index bd0c1027..6818e1a2 100644 Binary files a/源代码/StgSharpDebug/obj/x64/Release/net6.0/StgSharpDebug.dll and b/源代码/StgSharpDebug/obj/x64/Release/net6.0/StgSharpDebug.dll differ diff --git a/源代码/StgSharpDebug/obj/x64/Release/net6.0/ref/StgSharpDebug.dll b/源代码/StgSharpDebug/obj/x64/Release/net6.0/ref/StgSharpDebug.dll index 52a1d50a..1e21defb 100644 Binary files a/源代码/StgSharpDebug/obj/x64/Release/net6.0/ref/StgSharpDebug.dll and b/源代码/StgSharpDebug/obj/x64/Release/net6.0/ref/StgSharpDebug.dll differ diff --git a/源代码/StgSharpDebug/obj/x64/Release/net6.0/refint/StgSharpDebug.dll b/源代码/StgSharpDebug/obj/x64/Release/net6.0/refint/StgSharpDebug.dll index 52a1d50a..1e21defb 100644 Binary files a/源代码/StgSharpDebug/obj/x64/Release/net6.0/refint/StgSharpDebug.dll and b/源代码/StgSharpDebug/obj/x64/Release/net6.0/refint/StgSharpDebug.dll differ diff --git a/源代码/StgShqrpGraphic/StgSharpGraphic.c b/源代码/StgShqrpGraphic/StgSharpGraphic.c index 83731837..af526a75 100644 --- a/源代码/StgShqrpGraphic/StgSharpGraphic.c +++ b/源代码/StgShqrpGraphic/StgSharpGraphic.c @@ -46,18 +46,4 @@ STGSHARPGRAPHIC_API int initGLAD(void) { return gladLoadGLLoader((GLADloadproc)glfwGetProcAddress); -} - -GLFWwindow* (*createWindow)( - int width, - int height, - const char* title, - GLFWmonitor* monitor, - GLFWwindow* share); - - -STGSHARPGRAPHIC_API void* getPtr(void) -{ - createWindow = glfwCreateWindow; - return createWindow; } \ No newline at end of file diff --git a/源代码/StgShqrpGraphic/StgSharpGraphic.h b/源代码/StgShqrpGraphic/StgSharpGraphic.h index 01c529d0..efcbf334 100644 --- a/源代码/StgShqrpGraphic/StgSharpGraphic.h +++ b/源代码/StgShqrpGraphic/StgSharpGraphic.h @@ -19,7 +19,6 @@ STGSHARPGRAPHIC_API glIOpackage loadGLApi(void); STGSHARPGRAPHIC_API void initGL(void); STGSHARPGRAPHIC_API int initGLAD(void); -STGSHARPGRAPHIC_API void* getPtr(void); #endif // !SSG