The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL_CreateWindowFrom() wxWidgets panel
IshtarUK


Joined: 06 May 2016
Posts: 8
Hello everyone

I have spent the last few days trying to embed SDL2 into wxWidgets 3.1 wxPanel. My research has lead to using SDL_CreateWindowFrom(void * window_handle) which I have implemented, however, when I try calling SDL_CreateRenderer() I find that the application hangs. That is SDL_CreateRenderer() never returns.

My system config is as follows:

OS: Fedora 23
Kernel 4.4.8
SDL-2.0.4
wxWidgets 3.1

I would be grateful if somebody would be able to look at the following code to see why SDL_CreateRenderer() never returns.

Many thanks
Amanda


Code:

 if (SDL_Init(SDL_INIT_VIDEO) < 0)
    {
        std::cerr << "SDL Initialisation Error\n\n";
    }

    wxGridBagSizer* gbSizer1;
    gbSizer1 = new wxGridBagSizer(0, 0);
    gbSizer1->SetFlexibleDirection(wxBOTH);
    gbSizer1->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
   
    wxPanel *panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(700, 500), wxRAISED_BORDER | wxTAB_TRAVERSAL);

    gbSizer1->Add(panel, wxGBPosition(0, 0), wxGBSpan(1, 1), wxEXPAND | wxALL, 5);

    this->SetSizer(gbSizer1);
    this->Layout();

    this->Centre(wxBOTH);

    this->SetSize(800, 600);

    /*******************************************************
     *
     * SDL Specific Stuff
     *
     ******************************************************/
    SDL_Window *sdl_window = NULL;
    SDL_Renderer * renderer = NULL;
   
    sdl_window = SDL_CreateWindowFrom((void *) panel->GetHandle());


    if (sdl_window == NULL)
    {
      // ERROR HANDLING
    }
   
   // Application Hangs here
    renderer = SDL_CreateRenderer(sdl_window, -1, SDL_RENDERER_ACCELERATED);

    std::cerr << "IN HERE";

    if (renderer == NULL)
    {
       // ERROR HANDLING
    }
IshtarUK


Joined: 06 May 2016
Posts: 8
Additional Information omitted from my first post:

wxWidgets 3.1 is compiled to use GTK3.

Hope somebody can point me in the right direction.

Kind Regards
Amanda