C.ImGuiGLFW
1.0.0.9
See the version list below for details.
dotnet add package C.ImGuiGLFW --version 1.0.0.9
NuGet\Install-Package C.ImGuiGLFW -Version 1.0.0.9
<PackageReference Include="C.ImGuiGLFW" Version="1.0.0.9" />
<PackageVersion Include="C.ImGuiGLFW" Version="1.0.0.9" />
<PackageReference Include="C.ImGuiGLFW" />
paket add C.ImGuiGLFW --version 1.0.0.9
#r "nuget: C.ImGuiGLFW, 1.0.0.9"
#:package C.ImGuiGLFW@1.0.0.9
#addin nuget:?package=C.ImGuiGLFW&version=1.0.0.9
#tool nuget:?package=C.ImGuiGLFW&version=1.0.0.9
A modern C# wrapper library that simplifies creating ImGui applications with OpenGL rendering and GLFW window management.
About
C.ImGuiGLFW is a C# class library that simplifies the creation of ImGui-rendered windows. It uses OpenGL 4.6 core for rendering, GLFW for window management system, and Hexa.NET.ImGui for ImGui integration.
Requirements
- .NET 9.0 or higher
- Windows (tested), macOS and Linux (untested)
- OpenGL 4.6 compatible graphics driver
Installation
Get C.ImGuiGLFW from NuGet using one of the following methods:
.NET CLI (Recommended)
dotnet add package C.ImGuiGLFW
Use this command in terminal/command prompt. Works on Windows, macOS, and Linux.
Package Manager Console
Install-Package C.ImGuiGLFW
Use this command in Visual Studio's Package Manager Console (Windows only).
NuGet Package Manager GUI
Alternatively, you can install via the graphical interface in Visual Studio or your preferred IDE by searching for "C.ImGuiGLFW".
Basic Setup
Initialize the ImGuiController in the Main() method of your program:
ImGuiController.Initialize("MyApplication", modules: Module.All);
The Initialize
method has multiple overloads to accommodate different initialization scenarios:
// Basic initialization with default settings
ImGuiController.Initialize();
// Initialize with modules
ImGuiController.Initialize(modules: Module.All);
// Initialize with window title
ImGuiController.Initialize("MyApp");
// Initialize with title and modules
ImGuiController.Initialize("MyApp", Module.All);
// Initialize with title and dimensions
ImGuiController.Initialize("MyApp", 800, 600);
// Initialize with title, dimensions, and modules
ImGuiController.Initialize("MyApp", 800, 600, Module.All);
// Initialize with dimensions only
ImGuiController.Initialize(800, 600);
// Initialize with dimensions and modules
ImGuiController.Initialize(800, 600, Module.All);
// Initialize with dimensions and position
ImGuiController.Initialize(800, 600, new Vector2(100, 100));
// Initialize with dimensions, position, and modules
ImGuiController.Initialize(800, 600, new Vector2(100, 100), Module.Guizmo);
// Initialize with dimensions, position, and resizable flag
ImGuiController.Initialize(800, 600, new Vector2(100, 100), true);
// Initialize with dimensions, position, resizable flag, and modules
ImGuiController.Initialize(800, 600, new Vector2(100, 100), true, Module.Nodes, Module Plot);
// Initialize with dimensions and position coordinates
ImGuiController.Initialize(800, 600, 100, 100);
// Initialize with dimensions, position coordinates, and modules
ImGuiController.Initialize(800, 600, 100, 100, Module.Plot);
// Initialize with custom WindowSettings
ImGuiController.Initialize(windowSettings);
// Initialize with custom WindowSettings and modules
ImGuiController.Initialize(windowSettings, Module.All);
Parameters:
windowSettings
: Custom window settings (optional, reads from file if null)title
: Window titlewidth
/height
: Window dimensions in pixelsposition
: Window position as Vector2 or separate X/Y coordinatesresizable
: Whether the window should be resizablemodules
: ImGui modules to initialize (optional params array)
Event Handling
Subscribe to various events to handle user input and UI rendering:
// Handle main menu bar rendering
ImGuiController.OnMainMenuBarRender += MainMenuBar;
// Handle character input events
ImGuiController.OnChar += OnCharInput;
Adding Windows
Create and add your custom ImGui windows:
var demoWindow = new DemoWindow();
ImGuiController.AddWindow(demoWindow);
Running the Application
Start the main application loop:
ImGuiController.Run();
Example
Here's a minimal example:
using System;
using C.ImGuiGLFW;
class Program
{
static void Main()
{
// Initialize ImGuiController
ImGuiController.Initialize("TESTWINDOW");
// Set up event handlers
ImGuiController.OnMainMenuBarRender += MainMenuBar;
ImGuiController.OnChar += OnCharInput;
// Create and add windows
var demoWindow = new DemoWindow();
ImGuiController.AddWindow(demoWindow);
// Start the application
ImGuiController.Run();
}
private static void MainMenuBar()
{
// Your main menu bar implementation
}
private static void OnCharInput(uint codepoint)
{
// Handle character input
}
}
Creating Custom Windows
To create custom windows, implement the appropriate window interface or base class:
public class DemoWIndow : Window
{
protected override void Draw()
{
ImGui.Text("Hello, World!");
}
}
Available Modules
The Module
enum allows you to specify which ImGui modules to initialize:
Module.All
: Load all available modulesModule.Guizmo
: ImGuizmo for 3D gizmo manipulationModule.Nodes
: ImNodes for node-based graph editingModule.Plot
: ImPlot for data plotting and visualization
Multiple modules can be specified:
// Load specific modules
ImGuiController.Initialize("MyApp", Module.Guizmo, Module.Plot);
// Load all modules (equivalent to Module.All)
ImGuiController.Initialize("MyApp", Module.Guizmo, Module.Nodes, Module.Plot);
More Examples
For more detailed examples and advanced usage patterns, please visit the here.
Feedback and Contributions
I welcome your feedback and contributions to make C.ImGuiGLFW even better! If you have:
Feature requests - Ideas for new functionality or improvements Bug reports - Issues you've encountered while using the library Method suggestions - Additional methods or overloads you'd find useful
Please feel free to submit an issue or pull request on the GitHub repository.
Your contributions help improve the library for everyone who uses it. I appreciate bug reports, feature suggestions, code improvements, and documentation enhancements.
Dependencies
This project depends on several NuGet packages. Run dotnet list package
to see current versions, or check THIRD-PARTY-NOTICES for license details.
Acknowledgments
This project builds upon the excellent work of many open source contributors:
Core Technologies
- Dear ImGui by Omar Cornut - The amazing immediate mode GUI library that makes this all possible
- GLFW - Multi-platform library for OpenGL, Vulkan, window and input
- OpenGL - The cross-platform graphics API
.NET Bindings & Utilities
- Hexa.NET Libraries by Juna Meinhold - Comprehensive .NET bindings for ImGui, GLFW, OpenGL and related libraries
- Hexa.NET.ImGui - C# bindings for Dear ImGui
- Hexa.NET.GLFW - C# bindings for GLFW
- Hexa.NET.OpenGL - C# bindings for OpenGL
- Hexa.NET.ImGuizmo - C# bindings for ImGuizmo
- Hexa.NET.ImNodes - C# bindings for ImNodes
- Hexa.NET.ImPlot - C# bindings for ImPlot
Additional Libraries
- ImGuizmo by Cédric Guillemet - 3D gizmo for scene editing
- ImNodes by Nelarius - Node editor for Dear ImGui
- ImPlot by Evan Pezent - Advanced plotting library for ImGui
- Serilog - Flexible logging library for .NET
- SixLabors.ImageSharp - Cross-platform image processing library
Microsoft Technologies
- .NET - The platform this library runs on
- Microsoft.CodeAnalysis - The .NET Compiler Platform ("Roslyn")
Special thanks to all the maintainers and contributors of these projects for making modern cross-platform GUI development in C# possible.
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.GLFW (>= 1.0.4)
- Hexa.NET.ImGui (>= 2.2.8.4)
- Hexa.NET.ImGui.Backends (>= 1.0.17.4)
- Hexa.NET.ImGui.Backends.GLFW (>= 1.0.17.4)
- Hexa.NET.ImGui.Widgets (>= 1.2.14)
- Hexa.NET.ImGui.Widgets.Extras (>= 1.0.6)
- Hexa.NET.ImGuizmo (>= 2.2.8.4)
- Hexa.NET.ImNodes (>= 2.2.8.4)
- Hexa.NET.ImPlot (>= 2.2.8.4)
- Hexa.NET.OpenGL.Core (>= 1.1.0)
- Hexa.NET.OpenGL4 (>= 1.1.0)
- Hexa.NET.Utilities (>= 2.2.2)
- MaterialColorUtilities (>= 0.3.0)
- Serilog (>= 4.3.0)
- Serilog.Sinks.Console (>= 6.0.0)
- Serilog.Sinks.File (>= 7.0.0)
- SixLabors.ImageSharp (>= 3.1.11)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.