I was wondering, why can’t I create an opengl context using SDL_GL_CreateContext on a window that wasn’t created with SDL_WINDOW_OPENGL? I can do it using wgl on windows, so is there any blocker from other platforms?
In my use case I want to open a window as fast as possible (this means without any renderer) jus to show a splash screen (by just copying the pixels to a surface) and then load vulkan and if that fails load opengl
You don’t need to specify SDL_WINDOW_OPENGL when creating the window.
The issue is that accessing the window’s surface disables creating an OpenGL context in that window, because you aren’t supposed to mix the two for drawing to the window.
You could always try creating a window to show the image, with a hidden window that is used for Vulkan/OpenGL. Once they’re ready, close the image window and show the Vulkan window.
My issue is with the design of SDL it self, because I can create a vulkan context no problem without SDL_WINDOW_VULKAN but I can’t do the same with OpenGL, but nothing is stopping me to just call the native context creation api like EGL or WGL or whatever and start using it.
So I should be able to create it using SDL.
EDIT: If you check wgpu-rs you will see they create the GL context by calling EGL/WGL without depending on the windowing lib used
You can create a window for an OpenGL context without specifying SDL_WINDOW_OPENGL these days; the requirement to specify it was removed several versions ago IIRC. I just tried it (SDL 2.28.5) on macOS and it worked fine; if it isn’t working on Windows then that sounds like a bug in SDL’s Windows backend.