diff --git a/Program.cs b/Program.cs index f3c3fe2..e9871b4 100644 --- a/Program.cs +++ b/Program.cs @@ -9,6 +9,7 @@ namespace SDL3_TestingSuite; public class Program { private static bool _demoWindowVisible = true; + private static bool _imPlotDemoVisible; private static bool _fontStuff; private static readonly Dictionary?> GlyphsByName = new Dictionary?>(); private static bool _initialized; @@ -40,6 +41,8 @@ public class Program ImGui.Spacing(); ImGui.MenuItem("Demo Window", "", ref _demoWindowVisible); ImGui.Spacing(); + ImGui.MenuItem("ImPlot Demo Window", "", ref _imPlotDemoVisible); + ImGui.Spacing(); ImGui.MenuItem("Font Stuff", "", ref _fontStuff); ImGui.EndMenuBar(); @@ -92,12 +95,12 @@ public class Program ImGui.PushFont(null, 24); - if (GlyphsByName.TryGetValue(fontName, out List glyphs2)) + if (GlyphsByName.TryGetValue(fontName, out List? glyphs2)) { float cursorXStart = ImGui.GetCursorPosX(); float maxWidth = ImGui.GetContentRegionAvail().X; - foreach (uint codepoint in glyphs2) + foreach (uint codepoint in glyphs2!) { string text = char.ConvertFromUtf32((int)codepoint); float glyphWidth = ImGui.CalcTextSize(text).X; @@ -164,8 +167,10 @@ public class Program if (_demoWindowVisible) { ImGui.ShowDemoWindow(ref _demoWindowVisible); + } + if (_imPlotDemoVisible) + { ImPlot.ShowDemoWindow(ref _demoWindowVisible); - // ImPlot3D.ShowDemoWindow(ref _demoWindowVisible); } }; @@ -200,4 +205,4 @@ public class Program Console.WriteLine($"{message} | {method} | {path}:{line}"); } } -} \ No newline at end of file +} diff --git a/SDL3 TestingSuite.csproj b/SDL3 TestingSuite.csproj index 6821cfd..99416fb 100644 --- a/SDL3 TestingSuite.csproj +++ b/SDL3 TestingSuite.csproj @@ -15,7 +15,6 @@ - diff --git a/SDL3/ImGuiSDL3Platform.cs b/SDL3/ImGuiSDL3Platform.cs index aa8035f..f337112 100644 --- a/SDL3/ImGuiSDL3Platform.cs +++ b/SDL3/ImGuiSDL3Platform.cs @@ -969,7 +969,7 @@ public unsafe static class ImGuiSDL3Platform { ViewPortData vd = ImGuiUserData.Get(viewport.PlatformUserData)!; - string? oldHint = SDL.GetHint(SDL.Hints.WindowActivateWhenShown); + string oldHint = SDL.GetHint(SDL.Hints.WindowActivateWhenShown)!; SDL.SetHint(SDL.Hints.WindowActivateWhenShown, (viewport.Flags & ImGuiViewportFlags.NoFocusOnAppearing) != 0 ? "0" : "1"); diff --git a/SDL3/SDL3Window.cs b/SDL3/SDL3Window.cs index 2be215f..1970d6a 100644 --- a/SDL3/SDL3Window.cs +++ b/SDL3/SDL3Window.cs @@ -2,7 +2,6 @@ using Hexa.NET.ImGui; using Hexa.NET.ImGuizmo; using Hexa.NET.ImPlot; -using Hexa.NET.ImPlot3D; using SDL3; namespace SDL3_TestingSuite.SDL3; @@ -11,19 +10,25 @@ public sealed unsafe class SDL3Window : IDisposable { public readonly nint Window; public readonly nint Renderer; + + public readonly Vector4 DefaultClearColor = new Vector4(0.06f, 0.06f, 0.06f, 1f); - public event Action RenderCallback; + private Vector4? _clearColor; + public Vector4 ClearColor + { + get => _clearColor ?? DefaultClearColor; + set => _clearColor = value; + } - public Vector4 ClearColor = new Vector4(0.06f, 0.05882353f, 0.05882353f, 1f); + public event Action? RenderCallback; private ImGuiContextPtr _imGuiContext; private ImPlotContextPtr _imPlotContext; - private ImPlot3DContextPtr _imPlot3DContext; public bool Disposed => _disposed; private bool _disposed; - private FileSystemWatcher? _watcher; + private readonly FileSystemWatcher? _watcher; public SDL3Window(string name, int posX, int posY, int width, int height, SDL.WindowFlags flags = SDL.WindowFlags.Resizable | SDL.WindowFlags.HighPixelDensity) { @@ -41,10 +46,8 @@ public sealed unsafe class SDL3Window : IDisposable // Create ImGui context _imGuiContext = ImGui.CreateContext(); _imPlotContext = ImPlot.CreateContext(); - // _imPlot3DContext = ImPlot3D.CreateContext(); ImPlot.SetImGuiContext(_imGuiContext); ImGuizmo.SetImGuiContext(_imGuiContext); - // ImPlot3D.SetImGuiContext(_imGuiContext); ImGuiIOPtr io = ImGui.GetIO(); io.ConfigFlags |= ImGuiConfigFlags.NavEnableKeyboard | ImGuiConfigFlags.NavEnableGamepad | ImGuiConfigFlags.DockingEnable; @@ -60,7 +63,7 @@ public sealed unsafe class SDL3Window : IDisposable _watcher = new FileSystemWatcher(fontsPath); _watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.CreationTime; - _watcher.Created += (a, b) => + _watcher.Created += (_, b) => { if (!File.Exists(b.FullPath)) return; @@ -68,7 +71,7 @@ public sealed unsafe class SDL3Window : IDisposable ImGui.GetIO().AddFont(b.FullPath); }; - _watcher.Deleted += (a, b) => + _watcher.Deleted += (_, b) => { if (Path.GetExtension(b.FullPath) != ".ttf") return; @@ -180,10 +183,6 @@ public sealed unsafe class SDL3Window : IDisposable { ImPlot.SetCurrentContext(_imPlotContext); } - // if (_imPlot3DContext.Handle != null) - // { - // ImPlot3D.SetCurrentContext(_imPlot3DContext); - // } ImGuiSDL3Renderer.Dispose(); ImGuiSDL3Platform.Dispose(); @@ -203,12 +202,6 @@ public sealed unsafe class SDL3Window : IDisposable ImPlot.DestroyContext(_imPlotContext); _imPlotContext = null; } - // if (_imPlot3DContext.Handle != null) - // { - // ImPlot3D.SetCurrentContext(null); - // ImPlot3D.DestroyContext(_imPlot3DContext); - // _imPlot3DContext = null; - // } if (Renderer != nint.Zero) {