Comments (2)
Hi @Daandelange,
Thanks for your detailed explanation.
Yes, I'm using the code downloaded from code page as zip directly, I might want trying it ASAP at that time.
My design is in one glfw window there is one guimanager and it manages several gui 'pages' in an application.
Because I'm new to Dear ImGui and ofxImGui, I didn't understand the mechanism of them well at first. so I put the instance of ofxImGui::Gui into the 'page' level, and thus it's natural to release and recreate instance of the class each time when switching between 'pages'. So I found the assertion fail.
And after I posted here, as you have mentioned, now I indeed moved the only ofxImGui::Gui instance into my guimanager instance, whose life is as long as the whole application. So the problem is gone for me. I just need to manager the state of some 'controls' which keep alive between 'pages'. It worked well so far.
And thank you for the knowledge you told me. I understand it better.
Best regards.
from ofximgui.
Hi,
From your pieces of code I deduce that you're using the new develop version which brings (beta?) support for multiple instances, I have been working on this feature (and I still need to clean it up before merging it).
First of all, before going further into some details, I'd like to point out that ImGui discourages to use multiple GUI instances and switching them (event with destruct() etc.), and I also remember reading that it's mostly a "design mistake" in the sense that the GUI is meant to be used from within 1 single host system window; we -openFrameworkers- of course can not always comply with this and I tried to come up with a solution for this.
As you pointed out, the solution that I implemented tries to setup 1 ImGui context per ofAppBaseWindow and destroy it on close. In between, you can just render or not, and ofxImGui automatically handles switching the imgui context when you gui.begin()+end()
from within each ofAppBaseWindow. The drawback of this solution is that only the first call to setup()
from an ofWindow has "master" control over the gui instance, the next ones will setup()
as "slaves" and have less control over some settings. (In your ofApp you can check this by checking the return flag of setup()
.)
So I'd say, what you're trying to achieve is probably already baked in, except that we tested it only for the whole ofWindow lifetime, not for occasional use, but I can understand the need for it. On the other side, I also remember reading advice from the ImGui community that it's recommended (in terms of design principles) to keep that GUI context alive for the whole window lifetime and omit rendering to it if you don't need it and let it "sleep in memory", so we're probably adventuring into unsupported usage of the underlying library.
Do you really wish to kill that instance until its next use ? (Could you use a dummy instance to keep it alive ?)
ImGui has got a very tiny footprint and chances are that you lose more then you gain by periodically destroying/reconstructing it.
What are your application windows lifetimes ?
Btw, it could be great to throw a more informative ofxImGui assert before the ImGui assert throws.
from ofximgui.
Related Issues (20)
- No gui on Android HOT 2
- UTF-8 rendering fails with garbled characters. I need your help! Thank you! HOT 2
- input latin characters HOT 2
- ofxImGuiLoggerChannel.h HOT 2
- Merging forks : ImGuiContext and more HOT 8
- EGl window rk boards HOT 10
- ofxImGui upgrade HOT 8
- arb textures HOT 1
- imgui_stdlib.h and imgui_stdlib.cpp should be included in project files HOT 1
- Closing a window within a window? HOT 3
- imgui_impl_glfw_context_support.h missing from develop branch.
- develop brach broken HOT 5
- OF 0.12 compatibility
- Drawing ofFbo's texture as ImGui::Image(); HOT 3
- adding imGui as submodule? HOT 1
- how can we add the color picker expanded by default? HOT 2
- it's possible to use more than one instance of ofxImGui (inside classes) in the same ofApp? HOT 3
- Unknown type name 'ofVec2f'
- I make oF window borderless(not fullscreen),the screen display has an offset(mouse also)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ofximgui.