Reloaded.Imgui.Hook is a simple personal use utility library that can be used to inject Dear ImGui into the current process.
It is based off of DearImguiSharp, my personal use bindings library for Dear ImGui built ontop of cimgui.
Install Reloaded.Imgui.Hook
from NuGet and/or the required implementations of your choice
- Direct3D9:
Reloaded.Imgui.Hook.Direct3D9
- Direct3D11:
Reloaded.Imgui.Hook.Direct3D11
First call SDK.Init
to initialize all static variables used by the library, then simply call ImguiHook.Create
with an appropriate delegate.
// During initialization.
SDK.Init(_hooks);
_imguiHook = await ImguiHook.Create(RenderTestWindow, new ImguiHookOptions()
{
Implementations = new List<IImguiHook>()
{
new ImguiHookDx9(), // `Reloaded.Imgui.Hook.Direct3D9`
new ImguiHookDx11() // `Reloaded.Imgui.Hook.Direct3D11`
}
}).ConfigureAwait(false);
private void RenderTestWindow()
{
ImGuiNET.ImGui.ShowDemoWindow();
}
The _hooks
variable is an instance of IReloadedHooks
from Reloaded.Hooks. In a Reloaded-II mod, this is part of your mod template. Otherwise, add Reloaded.Hooks to your project and pass new ReloadedHooks()
to the method.
Use the specialised overload with ImguiHookOptions
.
await ImguiHook.Create(RenderTestWindow, new ImguiHookOptions()
{
EnableViewports = true, // Enable docking.
IgnoreWindowUnactivate = true // May help if game pauses when it loses focus.
}).ConfigureAwait(false);
// Deactivate
_imguiHook.Disable();
// Activate
_imguiHook.Enable();
Leveraging the capabilities of Reloaded.Hooks, you can even unload your Assembly (DLL) from the process once you disable if you wish.
- D3D9
- D3D9Ex
- D3D11
Implemented backends should support window resizing and device resets (fullscreen/windowed switching) etc.
Will implement D3D10 if there's any demand.
- Extensibility. Provide workarounds for possible edge cases such as SRGB colour space.
If you would like to try the library, try the test mod for Reloaded-II available in this repository.
Simply compile Reloaded.ImGui.TestMod
and add to your Reloaded-II mods directory.
- [14 August 2021]: When viewports are Enabled and being used (window outside app/game window), destroying the hook instance (and this imgui context) may crash the application. I believe this a dear imgui issue.
Contributions are very welcome and encouraged; especially given that I'm not really a graphics programmer. I only have some experience in OpenGL 3 as opposed to DirectX 😉.
Feel free to implement new features, make bug fixes or suggestions so long as they are accompanied by an issue with a clear description of the pull request.