Hello everyone
Operating System: Linux (Fedora 24)
wxWidgets: 3.1.0 compiled against GTK3
SDL-2.0.4
Question specifically about: SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT
I’m having a problem trying to embed SDL2 into wxWidgets using SDL_WindowFrom(win->GetHandle()). I have tried this using Qt5 so it’s not specifically a wxWidgets problem. My tests show that SDL_CreateWindowFrom() is working fine. However, when I try to setup a SDL_CreateRenderer(sdl_window, -1, SDL_RENDERER_ACCELERATED) I find that the function never returns. I have done a great deal of Googling and found lots of posts related to this problem. Some of these posts recommend patching src/video/x11/SDL_x11window.c which I have tried but to no avail.
I have tried using SDL_RENDERER_SOFTWARE but this just segfaults at vinfo->visualid = X11_XVisualIDFromVisual(visual); in SDL_x11modes.c
I have also tried compiling wxWidgets against gtk2 instead of gtk3. When I do this II get a Gdk-ERROR ‘BadWindow’ from SDL_CreateWindowFrom()
Further digging around has lead me to believe that I may need to set the SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT flag but I am not sure how to set this flag. Can anybody offer any advice or point me towards a some example code?
Please see the following code example which hopefully will show you what I have tried to date. PS: My SDL2 install workers perfectly in a stand-alone mode.
I hope somebody can help and I thank you for taking time to read my post.
Regards
Amanda
Code:
wxPanel *panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(800, 600), wxTAB_TRAVERSAL);
SDL_Window *sdl_window = SDL_CreateWindowFrom((void*) panel->GetHandle());
if (sdl_window == NULL) {
std::cerr << SDL_GetError();
}
SDL_Renderer* r = SDL_CreateRenderer(sdl_window, -1, SDL_RENDERER_ACCELERATED); // Hangs Here!
if (r == NULL) {
std::cerr << SDL_GetError();
}
SDL_SetRenderDrawColor(r, 255, 0, 0, 255);
SDL_RenderFillRect(r, NULL);
SDL_RenderPresent(r);
sizer->Add(panel, 1, wxALL | wxEXPAND, 5);
this->SetSize(900, 700);
this->SetSizer(sizer);
this->Layout();
this->Centre(wxBOTH);