Welcome to Hexa.NET.ImGui! This custom wrapper is designed to be a high-performance, API-compatible alternative to ImGuiNET, offering enhanced speed, additional functionality, and comprehensive access to ImGui's internal structures. With optimizations that bring near C performance and significantly reduced startup times, Hexa.NET.ImGui provides the best of both worlds: the power of C and the productivity of C#.
The code generator in use HexaGen.
- Comprehensive Wrapper: Integrates the core Dear ImGui library along with essential addons such as ImGuizmo, ImNodes, and ImPlot.
- Backends: Includes a collection of native backends in the Hexa.NET.ImGui.Backends package. (incl. Android, Win32, OSX, D3D9, D3D10, D3D11, D3D12, Metal, OpenGL2, OpenGL3, Vulkan and extra packages for SDL2 and GLFW)
- FreeType Fonts: Allows better text rendering and colored fonts to be loaded.
- Multi Viewport Support: Enables seamless multi-viewport rendering for advanced UI scenarios.
- Active Development: Regular updates and improvements to ensure compatibility with the latest Dear ImGui features and .NET advancements.
- Trustworthy Builds: Native libraries are built using GitHub Actions for added trustworthiness and can be found here.
- Open Source: The source code for the native libraries is public and can be reviewed by anyone.
- Access to Internals: Allows users to access Dear ImGui internals for advanced customization and functionality.
- Drop in replacement for ImGuiNET Adapt to the library with minimal effort by simply changing the namespace.
- High performance Using a static VTable, all API calls are faster and startup time is reduced.
- Optimized String Handling: Overloads that bypass UTF-8 encoding and avoid allocations.
- Wide range .NET support: Supported versions net8.0, net7.0, netstandard2.1, netstandard2.0
We extend our heartfelt gratitude to all our sponsors for their generous support!
- @Doprez
- @qian-o
- @NotNite
- Mr Villa
Your contributions help keep this project thriving—thank you!
- Discord: https://discord.gg/VawN5d8HMh
Hexa.NET.ImGui is divided into four different packages to provide modularity and flexibility. You can choose to install only the packages you need:
- Hexa.NET.ImGui.Widgets
- A small framework making it easier working with ImGui in C# build on top of Hexa.NET.ImGui. It allows to capsulate Widgets in classes and manage them centralized, supporting dialogs that block other windows (incl. OpenFileDialog SaveFileDialog and more)
To get started with Hexa.NET.ImGui, follow these steps:
-
Install the NuGet packages:
For the core library:
dotnet add package Hexa.NET.ImGui
For ImGuizmo addon:
dotnet add package Hexa.NET.ImGuizmo
For ImNodes addon:
dotnet add package Hexa.NET.ImNodes
For ImPlot addon:
dotnet add package Hexa.NET.ImPlot
-
Initialize the library in your project:
using Hexa.NET.ImGui; // Your initialization code here
-
Explore the demos to see the library in action.
For a comprehensive example of how to use the library, refer to the ExampleD3D11 project ExampleOpenGL3 project.
For details on how to set up the library, check the ImGuiManager.cs file in the ExampleFramework project.
Hexa.NET.ImGui supports both safe and unsafe API calls, along with optimized string handling to bypass UTF-8 encoding and avoid allocations. Here are some examples:
- Safe API Call:
ImGui.Text("A normal C# string");
- Unsafe API Call:
unsafe
{
byte* pText = (byte*)Marshal.StringToHGlobalAnsi("A string from an unsafe pointer").ToPointer();
ImGui.Text(pText);
Marshal.FreeHGlobal((IntPtr)pText);
}
- Optimized String Handling:
ImGui.Text("A C# string"u8);
This overload bypasses UTF-8 encoding and avoids allocations, providing a highly optimized way to render text.
Contributions are welcome! If you have ideas for improvements or new features, feel free to submit a pull request or open an issue.
- ImGui.NET for the JSON parsing of the cimgui metadata.
- cimgui for the c interface.
- Dear ImGui
This project is licensed under the MIT License. See the LICENSE file for more details.