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

Rendering Context MakeCurrent Doesn't Work From Other Threads #40

Closed
BBoldenow opened this issue Jan 5, 2021 · 5 comments
Closed

Rendering Context MakeCurrent Doesn't Work From Other Threads #40

BBoldenow opened this issue Jan 5, 2021 · 5 comments

Comments

@BBoldenow
Copy link
Contributor

Sorry, I can't get to Discord via work, hopefully this is the right place to post -

Currently MakeCurrent doesn't work from other threads for rendering contexts - it throws a resource in use exception. This seems like it'd be worthwhile so you can spawn threads for texture loading and the like that can subsequently request the context. If there is a way to do this currently feel free to let me know (or if there's a better place to post requests).

@varon
Copy link
Member

varon commented Jan 6, 2021

This is a perfectly fine place to raise an issue. Thanks for doing so.

Can you try create a context yourself externally and pass that in as part of the settings? It should allow for all sorts of customization as required.

@DimaS86
Copy link

DimaS86 commented Mar 13, 2021

Hello! I have the same issue and I really need that. I have migrated to GLWpfControl from the old GLControl, which had the same issue, so I recreated the context from the other thread and it worked. However, it is not possible here to create another context from a non-interface thread. I didn't understand how I can create the context externally. Could you please give me some direction to go?
Thanks in advance.

@BBoldenow
Copy link
Contributor Author

Varon, thanks for responding. Life has been a bit crazy, but I'll give that a shot and let you know how it goes. Thanks again!

@romen-h
Copy link

romen-h commented Dec 1, 2021

Make sure that you are calling GraphicsContext.MakeCurrent(null) on the thread it was created to "detach" the context from its current thread.
This allowed me to use the context on another thread with no problems.

@NogginBops
Copy link
Member

Using context sharing to create separate contexts (NativeWindows) should work fine.
For multiple GLWpfControls, #86 is going to make every GLWpfControl have it's own OpenGL context and will add a SharedContext setting so context sharing can be setup between controls.

I'm going to close this issue, feel free to reopen if this is not completely fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants