I'm currently attempting to embed an SDL2 Window/Renderer inside a child wxWindow. After some digging around I managed to retrieve the X11 handle from that child wxWindow, and use it inside SDL_CreateWindowFrom(), and therefore also create a renderer via SDL_CreateRenderer().
The code compiles and executes without any crashes, the SDL window and renderer get created with no issues, however nothing is being rendered on the wxWindow child...
Here is a snippet of the code which shows the initialization of the wxWindow child with respect to a wxFrame parent (aka the top level window):
Code: Select all
PPU::PPU(wxFrame* parent, Memory* mem) : wxWindow(parent, wxID_ANY, wxPoint(0, 0), parent->GetSize())
{
WXWidget widget = GetHandle();
#ifdef FUUGB_SYSTEM_LINUX
GdkWindow* gdkWindow = gtk_widget_get_window(widget);
XID x11Handle = GDK_WINDOW_XID(gdkWindow);
sdlWindow = SDL_CreateWindowFrom((void*)x11Handle);
#endif
if (sdlWindow == NULL) {
wxPrintf("Error occured during SDL window creation: %s\n", SDL_GetError());
SDL_Quit();
wxExit();
}
renderer = SDL_GetRenderer(sdlWindow);
if (renderer == NULL) {
if (!(renderer = SDL_CreateRenderer(sdlWindow, -1, SDL_RENDERER_SOFTWARE))) {
wxPrintf("Error occured during renderer creation: %s\n", SDL_GetError());
SDL_Quit();
wxExit();
}
}
...
Here is the code snippet which works (but is not desireable):
Code: Select all
PPU::PPU(wxFrame* parent, Memory* mem)
{
WXWidget widget = parent->GetHandle();
#ifdef FUUGB_SYSTEM_LINUX
GdkWindow* gdkWindow = gtk_widget_get_window(widget);
XID x11Handle = GDK_WINDOW_XID(gdkWindow);
sdlWindow = SDL_CreateWindowFrom((void*)x11Handle);
#endif
...
Would anyone know why the rendering is not occuring on the wxWindow child? I've debugged the program and it seems like everything is running fine on the SDL2 side, so i'm suspecting i'm missing a crucial call from the wxWidgets library side...
Here are the details of my environment:
wxWidgets 3.0.5 with GTK+-3.0
Ubuntu 20.04 LTS