ImGui DirectX11 Implementation
Summary of the PR
This PR introduces initial support for ImGui with DirectX11 in Silk.NET. It includes:
- C# rewriting of imgui_impl_dx11.cpp for Silk.NET.
- ImGui controller very similar to the existing OpenGL implementation as well as the Lab Vulkan implementation (actually I copied most, if not all, the code from the OpenGL controller).
- Minimal sample following the existing OpenGL ImGui demo to demonstrate ImGui usage with DirectX11 (not started yet).
Related issues, Discord discussions, or proposals
Current progress
- [x] Working prototype in my own project see
- [x] Create directory & project under
/src/Lab/Experiments/ImGui_DX11/ - [x] Create
ImGui_Impl_DX11.cs(C++ port) and the associatedImGuiDX11Controller.cs- Not sure if I should keep those 2 files separated though? I am sticking to the original C++ file as DX11 code is a bit verbose and the controller would reach +1k lines very fast.
- [x] Create another directory and a sample minimal project to demonstrate
- [ ] Solve TODOs and clean up the code
Further Comments
The changes should not introduce any breaking API or behavioral changes: they will extend the functionality of Silk.NET.
Tested on
- Silk.NET v2.22.0
- ImGui.NET v1.91.6.1
Remarks
This is actually my first PR to such a large open-source repo. Any help, constructive criticism, remarks, suggestions, improvements and feedback are greatly appreciated!
@dotnet-policy-service agree
I have pushed my prototype code all in one. My apologize for the long files!
As a recap:
ImGuiDX11Controller.csis mostly a copy paste from the existing OpenGL controller implementation, I replaced OpenGL calls by calls toImGui_Impl_DX11.csequivalent functions. Also assigned DirectXhwndhandle to ImGui (taken from imgui_impl_win32.cpp). Not a lot of changes there.ImGui_Impl_DX11.csis the full port of the original C++ and header (linked in theREADME.txt)ImGuiFontConfig.csimported from the OpenGL impl, no changes at all.- I created the
.csprojfile linking the necessary dependencies inside Silk.NET repo ⚠️never compiled yet!⚠️
No worries. Is this ready for review? (it's still marked as draft :P)
Not yet, I've set aside my compilation issues and improved the code to support .NET 6.0 features (instead of the .NET 9.0 I created my prototype on). So, the code needs at least C# 12 to compile, I'll push that ASAP (probably beginning of next week) then it'll be ready for review!
I've also made a minimal sample that works which I'll push soon afterwards.
Hey, I think this PR is now ready for review (I provided a sample as well).
There are still work to do (tell me if you need comments/self-explanatory code anywhere, this won't bother me). Most TODOs are out of my knowledge, there's one to check out as it can cause issues later: https://github.com/dotnet/Silk.NET/pull/2409/files#diff-8c4147963edd0bf7166adef79bb3a37e316e17b1d610f2591590f81e6acd4ab9R593 It's the part where we revert back the state of the whole pipeline, I still don't understand how the bindings work with pointers to retrieve/restore arrays of viewports.
And sorry for the long wait also.