ktsu.ImGuiApp
2.0.7-pre.1
Prefix Reserved
See the version list below for details.
dotnet add package ktsu.ImGuiApp --version 2.0.7-pre.1
NuGet\Install-Package ktsu.ImGuiApp -Version 2.0.7-pre.1
<PackageReference Include="ktsu.ImGuiApp" Version="2.0.7-pre.1" />
<PackageVersion Include="ktsu.ImGuiApp" Version="2.0.7-pre.1" />
<PackageReference Include="ktsu.ImGuiApp" />
paket add ktsu.ImGuiApp --version 2.0.7-pre.1
#r "nuget: ktsu.ImGuiApp, 2.0.7-pre.1"
#:package ktsu.ImGuiApp@2.0.7-pre.1
#addin nuget:?package=ktsu.ImGuiApp&version=2.0.7-pre.1&prerelease
#tool nuget:?package=ktsu.ImGuiApp&version=2.0.7-pre.1&prerelease
ktsu.ImGuiApp
A .NET library that provides application scaffolding for Dear ImGui, using Silk.NET and Hexa.NET.ImGui.
Introduction
ImGuiApp is a .NET library that provides application scaffolding for Dear ImGui, using Silk.NET for OpenGL and window management and Hexa.NET.ImGui for the ImGui bindings. It simplifies the creation of ImGui-based applications by abstracting away the complexities of window management, rendering, and input handling.
Features
- Simple API: Create ImGui applications with minimal boilerplate code
- Full Integration: Seamless integration with Silk.NET for OpenGL and input handling
- Window Management: Automatic window state, rendering, and input handling
- DPI Awareness: Built-in support for high-DPI displays and scaling
- Font Management: Flexible font loading system with customization options
- Texture Support: Built-in texture management for ImGui
- Lifecycle Callbacks: Customizable delegate callbacks for application events
- Menu System: Easy-to-use API for creating application menus
- Positioning Guards: Offscreen positioning checks to keep windows visible
- Modern .NET: Supports .NET 8 and newer
- Active Development: Open-source and actively maintained
Getting Started
Prerequisites
- .NET 8.0 or later
- Windows OS (for DPI awareness features)
Installation
Package Manager Console
Install-Package ktsu.ImGuiApp
.NET CLI
dotnet add package ktsu.ImGuiApp
Package Reference
<PackageReference Include="ktsu.ImGuiApp" Version="x.y.z" />
Usage Examples
Basic Application
Create a new class and call ImGuiApp.Start()
with your application config:
using ktsu.ImGuiApp;
using Hexa.NET.ImGui;
static class Program
{
static void Main()
{
ImGuiApp.Start(new ImGuiAppConfig()
{
Title = "ImGuiApp Demo",
OnStart = () => { /* Initialization code */ },
OnUpdate = delta => { /* Logic updates */ },
OnRender = delta => { ImGui.Text("Hello, ImGuiApp!"); },
OnAppMenu = () =>
{
if (ImGui.BeginMenu("File"))
{
// Menu items
if (ImGui.MenuItem("Exit"))
{
ImGuiApp.Stop();
}
ImGui.EndMenu();
}
}
});
}
}
Custom Font Management
Use the resource designer to add font files to your project, then load the fonts:
ImGuiApp.Start(new()
{
Title = "ImGuiApp Demo",
OnRender = OnRender,
Fonts = new Dictionary<string, byte[]>
{
{ nameof(Resources.MY_FONT), Resources.MY_FONT }
},
});
Or load the font data manually:
var fontData = File.ReadAllBytes("path/to/font.ttf");
ImGuiApp.Start(new()
{
Title = "ImGuiApp Demo",
OnRender = OnRender,
Fonts = new Dictionary<string, byte[]>
{
{ "MyFont", fontData }
},
});
Then apply the font to ImGui using the FontAppearance
class:
private static void OnRender(float deltaTime)
{
ImGui.Text("Hello, I am normal text!");
using (new FontAppearance("MyFont", 24))
{
ImGui.Text("Hello, I am BIG fancy text!");
}
using (new FontAppearance(32))
{
ImGui.Text("Hello, I am just huge text!");
}
using (new FontAppearance("MyFont"))
{
ImGui.Text("Hello, I am somewhat fancy!");
}
}
Texture Management
Load and manage textures with the built-in texture management system:
private static void OnRender(float deltaTime)
{
// Load texture from file path
var textureInfo = ImGuiApp.GetOrLoadTexture("path/to/texture.png");
// Use the texture in ImGui (using the new TextureRef API for Hexa.NET.ImGui)
ImGui.Image(textureInfo.TextureRef, new Vector2(128, 128));
// Clean up when done (optional - textures are cached and managed automatically)
ImGuiApp.DeleteTexture(textureInfo);
}
Full Application with Multiple Windows
using ktsu.ImGuiApp;
using Hexa.NET.ImGui;
using System.Numerics;
class Program
{
private static bool _showDemoWindow = true;
private static bool _showCustomWindow = true;
static void Main()
{
ImGuiApp.Start(new ImGuiAppConfig
{
Title = "Advanced ImGuiApp Demo",
Width = 1280,
Height = 720,
OnStart = OnStart,
OnUpdate = OnUpdate,
OnRender = OnRender,
OnAppMenu = OnAppMenu,
OnShutdown = OnShutdown
});
}
private static void OnStart()
{
// Initialize your application state
Console.WriteLine("Application started");
}
private static void OnUpdate(float deltaTime)
{
// Update your application state
// This runs before rendering each frame
}
private static void OnRender(float deltaTime)
{
// ImGui demo window
if (_showDemoWindow)
ImGui.ShowDemoWindow(ref _showDemoWindow);
// Custom window
if (_showCustomWindow)
{
ImGui.Begin("Custom Window", ref _showCustomWindow);
ImGui.Text($"Frame time: {deltaTime * 1000:F2} ms");
ImGui.Text($"FPS: {1.0f / deltaTime:F1}");
if (ImGui.Button("Click Me"))
Console.WriteLine("Button clicked!");
ImGui.ColorEdit3("Background Color", ref _backgroundColor);
ImGui.End();
}
}
private static void OnAppMenu()
{
if (ImGui.BeginMenu("File"))
{
if (ImGui.MenuItem("Exit"))
ImGuiApp.Stop();
ImGui.EndMenu();
}
if (ImGui.BeginMenu("Windows"))
{
ImGui.MenuItem("Demo Window", string.Empty, ref _showDemoWindow);
ImGui.MenuItem("Custom Window", string.Empty, ref _showCustomWindow);
ImGui.EndMenu();
}
}
private static void OnShutdown()
{
// Clean up resources
Console.WriteLine("Application shutting down");
}
private static Vector3 _backgroundColor = new Vector3(0.45f, 0.55f, 0.60f);
}
API Reference
ImGuiApp
Static Class
The main entry point for creating and managing ImGui applications.
Methods
Name | Parameters | Return Type | Description |
---|---|---|---|
Start |
ImGuiAppConfig config |
void |
Starts the ImGui application with the provided configuration |
Stop |
void |
Stops the running application | |
GetOrLoadTexture |
string path |
ImGuiAppTextureInfo |
Loads a texture from file or returns cached texture info if already loaded |
TryGetTexture |
string path, out ImGuiAppTextureInfo textureInfo |
bool |
Attempts to get a cached texture by path |
DeleteTexture |
uint textureId |
void |
Deletes a texture and frees its resources |
DeleteTexture |
ImGuiAppTextureInfo textureInfo |
void |
Deletes a texture and frees its resources (convenience overload) |
GetWindowSize |
Vector2 |
Returns the current window size | |
SetClipboardText |
string text |
void |
Sets the clipboard text |
GetClipboardText |
string |
Gets the clipboard text |
ImGuiAppConfig
Class
Configuration for the ImGui application.
Properties
Name | Type | Description |
---|---|---|
Title |
string |
The window title |
IconPath |
string |
The file path to the application window icon |
InitialWindowState |
ImGuiAppWindowState |
The initial state of the application window |
TestMode |
bool |
Whether the application is running in test mode |
Fonts |
Dictionary<string, byte[]> |
Font name to font data mapping |
OnStart |
Action |
Called when the application starts |
OnUpdate |
Action<float> |
Called each frame before rendering (param: delta time) |
OnRender |
Action<float> |
Called each frame for rendering (param: delta time) |
OnAppMenu |
Action |
Called each frame for rendering the application menu |
OnMoveOrResize |
Action |
Called when the application window is moved or resized |
SaveIniSettings |
bool |
Whether ImGui should save window settings to imgui.ini |
FontAppearance
Class
A utility class for applying font styles using a using statement.
Constructors
Constructor | Parameters | Description |
---|---|---|
FontAppearance |
string fontName |
Creates a font appearance with the named font at default size |
FontAppearance |
float fontSize |
Creates a font appearance with the default font at the specified size |
FontAppearance |
string fontName, float fontSize |
Creates a font appearance with the named font at the specified size |
Demo Application
Check out the included demo project to see a working example:
- Clone or download the repository
- Open the solution in Visual Studio (or run dotnet build)
- Start the ImGuiAppDemo project to see a basic ImGui application
Contributing
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Please make sure to update tests as appropriate and adhere to the existing coding style.
License
This project is licensed under the MIT License - see the LICENSE.md file for details.
Versioning
Check the CHANGELOG.md for detailed release notes and version changes.
Acknowledgements
- Dear ImGui - The immediate mode GUI library
- Hexa.NET.ImGui - .NET bindings for Dear ImGui
- Silk.NET - .NET bindings for OpenGL and windowing
- All contributors and the .NET community for their support
Support
If you encounter any issues or have questions, please open an issue.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- Hexa.NET.ImGui (>= 2.2.8.4)
- ktsu.Invoker (>= 1.1.0)
- ktsu.ScopedAction (>= 1.1.2)
- ktsu.StrongPaths (>= 1.3.2)
- Silk.NET (>= 2.22.0)
- Silk.NET.Assimp (>= 2.22.0)
- Silk.NET.Direct3D12 (>= 2.22.0)
- Silk.NET.Input.Extensions (>= 2.22.0)
- Silk.NET.Input.Sdl (>= 2.22.0)
- Silk.NET.OpenGLES (>= 2.22.0)
- Silk.NET.OpenXR (>= 2.22.0)
- Silk.NET.Windowing.Sdl (>= 2.22.0)
- SixLabors.ImageSharp (>= 3.1.10)
- System.Text.Json (>= 9.0.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
2.1.7 | 383 | 8/8/2025 |
2.1.6 | 224 | 8/8/2025 |
2.1.5 | 244 | 8/7/2025 |
2.1.4 | 245 | 8/7/2025 |
2.1.3 | 148 | 7/30/2025 |
2.1.2 | 115 | 7/30/2025 |
2.1.1 | 502 | 7/24/2025 |
2.1.0 | 551 | 7/23/2025 |
2.0.12 | 551 | 7/22/2025 |
2.0.11 | 516 | 7/22/2025 |
2.0.10 | 516 | 7/22/2025 |
2.0.8 | 515 | 7/22/2025 |
2.0.7-pre.1 | 297 | 7/20/2025 |
2.0.6 | 167 | 7/18/2025 |
1.12.5-pre.13 | 140 | 4/28/2025 |
1.12.5-pre.12 | 132 | 4/28/2025 |
1.12.5-pre.11 | 146 | 4/28/2025 |
1.12.5-pre.10 | 139 | 4/28/2025 |
1.12.5-pre.9 | 154 | 4/28/2025 |
1.12.5-pre.8 | 120 | 4/27/2025 |
1.12.5-pre.7 | 117 | 4/27/2025 |
1.12.5-pre.6 | 116 | 4/27/2025 |
1.12.5-pre.5 | 63 | 4/26/2025 |
1.12.5-pre.4 | 72 | 4/25/2025 |
1.12.5-pre.3 | 142 | 4/8/2025 |
1.12.5-pre.2 | 121 | 4/4/2025 |
1.12.5-pre.1 | 126 | 4/4/2025 |
1.12.4 | 781 | 4/4/2025 |
1.12.3 | 297 | 3/30/2025 |
1.12.2 | 596 | 3/30/2025 |
1.12.1 | 134 | 3/29/2025 |
1.12.0 | 188 | 3/21/2025 |
1.11.1-pre.1 | 144 | 3/20/2025 |
1.11.0 | 217 | 3/19/2025 |
1.10.0 | 227 | 3/17/2025 |
1.9.0 | 163 | 3/15/2025 |
1.8.1 | 152 | 3/15/2025 |
1.8.0 | 243 | 3/14/2025 |
1.7.1 | 240 | 3/12/2025 |
1.7.0 | 266 | 3/12/2025 |
1.6.1-pre.1 | 141 | 3/12/2025 |
1.6.0 | 272 | 3/12/2025 |
1.5.1-pre.1 | 149 | 3/11/2025 |
1.5.0 | 344 | 3/7/2025 |
1.4.1-pre.3 | 186 | 3/6/2025 |
1.4.1-pre.2 | 79 | 2/19/2025 |
1.4.1-pre.1 | 92 | 2/17/2025 |
1.4.0 | 386 | 2/17/2025 |
1.3.1-pre.1 | 87 | 2/11/2025 |
1.3.0 | 831 | 2/7/2025 |
1.2.1-pre.1 | 80 | 2/6/2025 |
1.2.0 | 278 | 2/5/2025 |
1.1.0 | 1,066 | 1/5/2025 |
1.0.12 | 216 | 12/28/2024 |
1.0.12-pre.11 | 90 | 1/4/2025 |
1.0.12-pre.10 | 86 | 1/3/2025 |
1.0.12-pre.9 | 89 | 1/3/2025 |
1.0.12-pre.8 | 85 | 1/3/2025 |
1.0.12-pre.7 | 77 | 1/3/2025 |
1.0.12-pre.6 | 81 | 1/1/2025 |
1.0.12-pre.5 | 112 | 12/31/2024 |
1.0.12-pre.4 | 73 | 12/29/2024 |
1.0.12-pre.3 | 76 | 12/28/2024 |
1.0.12-pre.2 | 92 | 12/27/2024 |
1.0.12-pre.1 | 65 | 12/27/2024 |
1.0.11-pre.1 | 70 | 12/27/2024 |
1.0.10-pre.1 | 78 | 12/27/2024 |
1.0.9 | 162 | 12/26/2024 |
1.0.8 | 147 | 12/26/2024 |
1.0.7 | 155 | 12/25/2024 |
1.0.6 | 184 | 12/24/2024 |
1.0.5 | 160 | 12/23/2024 |
1.0.4 | 120 | 12/23/2024 |
1.0.3 | 290 | 12/19/2024 |
1.0.2 | 188 | 12/17/2024 |
1.0.1 | 205 | 12/13/2024 |
1.0.0 | 231 | 12/9/2024 |
1.0.0-alpha.76 | 138 | 12/7/2024 |
1.0.0-alpha.75 | 88 | 12/6/2024 |
1.0.0-alpha.74 | 116 | 12/5/2024 |
1.0.0-alpha.73 | 189 | 12/2/2024 |
1.0.0-alpha.72 | 77 | 12/2/2024 |
1.0.0-alpha.71 | 101 | 12/1/2024 |
1.0.0-alpha.70 | 103 | 11/30/2024 |
1.0.0-alpha.69 | 93 | 11/29/2024 |
1.0.0-alpha.68 | 126 | 11/28/2024 |
1.0.0-alpha.67 | 128 | 11/26/2024 |
1.0.0-alpha.66 | 178 | 11/21/2024 |
1.0.0-alpha.65 | 131 | 11/20/2024 |
1.0.0-alpha.64 | 142 | 11/17/2024 |
1.0.0-alpha.63 | 80 | 11/15/2024 |
1.0.0-alpha.62 | 104 | 11/14/2024 |
1.0.0-alpha.61 | 124 | 11/13/2024 |
1.0.0-alpha.60 | 173 | 11/7/2024 |
1.0.0-alpha.59 | 86 | 11/7/2024 |
1.0.0-alpha.58 | 107 | 11/6/2024 |
1.0.0-alpha.57 | 120 | 11/5/2024 |
1.0.0-alpha.56 | 225 | 11/2/2024 |
1.0.0-alpha.55 | 82 | 11/1/2024 |
1.0.0-alpha.54 | 361 | 10/18/2024 |
1.0.0-alpha.53 | 343 | 10/9/2024 |
1.0.0-alpha.52 | 114 | 10/8/2024 |
1.0.0-alpha.51 | 162 | 10/5/2024 |
1.0.0-alpha.50 | 101 | 10/4/2024 |
1.0.0-alpha.49 | 296 | 9/25/2024 |
1.0.0-alpha.48 | 109 | 9/24/2024 |
1.0.0-alpha.47 | 129 | 9/21/2024 |
1.0.0-alpha.46 | 119 | 9/19/2024 |
1.0.0-alpha.45 | 93 | 9/19/2024 |
1.0.0-alpha.44 | 105 | 9/19/2024 |
1.0.0-alpha.43 | 72 | 9/19/2024 |
1.0.0-alpha.42 | 114 | 9/19/2024 |
1.0.0-alpha.41 | 131 | 9/18/2024 |
1.0.0-alpha.40 | 92 | 9/18/2024 |
1.0.0-alpha.39 | 98 | 9/18/2024 |
1.0.0-alpha.38 | 90 | 9/18/2024 |
1.0.0-alpha.37 | 148 | 9/18/2024 |
1.0.0-alpha.36 | 248 | 9/14/2024 |
## v2.0.7-pre.1 (prerelease)
Changes since v2.0.6: