a
This commit is contained in:
@@ -5,7 +5,6 @@ using Hexa.NET.ImGui;
|
|||||||
using Hexa.NET.ImPlot;
|
using Hexa.NET.ImPlot;
|
||||||
using HexaGen.Runtime;
|
using HexaGen.Runtime;
|
||||||
using SDL3_TestingSuite.SDL3;
|
using SDL3_TestingSuite.SDL3;
|
||||||
using SDL3;
|
|
||||||
|
|
||||||
namespace SDL3_TestingSuite;
|
namespace SDL3_TestingSuite;
|
||||||
|
|
||||||
|
|||||||
@@ -16,10 +16,10 @@
|
|||||||
<PackageReference Include="Hexa.NET.ImGui.Widgets" Version="1.2.18" />
|
<PackageReference Include="Hexa.NET.ImGui.Widgets" Version="1.2.18" />
|
||||||
<PackageReference Include="Hexa.NET.ImNodes" Version="2.2.9" />
|
<PackageReference Include="Hexa.NET.ImNodes" Version="2.2.9" />
|
||||||
<PackageReference Include="Hexa.NET.ImPlot" 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.OpenGL4" Version="1.1.0" />
|
||||||
<PackageReference Include="Hexa.NET.SDL3.Image" Version="1.0.0" />
|
<PackageReference Include="Hexa.NET.SDL3.Image" Version="1.0.0" />
|
||||||
<PackageReference Include="Hexa.NET.Utilities" Version="2.2.12" />
|
<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" Version="3.2.18" />
|
||||||
<PackageReference Include="SDL3-CS.Native" Version="3.2.18" />
|
<PackageReference Include="SDL3-CS.Native" Version="3.2.18" />
|
||||||
<PackageReference Include="SDL3-CS.Native.Image" Version="3.3.0" />
|
<PackageReference Include="SDL3-CS.Native.Image" Version="3.3.0" />
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using Elements.Assets;
|
|
||||||
using Hexa.NET.ImGui;
|
using Hexa.NET.ImGui;
|
||||||
using Hexa.NET.OpenGL;
|
using Hexa.NET.OpenGL;
|
||||||
using SDL3;
|
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)
|
public static OpenGLTexture FromSurface(GL gl, nint surface, string? path = null)
|
||||||
{
|
{
|
||||||
if (surface == nint.Zero)
|
if (surface == nint.Zero)
|
||||||
|
|||||||
+31
-2
@@ -2,6 +2,7 @@
|
|||||||
using Hexa.NET.ImGui;
|
using Hexa.NET.ImGui;
|
||||||
using Hexa.NET.ImGuizmo;
|
using Hexa.NET.ImGuizmo;
|
||||||
using Hexa.NET.ImPlot;
|
using Hexa.NET.ImPlot;
|
||||||
|
using Hexa.NET.ImNodes;
|
||||||
using Hexa.NET.OpenGL;
|
using Hexa.NET.OpenGL;
|
||||||
using HexaGen.Runtime;
|
using HexaGen.Runtime;
|
||||||
using SDL3;
|
using SDL3;
|
||||||
@@ -23,10 +24,14 @@ public sealed unsafe class SDL3Window : IDisposable
|
|||||||
|
|
||||||
public event Action? RenderCallback;
|
public event Action? RenderCallback;
|
||||||
public event Action? Disposing;
|
public event Action? Disposing;
|
||||||
|
public event Action<Vector4>? Resized;
|
||||||
|
public event Action<SDL.Event>? EventCallback;
|
||||||
|
|
||||||
private ImGuiContextPtr _imGuiContext;
|
private ImGuiContextPtr _imGuiContext;
|
||||||
private ImPlotContextPtr _imPlotContext;
|
private ImPlotContextPtr _imPlotContext;
|
||||||
|
private ImNodesContextPtr _imNodesContext;
|
||||||
|
// private ImPLot3DContextPtr _imPlot3DContext;
|
||||||
|
|
||||||
public bool Disposed => _disposed;
|
public bool Disposed => _disposed;
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
|
|
||||||
@@ -71,9 +76,13 @@ public sealed unsafe class SDL3Window : IDisposable
|
|||||||
// Create ImGui context
|
// Create ImGui context
|
||||||
_imGuiContext = ImGui.CreateContext();
|
_imGuiContext = ImGui.CreateContext();
|
||||||
_imPlotContext = ImPlot.CreateContext();
|
_imPlotContext = ImPlot.CreateContext();
|
||||||
|
_imNodesContext = ImNodes.CreateContext();
|
||||||
|
// _imPlot3DContext = ImPlot3D.CreateContext();
|
||||||
ImPlot.SetImGuiContext(_imGuiContext);
|
ImPlot.SetImGuiContext(_imGuiContext);
|
||||||
ImGuizmo.SetImGuiContext(_imGuiContext);
|
ImGuizmo.SetImGuiContext(_imGuiContext);
|
||||||
|
ImNodes.SetImGuiContext(_imGuiContext);
|
||||||
|
// ImPlot3D.SetImGuiContext(_imGuiContext);
|
||||||
|
|
||||||
ImGuiIOPtr io = ImGui.GetIO();
|
ImGuiIOPtr io = ImGui.GetIO();
|
||||||
io.ConfigFlags |= ImGuiConfigFlags.NavEnableKeyboard | ImGuiConfigFlags.NavEnableGamepad | ImGuiConfigFlags.DockingEnable;
|
io.ConfigFlags |= ImGuiConfigFlags.NavEnableKeyboard | ImGuiConfigFlags.NavEnableGamepad | ImGuiConfigFlags.DockingEnable;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags.ViewportsEnable;
|
io.ConfigFlags |= ImGuiConfigFlags.ViewportsEnable;
|
||||||
@@ -143,7 +152,15 @@ public sealed unsafe class SDL3Window : IDisposable
|
|||||||
case SDL.EventType.Quit:
|
case SDL.EventType.Quit:
|
||||||
ShouldClose = true;
|
ShouldClose = true;
|
||||||
break;
|
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))
|
if (SDL.GetWindowFlags(Window).HasFlag(SDL.WindowFlags.Minimized))
|
||||||
@@ -238,6 +255,18 @@ public sealed unsafe class SDL3Window : IDisposable
|
|||||||
ImPlot.DestroyContext(_imPlotContext);
|
ImPlot.DestroyContext(_imPlotContext);
|
||||||
_imPlotContext = null;
|
_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)
|
// if (Renderer != nint.Zero)
|
||||||
// {
|
// {
|
||||||
|
|||||||
Reference in New Issue
Block a user