GLWpfControl icon indicating copy to clipboard operation
GLWpfControl copied to clipboard

Rendering Context MakeCurrent Doesn't Work From Other Threads

Open BBoldenow opened this issue 5 years ago • 4 comments

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).

BBoldenow avatar Jan 05 '21 18:01 BBoldenow

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.

varon avatar Jan 06 '21 13:01 varon

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.

DimaS86 avatar Mar 13 '21 11:03 DimaS86

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!

BBoldenow avatar Mar 25 '21 17:03 BBoldenow

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.

romen-h avatar Dec 01 '21 21:12 romen-h