-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
Somewhat related to #12787. In order to share some OpenGL resources across multiple GL contexts, I create a hidden base shared OpenGL context like this:
// Create a hidden window for the context
m_window = SDL_CreateWindow("", 1, 1, SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN);
if (m_window == nullptr) { /* ...error handling... */ }
// Create the OpenGL context
m_context = SDL_GL_CreateContext(m_window);
if (!m_context) { /* ...error handling... */ }
Note that, despite not needing event handling or any other window functionality, I am forced to create a hidden window just to create the the OpenGL context. This also complicates my code as I now have to manage the lifetime of the window as well as the one for the context.
It would be nice if I could pass nullptr
as an argument to SDL_GL_CreateContext
to create a context detached from any window, e.g.:
m_sharedContext = SDL_GL_CreateContext(nullptr); // detached context
Similarly, it would also be nice if I could pass nullptr
as the first argument of SDL_GL_MakeCurrent
to set a detached context as active:
SDL_GL_MakeCurrent(nullptr, m_sharedContext); // set detached context as active
How difficult would it be to implement these changes? What is the fundamental reason why OpenGL contexts are architecturally tied to windows in SDL3?