-
Notifications
You must be signed in to change notification settings - Fork 58
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
Better sample code and documentation #45
Comments
Hit that too. Looking at the sample.cpp code, I realise the home page snippet does not deal with initialization and shutdown code:
Although to be fair, the snippet does say a very simplistic example. As for the canvas code in the snippet and the assertion crash, the issues are these:
Basically all functions that are within the Ez namespace internally work with the context and its own CanvasState. In the code above though, BeginCanvas is not from the Ez namespace and instead uses a local CanvasState, yet all the inner nodes and slots are calling into Ez namespace. Since we don't call ImNodes::Ez::BeginCanvas, the inner CanvasState of the context is not properly initialized (and internally split) and that split is what raises the internal _Count which is referenced in that assertion. Instead the local CanvasState is initialized. Later inside the node loop, we call ImNodes::Ez::BeginNode which will try to use the context's CanvasState which is not initialized (therefore its _Count is still 0) so the assertion will be hit. If you switch
and its correspondent EndCanvas to the Ez namespace and without parameters
it will work. The other option, if you wish to work with a local CanvasState instead, would be to remove ::Ez:: from all calls in the middle and provide the local canvas as parameter. I have not tested this, but I imagine it works as internally functions in the Ez namespace do that using the context.State canvas. |
It does not work for me. I wish there was a sample with this possibiity also. |
I pasted the sample code on the readme.
I got this
imgui/ImNodesEz.cpp:125: bool ImNodes::Ez::BeginNode(void*, const char*, ImVec2*, bool*): Assertion `GContext != nullptr' failed.
Aborted (core dumped)
something something context. OK.
You have another sample code. Looked through it. Ah!
Pasted this in:
static ImNodes::Ez::Context* context = ImNodes::Ez::CreateContext();
Only to be met with a new assertion fail!
imgui/imgui_draw.cpp:1792: void ImDrawListSplitter::SetCurrentChannel(ImDrawList*, int): Assertion `idx >= 0 && idx < _Count' failed.
Perhaps the sample code was written for a previous version of the library which is now outdated.
In any case, having something to run and play with incrementally is immensely helpful.
The text was updated successfully, but these errors were encountered: