SDL_CreateWindowFrom with OpenGL

I haven’t solved it yet. I’m thinking of either reparenting the window using Xlib + using Wayland subsurfaces in the future, or just importing and changing small pieces of SDL.

I have the same problem. I am running SDL in Win7. It was much more convenient to fix the solution using the SDL_WINDOWID environment variable trick then SDL_CreateWindowFrom.

I implemented a solution similar to valoh’s SDLCALL SDL_CreateWindowFrom(const void *data, SDL_bool supportOpenGl), but on Windows I also had to modify the code in SDL_windowswindow.c to setup the pixel format after setting the windowdata, otherwise the context was still invalid like this:

Code:
int
WIN_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
{
HWND hwnd = (HWND) data;
[…]
if (SetupWindowData(_this, window, hwnd, SDL_FALSE) < 0) {
return -1;
}

// Added code to setup the pixel format
if (window->flags & SDL_WINDOW_OPENGL) {
    if (WIN_GL_SetupWindow(_this, window) < 0) {
        WIN_DestroyWindow(_this, window);
        return -1;
    }
}
return 0;

}