HexaEngine / Hexa.NET.ImGui

A .NET wrapper for the Dear ImGui.
Other
81 stars 7 forks source link
bindings codegenerator csharp imgui wrapper

Hexa.NET.ImGui

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.

Features

🎉 Acknowledgment to Our Sponsors

We extend our heartfelt gratitude to all our sponsors for their generous support!

Your contributions help keep this project thriving—thank you!

Community

Packages

Hexa.NET.ImGui is divided into four different packages to provide modularity and flexibility. You can choose to install only the packages you need:

Releated Projects

Getting Started

To get started with Hexa.NET.ImGui, follow these steps:

  1. 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
  2. Initialize the library in your project:

    using Hexa.NET.ImGui;
    // Your initialization code here
  3. Explore the demos to see the library in action.

Usage Example

For a comprehensive example of how to use the library, refer to the ExampleD3D11 project ExampleOpenGL3 project.

Setup Guide

For details on how to set up the library, check the ImGuiManager.cs file in the ExampleFramework project.

Using the Flexible and Optimized API

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:

  1. Safe API Call:
ImGui.Text("A normal C# string");
  1. Unsafe API Call:

    unsafe
    {
    byte* pText = (byte*)Marshal.StringToHGlobalAnsi("A string from an unsafe pointer").ToPointer();
    ImGui.Text(pText);
    Marshal.FreeHGlobal((IntPtr)pText);
    }
  2. 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.

Projects Using Hexa.NET.ImGui

HexaEngine

HexaEngine Editor

Screenshots

Main Interface

Screenshot 2023-05-23 163105

Multi Viewport Support

Screenshot 2023-07-07 153108

Contributing

Contributions are welcome! If you have ideas for improvements or new features, feel free to submit a pull request or open an issue.

Credits

License

This project is licensed under the MIT License. See the LICENSE file for more details.