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
-1
View File
@@ -5,7 +5,6 @@ using Hexa.NET.ImGui;
using Hexa.NET.ImPlot;
using HexaGen.Runtime;
using SDL3_TestingSuite.SDL3;
using SDL3;
namespace SDL3_TestingSuite;
+1 -1
View File
@@ -16,10 +16,10 @@
<PackageReference Include="Hexa.NET.ImGui.Widgets" Version="1.2.18" />
<PackageReference Include="Hexa.NET.ImNodes" Version="2.2.9" />
<PackageReference Include="Hexa.NET.ImPlot" Version="2.2.9" />
<PackageReference Include="Hexa.NET.ImPlot3D" Version="2.2.9" />
<PackageReference Include="Hexa.NET.OpenGL4" Version="1.1.0" />
<PackageReference Include="Hexa.NET.SDL3.Image" Version="1.0.0" />
<PackageReference Include="Hexa.NET.Utilities" Version="2.2.12" />
<PackageReference Include="Resonite.GameLibs" Version="2026.5.20.291" />
<PackageReference Include="SDL3-CS" Version="3.2.18" />
<PackageReference Include="SDL3-CS.Native" Version="3.2.18" />
<PackageReference Include="SDL3-CS.Native.Image" Version="3.3.0" />
-26
View File
@@ -1,5 +1,4 @@
using System.Numerics;
using Elements.Assets;
using Hexa.NET.ImGui;
using Hexa.NET.OpenGL;
using SDL3;
@@ -55,31 +54,6 @@ public sealed unsafe class OpenGLTexture : IDisposable
}
}
public static OpenGLTexture FromBitmap2D(GL gl, Bitmap2D bmp)
{
if (bmp == null) throw new ArgumentNullException(nameof(bmp));
int width = bmp.Size.x;
int height = bmp.Size.y;
// Ensure we upload RGBA8 as unsigned bytes
byte[] pixels = new byte[width * height * 4];
for (int y = 0; y < height; ++y)
{
for (int x = 0; x < width; ++x)
{
var p = bmp.GetPixel32(x, y);
int idx = (y * width + x) * 4;
pixels[idx + 0] = p.r;
pixels[idx + 1] = p.g;
pixels[idx + 2] = p.b;
pixels[idx + 3] = p.a;
}
}
uint tex = UploadRgba32FromPixels(gl, pixels, width, height);
return new OpenGLTexture(gl, tex, width, height);
}
public static OpenGLTexture FromSurface(GL gl, nint surface, string? path = null)
{
if (surface == nint.Zero)
+29
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,9 +24,13 @@ 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,8 +76,12 @@ 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;
@@ -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)
// {