Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose ImGui internals (experimental) using 1.85 WIP #273

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

JulianVallee
Copy link

@JulianVallee JulianVallee commented Sep 20, 2021

Description

Add changes to expose ImGui internals using ImGui 1.85 WIP. This PR is based on the fork of https://github.com/renenieuw/ImGui.NET (see #202) and is currently in experimental status.

The fork introduces a last-moment string replacement on the generated files to allow correcting code that has not been generated properly. While it seems to be working at the moment, it kinda defeats the whole purpose of the code generator and focus should be on fixing the remaining errors to get rid of it again. Still having a pull request might get this feature a bit more attention than a fork mentioned deep down in a random issue.

I have added an example using the internal DockBuilder API in the SampleProgram.XNA project. However, it's probably better to move these changes into a separate PR and the regular/a more advanced example app.. "I got carried away while refactoring" does not even come close, there are a lot of changes that are really unnecessary for this feature. I'm open to all ideas though!

The C binaries have been compiled using ImGuiNET/ImGui.NET-nativebuild#3. The CodeGenerator can now be invoked with a third argument to enable or disable exposing internals in the generated files: dotnet run -p src\CodeGenerator\CodeGenerator.csproj src\ImGui.NET\Generated cimgui true

Last but not least I have removed a non-existing reference from the ImPlot.NET project file, and the CodeGenerator can be forced to always copy the definition json files to the output folder by setting a environment variable: SET CopyToOutputDirectory=Always (any other value will fallback to the original behaviour of PreserveNewest)

Library Compiles with internal
ImGui.NET yes
ImPlot.NET no (is this important at all?)
ImGuizmo.NET yes
ImNodes.NET yes

Without DockingEnable flag
undocked

With DockingEnable flag
docked

Demo stuff is working too!
custom_rendering

Type of change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

I have implemented an example of the internal DockBuilder API inside the XNA sample.

  • SampleProgram
  • SampleProgram.XNA
  • ImGui Demo
  • My own DIY engine

Test Configuration:

  • OS: Windows 10 x64
  • Hardware: GTX 1080TI

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests examples that prove my fix is effective or that my feature works
  • Any dependent changes have been merged and published in downstream modules

@freakbyte
Copy link

Thanks for putting this together, experimental or not I will give it a shot. Not being able to predefine a docking layout makes it pretty annoying to use.

@Thraka
Copy link
Contributor

Thraka commented Jan 7, 2022

I really want this and access to the internals!!! 😁

@MarioGK
Copy link

MarioGK commented Apr 21, 2022

What else is needed for this pull request to be merged? more tests? features? I wanted to use this feature and maybe i can help out finishing this PR

@JulianVallee
Copy link
Author

What else is needed for this pull request to be merged? more tests? features? I wanted to use this feature and maybe i can help out finishing this PR

It's been a while since I worked on this, so bear with me if I miss something.

The generated code seems be mostly correct, but still has a few obvious errors whose cause I can't find on my own. The PostFixes class kind of documents all these errors, and does some string replace/remove on the generated code to make the compiler happy.

This approach works in theory, but has the obvious problem that we simply discard parts of the internals. It is also a pain to maintain, as we probably have to adjust these tweaks with every ImGui update. Therefore, we probably need to get rid of these monkey patches (basically remove the PostFixes file) as the next step.

I'll try to find some time to rebase the PR in the next couple days. If it doesn't break too many things I'll also update to ImGui 1.87, maybe it fixes some of the issues 👍

@MarioGK
Copy link

MarioGK commented Apr 21, 2022

@JulianVallee If you need any help tag me here, i can work with you if needed

@MarioGK
Copy link

MarioGK commented Apr 26, 2022

@JulianVallee I hope you dont mind but i stole a bit of your code and put on my own fork of imgui.net, i really want to test and use imgui, i gave you proper credits and i hope you dont mind.

https://github.com/MarioGK/ImGuiSharp/blob/main/CREDITS.md

@JulianVallee
Copy link
Author

@JulianVallee I hope you dont mind but i stole a bit of your code and put on my own fork of imgui.net, i really want to test and use imgui, i gave you proper credits and i hope you dont mind.

https://github.com/MarioGK/ImGuiSharp/blob/main/CREDITS.md

No not at all, feel free to use code of this PR in any way you want. Credits are highly appreciated, but wouldn't have been necessary!

PS: Noticed the discord link in your readme.md doesn't work, the link is broken.

@zzxzzk115
Copy link

It works fine on Windows, but on Linux, some APIs give the error EntryPoint not found, such as ImGui.PushStyleVar, ImGui.TreeNode, etc. How can I fix this problem?

@zaafar
Copy link
Collaborator

zaafar commented Apr 30, 2022

It works fine on Windows, but on Linux, some APIs give the error EntryPoint not found, such as ImGui.PushStyleVar, ImGui.TreeNode, etc. How can I fix this problem?

Maybe, it is time to move this discussion on that repo? It will help that repo grow and become as awesome as imgui.net.

@MarioGK
Copy link

MarioGK commented May 4, 2022

@zzxzzk115 If you want to talk about this please move to my repo https://github.com/MarioGK/ImGuiSharp
OBS: I am rewriting the code generator from scratch using C#'s source generator and templates to make it easier to edit the source code, it will take a while before i prioritize building for linux and mac
@JulianVallee Fixed the discord link, i forgot to properly create an invite link

@zzxzzk115
Copy link

@zzxzzk115 If you want to talk about this please move to my repo https://github.com/MarioGK/ImGuiSharp OBS: I am rewriting the code generator from scratch using C#'s source generator and templates to make it easier to edit the source code, it will take a while before i prioritize building for linux and mac @JulianVallee Fixed the discord link, i forgot to properly create an invite link

That's great! Ok I'll keep watching on your repo.

@Shadowblitz16
Copy link

Does this expose the Impli methods that make implementing imgui for some api's easier?

@Hi-ImKyle
Copy link

Works to a degree but using this on the latest version 1.89.3 causes so many errors it's pointless me even thinking about listing them all. What will it take to make this work with the latest ImGui version in order to update ImGui.NET to 1.89.3?

@VELD-Dev
Copy link

VELD-Dev commented Aug 23, 2024

I'm following this PR. Dockbuilder is something I'm very hyped about.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants