-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Multiple instances of GUIs and viewports #269
Comments
I've had success with using ImGui::GetInternalStateSize(), ImGui::SetInternalState()/ImGui::GetInternalState() for handling for multiple independent instances. You do need to take it into account in your render function. |
It should work. What you have to do is switch the global context pointer using ImGui::GetInternalState(), ImGui::SetInternalState(). All the ImGui functions access this global context. It may be not well supported or tested so I'm sure you'll run into problems here and there but overall it's possible. |
I did it with GetInternalState/SetInternalState and it works. |
I am not sure how this works. I have multiple HWNDs each with a HGLRC, but only a callback to a single render function. Do I initialise the render callback, then make a copy of the buffer with GetInternalState/GetInternalStateSize, then everytime I want to a do a NewFrame...Render, I have to start with a SetInternalState()? |
Your render callback will be called by Render() as a convenience. So at the time you call Render() you should know which of your ImGui state is active if you have more than one. You may pass arbitrary data via the
This isn't a structure you can copy yourself. The rendering data is in ImDrawData and only valid after Render() and until you call NewFrame() for the context. So actual render directly about you call ImGui::Render() is preferable. If you really need to make a copy (for later frames) you may make a deep copy of the ImDrawData structure and all vectors there, but you shouldn't have to do that. |
If you want to create additional state, allocate GetInternalStateSize() bytes and call SetInternalState() once with If you want to retrive the default state, call You can switch state at any time by calling EDIT I realize it is strange that there's no helper function to create a new state. |
So my workflow should be: For each openGL context/HWND:
Am I correct? On Tue, 8 Mar 2016 at 15:14 omar notifications@github.com wrote:
|
Missing the most important part
But you can totally keep changing the internal state during the frame as well, you don't need to do NewFrame/misc calls/Render completely, you can interleave access to the different context as long as you call SetInternalState() to select the active context. |
I don't understand why I would call SetInternalState(). What would I pass Sorry for being blind about this. Would it be possible to jot some Reading over my original message I am wondering when I said "copy the BTW, I think your library is amazing and I've watched the level of support On Tue, 8 Mar 2016 at 15:29 omar notifications@github.com wrote:
|
If you want to have 2 independant contexts of ImGui running in each of your window (as opposed to a single ImGui running across two windows like a virtual desktop), you need 2 ImGui contexts. GetInternalState() returns you the pointer to the current context. I may as well rename those functions to use the word "Context" instead of State. This is persitent, we store windows information and state that is carried from frame to frame. By default only one is created. You can create more:
Then change anytime:
This is like if you have two completely different instances of ImGui running. |
That makes things very clear to me now. My interpretation of the semantics On Tue, 8 Mar 2016 at 16:15 omar notifications@github.com wrote:
|
What do you think would have helped? May I comment or reword something? |
Good question. My initial incorrect assumption was that you'd "save" the Your use case above doesn't actually require the use of GetInternalState(), I see nothing wrong with your wording. The problem was that previous size_t GetContextSize(); What do you think? On Tue, 8 Mar 2016 at 16:23 omar notifications@github.com wrote:
|
Hello, does ImGui support having multiple instance of GUIs, potentially display on multiple viewports with different dimensions, with only one viewport activated and accepting input at a time?
I would like to add use ImGui on my project here. But worry it might not be easy to make it work the way I wanted.
The text was updated successfully, but these errors were encountered: