Nelarius / imnodes

A small, dependency-free node editor for dear imgui
MIT License
2.01k stars 244 forks source link

Issue with dlls #74

Closed bootzin closed 3 years ago

bootzin commented 3 years ago

Would it be possible to add a public method similar to the one below?

void SetImGuiContext(ImGuiContext* ctx) {
    ImGui::SetCurrentContext(ctx);
}

The reason behind this is that globals are not shared between dlls, so when compiling imgui into a dll and imnodes into another, the context is not shared, and I end up getting access violations

You can read more about this here

I can also submit a PR to this if you wish, but I'm not exactly familiar with c++, although it does seems like an easy change

Nelarius commented 3 years ago

Hi @bootzin ! Sorry for taking a long time to respond. I must confess that I haven't worked very much dlls 😅But I think I understood the gist: you need a function exported from the imnodes dll which would set the GImGui global in that module.

I checked ImPlot, another ImGui extension library, and it seems like they also have exposed a SetImGuiContext function as part of the library API. So I don't see why imnodes wouldn't have it either.