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

Allow a context to defined in the ImGui config header. #297

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bmqn
Copy link

@bmqn bmqn commented Jun 16, 2024

I've found it useful to have control over the modifiers and/or type of the internal context s_Editor, which is defined in imgui_node_editor_api.cpp.

In my case, it's important to make the context thread_local for an application that has many instances of the the node editor all running in different threads of the same process, otherwise, the static context is shared and things get ugly.

I propose that the standard ImGui approach is adpoted, whereby defining your own GImGuiNodeEditor in your standard ImGui config header will enable you to override the context.

With this, to make the context thread_local we can define

namespace ax {
namespace NodeEditor {
namespace Detail {
struct EditorContext;
}}}
extern thread_local ax::NodeEditor::Detail::EditorContext *g_MyImGuiNodeEditor;
#define GImGuiNodeEditor g_MyImGuiNodeEditor

in our ImGui config header with the extern global referring to some instance of ax::NodeEditor::Detail::EditorContext somewhere in the program.

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

Successfully merging this pull request may close these issues.

1 participant