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

Question: Supporting 3rd party C++ ImGui Widgets #15

Open
KCoen opened this issue Feb 14, 2023 · 1 comment
Open

Question: Supporting 3rd party C++ ImGui Widgets #15

KCoen opened this issue Feb 14, 2023 · 1 comment

Comments

@KCoen
Copy link
Contributor

KCoen commented Feb 14, 2023

Hey,

Since these bindings are generated through CppSharp, I am guessing it should be easier to generate bindings for 3rd party C++ Widgets,

I was wondering if you could provide some steps/guidance on how to develop these C# bindings, for example for: github/thedmd/imgui-node-editor

@aybe
Copy link
Owner

aybe commented Feb 15, 2023

For implot, I proceeded like so:

  • in implot subdirectory, I added it as a submodule at the appropriate tag
  • then added a DLL project with minimal changes, e.g. IntDir, OutDir, PreprocessorDefinitions, ProjectReference, sources
  • once that builds, I updated dearimgui-build.cmd so it's easier to trigger in VSCode terminal (builds both 32-bit/64-bit native DLLs for managed project)

Then, a managed project is slightly more involved:

  • again, with minimal changes, I reused most code of DearGenerator and DearImGui.Generator in DearImPlot.Generator
  • after that, it's eventually a lot of rinse and repeat
    • run dearimgui-build.cmd
    • see what requires manual fixing with regex (or CppSharp eventually, though I believe we're maxed out on that one)
    • repeat until build succeeds

Not sure what your environment is, here I had both VSCode and VS + ReSharper so spotting the changes was mostly a matter of waiting for the build and analysis to complete in both.

What is daunting, is the sheer amount of generated code and sometimes to come up with the right regex, there is quite a bit to skim through with the comments and the duplicated for 32-bit and 64-bit imports.

Overall, it's mostly a matter of patience, the fixes aren't too difficult to come up with, if at all as there are already some in the base library.

I put emphasis on regex because the problem is that CppSharp is kinda a bit of black box with no documentation and unfinished in some ways; there are quite a bunch of things that are simply not working fully (e.g. type maps).

Therefore, a good old regex ends up being a good silver bullet as opposed to CppSharp, time-wise and efficiency-wise.

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

No branches or pull requests

2 participants