aybe / DearImGui

imgui & implot for .NET & OpenTK
MIT License
40 stars 3 forks source link

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

Open KCoen opened 1 year ago

KCoen commented 1 year ago

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 commented 1 year ago

For implot, I proceeded like so:

Then, a managed project is slightly more involved:

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.