[SDL] SDL-2.0.4 / SDL_WindowFrom / SDL_CreateRenderer() Hanging

IshtarUK nicola at mackin.it
Thu Sep 8 13:56:04 PDT 2016


Dear Capehill

I cannot thank you enough. 

I was assuming (a rather silly thing to do) that ::GetHandler() was returning a native XID. It wasn't. For the benefit of anybody else trying to embed SDL2 into wxWidgets here is my example code.


Code:

GtkWidget* widget = panel->GetHandle();
gtk_widget_realize(widget);
Window XID = GDK_WINDOW_XWINDOW(widget->window);

    SDL_Window *sdl_window = SDL_CreateWindowFrom((void*) XID);

    if (sdl_window == NULL)
    {
        std::cerr << SDL_GetError();
    }

    SDL_Renderer* r = SDL_CreateRenderer(sdl_window, -1, SDL_RENDERER_SOFTWARE);

    if (r == NULL)
    {
        std::cerr << SDL_GetError();
    }





And then, in a separate thread loop with the usual SDL_Renderer functions


Code:

 while (true)
    {
        SDL_RenderClear(r);
        SDL_SetRenderDrawColor(r, 255, 0, 255, 255);
        SDL_RenderPresent(r);
    }




Once again, thank you Capehill :)




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20160908/74622e90/attachment-0001.htm>


More information about the SDL mailing list