-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
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
framebuffer support #207
Comments
What do you mean by 3D GUI support? what are you trying to achieve? Are you aiming to render different part of the gui to different outputs? |
The direct goal is to separate what draw commands should be rendered to what framebuffer. Utilizing the framebuffer allows me to write to texture and display the result as part of my 3D scene. Example ImGUI being rendered on a in-game LCD screen. If this is too specific for a single use case (since it will also require special handling for inputs) I understand |
You can give it a shot since it is a fairly trivial patch, but my intuition is that it'll mess with some assumptions that ImGui can make in term of inputs. It would depends of how much inputs you are trying to use. Using ImGui::GetInternalStateSize(), ImGui::SetInternalState(), you may be able to have multiple ImGui state running simultaneously and that may be easy to do. I haven't tested it however. |
I've tried having "Multiple IMGUI" contexts using ImGui::GetInternalState()/ImGui::SetInternalState(). A quick testing shows it works, paying attention to the following:
FYI, the application in this shot is integrating ImGui together with MFC (it's needed for a legacy app) in a Windows Message Loop that also uses Async IO (so not the typical "redraw at 60 hz" realtime loop). |
… case of using multiple contexts #207
Nice!
I made Shutdown() now tests if io.Fonts is != NULL before clearing it, so you can temporarily swap this value to avoid this if you want. The reason behind this setup is a little tricky.
Because of this I made the font atlas global, which also make sense in most (but not all) use of multiple contexts. However as a user you can still manually create other ImFontAtlas if you need them.
If you have any idea how to make that better? The global font atlas could use a sort of reference counter but it is tricky because the pointer can be replaced by the user any time. This all stem from the lack of an explicit ImGui::Init() function really (I thought it was "nice" to not have one initially). |
Thanks for adding that != NULL test! All of your three reasons make sense to me and I agree with your decision of making the static font atlas. FYI in most situations when creating multiple contexts you're sharing font textures as well as in OpenGL you set the current context to some hwnd and you reuse textures. Setting fonts to null is fine as long as is clearly stated in the Shutdown documentation, and I would avoid refcounting as well. User will need to refcount other things anyway to properly shutdown OpenGL Contexts or other API equivalent of ogl contexts (I did it) and the same "condition" will be used to call the proper ImGui::Shutdown. |
Woo! Maybe have a global state struct, add an ImGui::PushContext(...) and ImGUI::PopContext.(...) stack, the former just does SetInteralState(state++) and the PopContext does everything shutdown except delete the shared data. |
I'll close this for now. I'm not sure I'll be making a change to the the Fonts pointer for now, it looks like it's manageable and if you are dealing with multiple contexts it's only a minor complication to handle. |
Hello,
I'd like to submit a feature request for support of offscreen rendering via framebuffers. This would allow for 3D GUI support. Something along the lines of
Clientside:
Renderside:
The text was updated successfully, but these errors were encountered: