Replies: 1 comment
-
Do these abstract handles need to be destructed when no longer needed? I think instead of binding the functions directly, the best strategy might be to create some kind of C++ wrapper (a |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've been developing ImGui bindings with Nanobind and I'm pretty happy with both my progress and results so far. However, there I have some untackled areas in expressing object ownership correctly and looking for help and ideas here.
Let me summarize some key ImGui APIs before continuing:
Most ImGui API calls use a hidden implicit "current ImGui context". Such a context is created using a call to ImGui::CreateContext, as below:
All subsequent API calls to ImGui will use the implicit "global context". E.g.,
I have currently modeled ImGui::GetIO like this:
Quite obviously, this does not take into account the ImGui implicit "current context". Nanobind doesn't know that ImGui::GetIO refers to the currently set context. I just don't know how to model this relationship through nanobind.
I wonder if anyone has any ideas on how to express an implicit context like above?
So far I've been getting by using my bindings even with broken object relationship modeling but I suspect I will soon hit more serious bugs. For example, it's possible in ImGui to directly set ImGUI::GetIO() fields, e.g.,
So if I model the above with something like below, I think I'll hit problems with Python object lifetimes:
And using it like:
Beta Was this translation helpful? Give feedback.
All reactions