Skip to content
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

Enable the OpenGL2 backend to be used with multiple contexts #4141

Closed
wants to merge 1 commit into from

Conversation

jpcima
Copy link

@jpcima jpcima commented May 15, 2021

This work enables the OpenGL2 backend to be used with multiple contexts.

This tries to solve a common problem with happens with music plugins (VST).
One may want to load more that one of a particular instrument in a music session.
If creating 2 instruments, the first UI opens with its context, the second UI conflicts and crashes.

The problem is resolved by associating the OpenGL data with the ImGui context, instead of it being global.

Among many others, the Carla software permits to experience this problem.
This is the original issue about the music plugin where the problem is present.

@ocornut
Copy link
Owner

ocornut commented May 16, 2021

Hello,
If you were to attempt something like this, you would be better off using the void* BackendRendererUserData field of ImGuiIO which was designed for this sorts of thing.

@jpcima jpcima force-pushed the gl2-multi-contexts branch from 2bc467a to 988ae2f Compare May 16, 2021 18:33
@jpcima
Copy link
Author

jpcima commented May 16, 2021

Thanks for the tip.
I've modified the code accordingly, and rechecked in context.

@ocornut
Copy link
Owner

ocornut commented May 16, 2021

Thank you.
I'm not going to merge this right away as I would like to do the work simultaneously on more backends, but we have several similar issues/PR so going to tackle them together and this is a good reference.

ocornut added a commit that referenced this pull request Jun 29, 2021
…multi-contexts. (#586, #1851, #2004, #3012, #3934, #4141)

This is NOT enable multi-contexts for any backends
- in order to make this commit as harmless as possible, while containing all the cruft/renaming
-
ocornut added a commit that referenced this pull request Jun 29, 2021
#1851, #2004, #3012, #3934, #4141)

I believe more renderer backends should work. GLFW/Win32/SDL/Vulkan probably have many issues.
@ocornut
Copy link
Owner

ocornut commented Jun 29, 2021

Hello,

This is now solved with 70c6038 + 4cec3a0.
I confirmed that the GL2 backend worked my test bed.

Details (posted in a few threads)

With 70c6038 i have rearranged all backends to pull their data from structures.
This commit is rather large and noisy so I tried to make it as harmless a possible and therefore the commit as-is tries to NOT change anything in the backends, which include NOT enabling support for multiple imgui-context.
It was then enabled with a small patch in each backend 4cec3a0

PS: Current change being generaly healthy I don't mind it but I'm not very excited with promoting and encouraging support of multiple-imgui-context-each-in-their-own-backend-context. I think that feature is likely to be incompatible with multi-viewports (single imgui context + multiple backend windows) and I think instead we should aim at reworking this to let user register any existing window.

@ocornut ocornut closed this Jun 29, 2021
ocornut pushed a commit that referenced this pull request Apr 27, 2022
…owing to use these backends with multiple contexts. (#5203, #5221, #4141)

# Conflicts:
#	docs/CHANGELOG.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants