Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@
<PrivateAssets>all</PrivateAssets>
</PackageVersion>
<PackageVersion Include="Hexa.NET.ImGui" Version="2.2.8.4" />
<PackageVersion Include="Hexa.NET.ImGuizmo" Version="2.2.8.4" />
<PackageVersion Include="Hexa.NET.ImNodes" Version="2.2.8.4" />
<PackageVersion Include="Hexa.NET.ImPlot" Version="2.2.8.4" />
<PackageVersion Include="ktsu.Invoker" Version="1.1.0" />
<PackageVersion Include="ktsu.ScopedAction" Version="1.1.2" />
<PackageVersion Include="ktsu.StrongPaths" Version="1.3.2" />
<PackageVersion Include="ktsu.Extensions" Version="1.5.6" />
<PackageVersion Include="ktsu.Semantics" Version="1.0.19" />
<PackageVersion Include="Silk.NET" Version="2.22.0" />
<PackageVersion Include="Silk.NET.Assimp" Version="2.22.0" />
<PackageVersion Include="Silk.NET.Direct3D12" Version="2.22.0" />
Expand All @@ -21,7 +25,7 @@
<PackageVersion Include="Silk.NET.OpenGLES" Version="2.22.0" />
<PackageVersion Include="Silk.NET.OpenXR" Version="2.22.0" />
<PackageVersion Include="Silk.NET.Windowing.Sdl" Version="2.22.0" />
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.10" />
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.11" />
<PackageVersion Include="System.Text.Json" Version="9.0.7" />
<!-- Test Dependencies -->
<PackageVersion Include="Moq" Version="4.20.72" />
Expand All @@ -33,11 +37,11 @@
<PackageVersion Include="Microsoft.Testing.Extensions.HotReload" Version="1.7.3" />
<PackageVersion Include="Microsoft.Testing.Extensions.Retry" Version="1.7.3" />
<PackageVersion Include="Microsoft.Testing.Extensions.TrxReport" Version="1.7.3" />
<PackageVersion Include="MSTest.TestAdapter" Version="3.9.3" />
<PackageVersion Include="MSTest.TestFramework" Version="3.9.3" />
<PackageVersion Include="MSTest.TestAdapter" Version="3.10.0" />
<PackageVersion Include="MSTest.TestFramework" Version="3.10.0" />
<PackageVersion Include="coverlet.msbuild" Version="6.0.4" />
<!-- SDK Dependencies -->
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="Microsoft.SourceLink.AzureRepos.Git" Version="8.0.0" />
</ItemGroup>
</Project>
</Project>
5 changes: 3 additions & 2 deletions ImGuiApp.Test/AdvancedCoverageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace ktsu.ImGuiApp.Test;
using System;
using Hexa.NET.ImGui;
using ktsu.ImGuiApp.ImGuiController;
using ktsu.Semantics;
using Microsoft.VisualStudio.TestTools.UnitTesting;

/// <summary>
Expand Down Expand Up @@ -179,8 +180,8 @@ public void ImGuiApp_WindowState_MultipleAccess_ReturnsConsistentValues()
[TestMethod]
public void ImGuiApp_Textures_MultipleAccess_ReturnsSameInstance()
{
System.Collections.Concurrent.ConcurrentDictionary<StrongPaths.AbsoluteFilePath, ImGuiAppTextureInfo> textures1 = ImGuiApp.Textures;
System.Collections.Concurrent.ConcurrentDictionary<StrongPaths.AbsoluteFilePath, ImGuiAppTextureInfo> textures2 = ImGuiApp.Textures;
System.Collections.Concurrent.ConcurrentDictionary<AbsoluteFilePath, ImGuiAppTextureInfo> textures1 = ImGuiApp.Textures;
System.Collections.Concurrent.ConcurrentDictionary<AbsoluteFilePath, ImGuiAppTextureInfo> textures2 = ImGuiApp.Textures;

// Should return the same collection instance
Assert.AreSame(textures1, textures2);
Expand Down
2 changes: 1 addition & 1 deletion ImGuiApp.Test/ImGuiAppCoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace ktsu.ImGuiApp.Test;

using System.Collections.Concurrent;
using ktsu.Extensions;
using ktsu.StrongPaths;
using ktsu.Semantics;
using Microsoft.VisualStudio.TestTools.UnitTesting;

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion ImGuiApp.Test/ImGuiAppDataStructureTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace ktsu.ImGuiApp.Test;

using System.Numerics;
using ktsu.Extensions;
using ktsu.StrongPaths;
using ktsu.Semantics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Silk.NET.Windowing;

Expand Down
4 changes: 1 addition & 3 deletions ImGuiApp.Test/ImGuiAppTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
// All rights reserved.
// Licensed under the MIT license.

using Microsoft.VisualStudio.TestTools.UnitTesting;

[assembly: DoNotParallelize]

namespace ktsu.ImGuiApp.Test;

using System.Numerics;
using ktsu.Extensions;
using ktsu.StrongPaths;
using ktsu.Semantics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Silk.NET.Core.Contexts;
Expand Down
3 changes: 1 addition & 2 deletions ImGuiApp.Test/ImGuiAppWindowManagementTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
namespace ktsu.ImGuiApp.Test;

using System.Numerics;

using ktsu.StrongPaths;
using ktsu.Semantics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Silk.NET.Windowing;
Expand Down
2 changes: 1 addition & 1 deletion ImGuiApp/DebugLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace ktsu.ImGuiApp;

using ktsu.Extensions;
using ktsu.StrongPaths;
using ktsu.Semantics;

/// <summary>
/// Simple file logger for debugging crashes
Expand Down
2 changes: 1 addition & 1 deletion ImGuiApp/ImGuiApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
using ktsu.ImGuiApp.ImGuiController;
using ktsu.Invoker;
using ktsu.ScopedAction;
using ktsu.StrongPaths;
using ktsu.Semantics;
using Silk.NET.Input;
using Silk.NET.OpenGL;
using Silk.NET.Windowing;
Expand All @@ -31,12 +31,12 @@
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling", Justification = "This class is the main entry point for the ImGui application and requires many dependencies. Consider refactoring in the future.")]
public static partial class ImGuiApp
{
internal static IWindow? window;

Check warning on line 34 in ImGuiApp/ImGuiApp.cs

View workflow job for this annotation

GitHub Actions / Build, Test & Release

Change the visibility of 'window' or make it 'const' or 'readonly'. (https://rules.sonarsource.com/csharp/RSPEC-2223)
internal static GL? gl;

Check warning on line 35 in ImGuiApp/ImGuiApp.cs

View workflow job for this annotation

GitHub Actions / Build, Test & Release

Change the visibility of 'gl' or make it 'const' or 'readonly'. (https://rules.sonarsource.com/csharp/RSPEC-2223)
internal static ImGuiController.ImGuiController? controller;

Check warning on line 36 in ImGuiApp/ImGuiApp.cs

View workflow job for this annotation

GitHub Actions / Build, Test & Release

Change the visibility of 'controller' or make it 'const' or 'readonly'. (https://rules.sonarsource.com/csharp/RSPEC-2223)
internal static IInputContext? inputContext;

Check warning on line 37 in ImGuiApp/ImGuiApp.cs

View workflow job for this annotation

GitHub Actions / Build, Test & Release

Change the visibility of 'inputContext' or make it 'const' or 'readonly'. (https://rules.sonarsource.com/csharp/RSPEC-2223)
internal static OpenGLProvider? glProvider;

Check warning on line 38 in ImGuiApp/ImGuiApp.cs

View workflow job for this annotation

GitHub Actions / Build, Test & Release

Change the visibility of 'glProvider' or make it 'const' or 'readonly'. (https://rules.sonarsource.com/csharp/RSPEC-2223)
internal static IntPtr currentGLContextHandle; // Track the current GL context handle

Check warning on line 39 in ImGuiApp/ImGuiApp.cs

View workflow job for this annotation

GitHub Actions / Build, Test & Release

Change the visibility of 'currentGLContextHandle' or make it 'const' or 'readonly'. (https://rules.sonarsource.com/csharp/RSPEC-2223)

internal static ImGuiAppWindowState LastNormalWindowState { get; set; } = new();

Expand All @@ -58,7 +58,7 @@
}

internal static ConcurrentDictionary<string, int> FontIndices { get; } = [];
internal static float lastFontScaleFactor;

Check warning on line 61 in ImGuiApp/ImGuiApp.cs

View workflow job for this annotation

GitHub Actions / Build, Test & Release

Change the visibility of 'lastFontScaleFactor' or make it 'const' or 'readonly'. (https://rules.sonarsource.com/csharp/RSPEC-2223)
internal static readonly List<GCHandle> currentPinnedFontData = [];

/// <summary>
Expand Down Expand Up @@ -91,8 +91,8 @@
/// </summary>
public static bool IsIdle { get; private set; }

internal static DateTime lastInputTime = DateTime.UtcNow;

Check warning on line 94 in ImGuiApp/ImGuiApp.cs

View workflow job for this annotation

GitHub Actions / Build, Test & Release

Change the visibility of 'lastInputTime' or make it 'const' or 'readonly'. (https://rules.sonarsource.com/csharp/RSPEC-2223)
internal static double targetFrameTimeMs = 1000.0 / 30.0; // Default to 30 FPS (33.33ms per frame)

Check warning on line 95 in ImGuiApp/ImGuiApp.cs

View workflow job for this annotation

GitHub Actions / Build, Test & Release

Change the visibility of 'targetFrameTimeMs' or make it 'const' or 'readonly'. (https://rules.sonarsource.com/csharp/RSPEC-2223)
internal static readonly PidFrameLimiter frameLimiter = new();
internal static double previousTargetFrameTimeMs = 1000.0 / 30.0;

Expand Down Expand Up @@ -510,7 +510,7 @@
{
// Temporarily keep console window visible for debugging
// if (OperatingSystem.IsWindows())
// {

Check warning on line 513 in ImGuiApp/ImGuiApp.cs

View workflow job for this annotation

GitHub Actions / Build, Test & Release

Remove this commented out code. (https://rules.sonarsource.com/csharp/RSPEC-125)
// DebugLogger.Log("ImGuiApp.Start: Hiding console window");
// nint handle = NativeMethods.GetConsoleWindow();
// NativeMethods.ShowWindow(handle, SW_HIDE);
Expand Down
3 changes: 2 additions & 1 deletion ImGuiApp/ImGuiApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@

<ItemGroup>
<PackageReference Include="Hexa.NET.ImGui" />
<PackageReference Include="ktsu.Extensions" />
<PackageReference Include="ktsu.Invoker" />
<PackageReference Include="ktsu.ScopedAction" />
<PackageReference Include="ktsu.StrongPaths" />
<PackageReference Include="ktsu.Semantics" />
<PackageReference Include="Silk.NET" />
<PackageReference Include="Silk.NET.Assimp" />
<PackageReference Include="Silk.NET.Direct3D12" />
Expand Down
2 changes: 1 addition & 1 deletion ImGuiApp/ImGuiAppTextureInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace ktsu.ImGuiApp;
using Hexa.NET.ImGui;
using ktsu.StrongPaths;
using ktsu.Semantics;

/// <summary>
/// Represents information about a texture, including its file path, texture ID, width, and height.
Expand Down
17 changes: 16 additions & 1 deletion ImGuiApp/ImGuiController/ImGuiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,16 @@ internal void Init(GL gl, IView view, IInputContext input)
_windowWidth = view.Size.X;
_windowHeight = view.Size.Y;

ImGui.CreateContext();
ImGuiContextPtr imguiContext = ImGui.CreateContext();

// Initialize ImGui extensions (ImGuizmo, ImNodes, ImPlot) if available
ImGuiExtensionManager.Initialize();

// Set the ImGui context for all extensions after context creation
ImGuiExtensionManager.SetImGuiContext(imguiContext);

// Create extension contexts and apply dark styles
ImGuiExtensionManager.CreateExtensionContexts();

ImGui.StyleColorsDark();
}
Expand All @@ -124,6 +133,9 @@ internal void BeginFrame()
{
ImGui.NewFrame();
_frameBegun = true;

// Call BeginFrame for all detected ImGui extensions
ImGuiExtensionManager.BeginFrame();
_keyboard = _input?.Keyboards[0];
_mouse = _input?.Mice[0];
if (_view is not null)
Expand Down Expand Up @@ -933,6 +945,9 @@ protected virtual void Dispose(bool disposing)
_fontTexture.Dispose();
_shader.Dispose();

// Cleanup extension contexts before destroying ImGui context
ImGuiExtensionManager.Cleanup();

ImGui.DestroyContext();
}
}
Expand Down
Loading