This commit is contained in:
2026-05-21 08:18:52 -05:00
parent 935edf0db8
commit 85781f4510
4 changed files with 32 additions and 30 deletions
+31 -2
View File
@@ -2,6 +2,7 @@
using Hexa.NET.ImGui;
using Hexa.NET.ImGuizmo;
using Hexa.NET.ImPlot;
using Hexa.NET.ImNodes;
using Hexa.NET.OpenGL;
using HexaGen.Runtime;
using SDL3;
@@ -23,10 +24,14 @@ public sealed unsafe class SDL3Window : IDisposable
public event Action? RenderCallback;
public event Action? Disposing;
public event Action<Vector4>? Resized;
public event Action<SDL.Event>? EventCallback;
private ImGuiContextPtr _imGuiContext;
private ImPlotContextPtr _imPlotContext;
private ImNodesContextPtr _imNodesContext;
// private ImPLot3DContextPtr _imPlot3DContext;
public bool Disposed => _disposed;
private bool _disposed;
@@ -71,9 +76,13 @@ public sealed unsafe class SDL3Window : IDisposable
// Create ImGui context
_imGuiContext = ImGui.CreateContext();
_imPlotContext = ImPlot.CreateContext();
_imNodesContext = ImNodes.CreateContext();
// _imPlot3DContext = ImPlot3D.CreateContext();
ImPlot.SetImGuiContext(_imGuiContext);
ImGuizmo.SetImGuiContext(_imGuiContext);
ImNodes.SetImGuiContext(_imGuiContext);
// ImPlot3D.SetImGuiContext(_imGuiContext);
ImGuiIOPtr io = ImGui.GetIO();
io.ConfigFlags |= ImGuiConfigFlags.NavEnableKeyboard | ImGuiConfigFlags.NavEnableGamepad | ImGuiConfigFlags.DockingEnable;
io.ConfigFlags |= ImGuiConfigFlags.ViewportsEnable;
@@ -143,7 +152,15 @@ public sealed unsafe class SDL3Window : IDisposable
case SDL.EventType.Quit:
ShouldClose = true;
break;
case SDL.EventType.WindowResized:
case SDL.EventType.WindowMoved:
SDL.GetWindowSize(Window, out int w, out int h);
SDL.GetWindowPosition(Window, out int x, out int y);
Resized?.Invoke(new Vector4(x, y, w, h));
break;
}
EventCallback?.Invoke(ev);
}
if (SDL.GetWindowFlags(Window).HasFlag(SDL.WindowFlags.Minimized))
@@ -238,6 +255,18 @@ public sealed unsafe class SDL3Window : IDisposable
ImPlot.DestroyContext(_imPlotContext);
_imPlotContext = null;
}
if (_imNodesContext.Handle != null)
{
ImNodes.SetCurrentContext(null);
ImNodes.DestroyContext(_imNodesContext);
_imNodesContext = null;
}
// if (_imPlot3DContext.Handle != null)
// {
// ImPlot3D.SetCurrentContext(null);
// ImPlot3D.DestroyContext(_imPlot3DContext);
// _imPlot3DContext = null;
// }
// if (Renderer != nint.Zero)
// {