cimgui/cimplot

Question regarding types like ImRect

4bb4 opened this issue · 6 comments

4bb4 commented

I'm working on the Rust bindings for implot, which are based on cimplot, over in https://github.com/4bb4/implot-rs. I've just tried to update to the latest cimplot master, but now it seems that my bindings generation does not find some types anymore, such as ImRect and ImPoolIdx.

I've looked a bit at the latest commits here and I think my issue might have to do with the move of some includes in 299d29f - I can't seem to figure out what I'm doing wrong though (I tried some combinations of including cimplot.h and cimplot_impl.h, but those don't seem to define ImRect).

Where should ImRect and ImPoolIdx come from? I see they are in imgui.h, but that's a C++ header.

Thanks in advance for any help, I really appreciate the work you're putting into keeping cimplot up to date!

Where should ImRect and ImPoolIdx come from? I see they are in imgui.h, but that's a C++ header.

They should come from cimgui.h (that is included from cimplot.h https://github.com/cimgui/cimplot/blob/master/cimplot.h#L7)

So if you update to latest cimplot you should also update cimgui.

4bb4 commented

Ah, that makes sense. I've been using an older cimgui because of an unrelated issue, but I suppose you made those header changes in concert with cimgui. I'll go and resolve the unrelated issue then so I can also upgrade cimgui. Thanks for the help, this would have taken me a while to figure out.

CIMGUI_DEFINE_ENUMS_AND_STRUCTS will need to be defined

4bb4 commented

Yes, that I've been doing all along, but it's really the issue you mentioned - I'm using an old cimgui, in fact the one that imgui-rs is vendoring in https://github.com/imgui-rs/imgui-rs/tree/master/imgui-sys/third-party, and that cimgui.h just doesn't have ImRect in it yet. I thought about adding cimgui as a submodule directly and generating off of that, but I think that might introduce tricky problems with interoperability between implot-rs and imgui-rs, which is very much needed for implot-rs to be of any use.

cimgui.h has ImRect if it is generated for internal API.
I think that cimgui.h in imgui-rs was regenerated without internal API.

4bb4 commented

I see, thanks for the info - so just to make sure I understand things properly:

  • cimplot and cimgui both can either be generated with or without the internal API, but basically cimplot has to be used together with a version of cimgui that has the setting set to the same value.
  • the current cimplot master has the internal API turned on and hence also requires a cimgui with the internal API generation enabled
  • imgui-rs currently vendors a version with the internal API turned off.

I've actually re-run the generator in my cimplot submodule with the internal API turned off, and that does seem to work out. So I think I can do two things: a) get imgui-rs to vendor the version with the internal API b) point my submodule to a cimgui fork that has the internal API turned off as well. It seems like a) may take a while (there is already an issue in imgui-rs/imgui-rs#395 for this, but it does not seem to be that active at the moment). I prefer not forking repos and creating maintenance effort, but it seems like b) may be a reasonable way forward for the moment.