I'm working on an OpenGL renderer for my wxWidgets-based project 3Beans, and I need to maintain a GL context that is potentially used across different threads. The addition of wxGLContext::ClearCurrent() allowed this to work flawlessly on Linux and Windows, but on macOS it was impossible to set the GL context on a non-UI thread. It crashes with the error [NSOpenGLContext setView:] must be called from the main thread. This change allows the context to be set without touching the UI if it's off the main thread, which makes threaded OpenGL work perfectly on macOS as well.
https://github.com/wxWidgets/wxWidgets/pull/26036
(1 file)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
I am not sure if it's really safe to use wxGLContext from non-UI thread(s), if it is, we need to document what thread-safety guarantees exactly does it provide (but I don't know what they are myself, unfortunately) and add an example of doing this to one of the OpenGL samples.
Of course, adding this check shouldn't do any harm, but I just worry about making promises that we won't be able to keep...
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
From what I've gathered online, GL contexts should be thread-safe as long as they're cleared from any other thread before being set on a new one. Of course, that doesn't account for any interactions a wxGLContext might have with a wxGLCanvas. Another solution might be to have a static function for setting the context, like how ClearCurrent() already is.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()