I’m in the middle of porting a very large legacy code base from MS Windows to Linux.
After looking at the alternatives, I chose SDL as my cross-platform window manager. I’m using the main branch of the SDL git repo.
Our existing code creates display-lists in a separate thread, so I called
SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1); before calling
SDL_GL_CreateContext(). But that context isn’t available in the other threads where I try to create an OpenGL context that’ll share its display-lists (e.g. done with
wglShareLists() in MS Windows).
The problem is that
wglMakeCurrent() fails if that OpenGL context has already been made current in another thread, but there’s no other way in SDL2 to specify the OpenGL context to share with other than the current one. The non-SDL version of our code calls
wglShareLists() with the external OpenGL context without trying to make it current, and it works fine.
Why is it only possible to share with the current context? The docs to
wglMakeCurrent() say “A rendering context can be current to only one thread at a time. You cannot make a rendering context current to multiple threads.” so what SDL2 is doing would never work under MS Windows anyway.
Is sharing display-lists like this not implemented in a cross-platform sense? My immediate other target is Linux, but it’d be nice to not do anything that prevents porting to something else in the future.