-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
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:
|
Includes my merged PRs and everything in my dev branch. Haven't tested with it yet. Changelog: Test case for clip rect HACK: more recent Windows SDK and VS2017; disable graph Set size to amount of space required Merge pull request ocornut#349 from maksw2/master Merge pull request ocornut#347 from mgerhardy/341 Merge pull request ocornut#348 from mgerhardy/fixed-warning Merge pull request ocornut#346 from mgerhardy/280 Merge pull request ocornut#345 from mgerhardy/322 Merge pull request ocornut#344 from rherilier/fix-gcc-warnings Merge pull request ocornut#336 from rherilier/add-isusingviewmanipulate Merge pull request ocornut#335 from RedSkittleFox/alternative_window Merge pull request ocornut#334 from ocornut/fix-beginchildframe dear imgui update and small fixes Merge pull request ocornut#316 from Batres3/2DSupport Merge pull request ocornut#326 from Sayama3/use-push-pop-id Merge pull request ocornut#328 from georgeto/master Merge pull request ocornut#330 from maritim/master Merge pull request ocornut#331 from GiovanyH/patch-1 Merge pull request ocornut#318 from dougbinks/imgui_math_operators Merge pull request ocornut#312 from kimidaisuki22/master div 0 fixed Merge pull request ocornut#301 from ZingBallyhoo/using-any Merge pull request ocornut#300 from Clog41200/Configurable-limits Merge pull request ocornut#298 from xDUDSSx/fix/rotation_circles Merge pull request ocornut#297 from xDUDSSx/fix/vertical-aspect-scaling Merge pull request ocornut#289 from ComputationalBiomechanicsLab/fix_isusing-ignores-setid Merge pull request ocornut#291 from ocornut/fix_math_operators_include Merge pull request ocornut#282 from MohitSethi99/master Merge pull request ocornut#276 from pthom/virtual_destructors Merge pull request ocornut#271 from idbrii/clip-parent Merge pull request ocornut#270 from idbrii/btn-behaviour Merge pull request ocornut#265 from mgerhardy/pr/fix-minor-formatting Merge pull request ocornut#264 from mgerhardy/pr/div0 Merge pull request ocornut#269 from peter1745/hatched-line-thickness-enhancement Merge pull request ocornut#259 from miyanyan/master Merge branch 'master' of https://github.com/CedricGuillemet/ImGuizmo update dear imgui Merge pull request ocornut#256 from Aidiakapi/patch-1 Merge pull request ocornut#252 from aaronkirkham/master Merge pull request ocornut#249 from rokups/rk/mouse-capture Merge pull request ocornut#246 from mgerhardy/pr/viewmanipulate removed commented code fix click view cube Merge pull request ocornut#231 from mgerhardy/master Merge pull request ocornut#230 from mgerhardy/master Merge pull request ocornut#228 from longod/master Merge pull request ocornut#227 from madeso/master AddBezierCubic Merge pull request ocornut#226 from sherief/master revert culling test commit Merge pull request ocornut#203 from rokups/rk/misc-fixes Merge pull request ocornut#212 from zhaijialong/fix-behind-camera-cull Merge pull request ocornut#209 from VictorFouquet/fix_normalize scale is always local Merge pull request ocornut#202 from pezy/master imguizmo namespace Merge pull request ocornut#194 from JonathanHiggs/vcpkg-example 1.84 WIP Merge pull request ocornut#197 from idbrii/seq-btn-color Merge pull request ocornut#196 from idbrii/seq-big-handles
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: