Skip to content

Conversation

@marcb152
Copy link

@marcb152 marcb152 commented Jan 9, 2025

Summary of the PR

This PR introduces initial support for ImGui with DirectX11 in Silk.NET. It includes:

Related issues, Discord discussions, or proposals

Current progress

  • Working prototype in my own project see
  • Create directory & project under /src/Lab/Experiments/ImGui_DX11/
  • Create ImGui_Impl_DX11.cs (C++ port) and the associated ImGuiDX11Controller.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.
  • 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!

…mpl_DX11 ported from Cpp file. WARNING: never compiled inside Silk.NET solution
@marcb152
Copy link
Author

marcb152 commented Jan 9, 2025

@dotnet-policy-service agree

@marcb152
Copy link
Author

marcb152 commented Jan 9, 2025

I have pushed my prototype code all in one. My apologize for the long files!

As a recap:

  • ImGuiDX11Controller.cs is mostly a copy paste from the existing OpenGL controller implementation, I replaced OpenGL calls by calls to ImGui_Impl_DX11.cs equivalent functions. Also assigned DirectX hwnd handle to ImGui (taken from imgui_impl_win32.cpp). Not a lot of changes there.
  • ImGui_Impl_DX11.cs is the full port of the original C++ and header (linked in the README.txt)
  • ImGuiFontConfig.cs imported from the OpenGL impl, no changes at all.
  • I created the .csproj file linking the necessary dependencies inside Silk.NET repo ⚠️never compiled yet!⚠️

@Perksey
Copy link
Member

Perksey commented Jan 12, 2025

No worries. Is this ready for review? (it's still marked as draft :P)

@marcb152
Copy link
Author

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.

…IntPtr conversion). csharp12 is required to pass readonly ref to dx wrapper. Still wasn't able to build inside the solution
@marcb152 marcb152 marked this pull request as ready for review January 21, 2025 19:24
@marcb152 marcb152 requested a review from a team as a code owner January 21, 2025 19:24
Demo is heavily inspired by the DX11 Tutorial 1.2 - HelloQuad. I tried to reduce the sample to a minimal state to show off ImGui.
@marcb152
Copy link
Author

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.

@Perksey Perksey enabled auto-merge (squash) January 7, 2026 20:44
@Perksey Perksey disabled auto-merge January 7, 2026 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants