SDL_CreateWindowFrom and blocking SDL_CreateRenderer |
Alvin Beach
Guest
|
Hello,
I am working on updating an older application that uses SDL 1.2 where, the main SDL_Surface is embedded into another window. This works great with SDL 1.2. However, I am having issues doing the same with SDL2, but with SDL_Window (not SDL_Surface). I call SDL_CreateWindowFrom() when I have the window handle. It seems to work just fine as I do get a non-NULL pointer. However, calling SDL_CreateRenderer() just hangs. I've stepped through SDL_CreateRenderer() and it appears to block here: SDL_x11window.c:X11_HideWindow: ... /* Blocking wait for "UnmapNotify" event */ X11_XIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow); //<--- hangs here ... I have a suspicion that the X11 events are being consumed by the application toolkit (FLTK) and not are not reaching SDL2. Does anyone have any experience with embedding a SDL2 SDL_Window inside of another window? Or any insights on how it is done differently than SDL 1.2? Any information or advice would be greatly appreciated. Thanks. Cheers, Alvin _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||
|
SDL_CreateWindowFrom and blocking SDL_CreateRenderer |
Alvin Beach
Guest
|
After some troubleshooting, it appears that the SDL_CreateWindowFrom()
works just fine. However, SDL_CreateRender() hangs. From what I can see, when creating the renderer, the window is checked if it has the SDL_WINDOW_OPENGL flag set. If it does not (it doesn't I know that for sure), SDL_RecreateWindow() is called. Eventually, the window is unmapped via SDL_HideWindow(). On my machine, this calls X11_HideWindow(). That is where it is hanging. X11_HideWindow() withdraws the window, but then waits indefinitely for an UnmapNotify event. I stuck a SDL_Log() in isUnmapNotify() and it appears that this event is never received. I do see a DestroyNotify event (17) but the Window ID doesn't match what it is waiting for. Interestingly, if I comment out this line (i.e. X11_XIfEvent(...)), everything appears to work just fine (the SDL_Window embedded in my app). I've also commented out the equivalent line in X11_ShowWindow(). My definition of "just fine" is very very limited. I cleared the renderer with an arbitrary colour and drew a filled rectangle at the centre of the window. Not very thorough, but it appeared when SDL_RenderPresent() was called. I'm fairly sure that not consuming the UnmapNotify and MapNotify events is likely not a good thing. Is there something else that could be done? Perhaps using the commented out X11_XIfEventTimeout() in SDL_x11window.c? On Fri, Jul 25, 2014 at 3:11 PM, Alvin Beach wrote:
SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
Other t |
perilsensitive
|
Hit the wrong key by accident when typing that last post. The subject shouldn't have been changed to 'Other t'. I intended to add this to the end of the post:
Other than the above issues, I've had no problems; rendering works perfectly and everything seems stable. |
|||||||||||
|
SDL_CreateWindowFrom and blocking SDL_CreateRenderer |
Alvin Beach
Guest
|
That's a very interesting workaround! I've tested and it works. Thanks! I did get the same freezing behaviour when SDL_Quit() was called. Turned out, I had to ensure that the window was hidden (unmapped) before calling SDL_Quit(). What toolkit are you using?
I would still like to find out what the issue really is though. Seems to me that SDL2 is executing low-level Xlib calls that maybe it should not be doing when the SDL_Window has been created using SDL_CreateWindowFrom(). I'm hoping that someone with more low-level SDL2 and X11 knowledge might be able to shine some light on this issue. On Mon, Jul 28, 2014 at 1:57 PM, perilsensitive wrote:
|
|||||||||||||
|
tehcloud
|
There was talk a long time ago about SDL_CreateGLWindowFrom(), but I haven't heard anything since then.
perilsensitive's hack seems to work for what I need. I have written functions that convert GDK keypresses and mouse clicks to SDL events to complete the puzzle. |
|||||||||||
|
SDL_CreateWindowFrom and blocking SDL_CreateRenderer |
Alvin Beach
Guest
|
On 29/07/14 16:00, tehcloud wrote:
I checked bugzilla again and this time I found an existing bug entry for SDL_CreateWindowFrom() - https://bugzilla.libsdl.org/show_bug.cgi?id=2500 This isn't the SDL_Create_GL_WindowFrom() though. This is strange as I searched before and I am sure I didn't see this bug. I have added my 2 cents to the bug report along with a patch that seems to work. I like perilsensitive's idea too, but the underlying issue of Xlib event processing causes concern for me. Cheers, Alvin _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
Re: SDL_CreateWindowFrom and blocking SDL_CreateRenderer |
perilsensitive
|
gtk+-3.0. I noticed that behavior when calling SDL_Quit() as well, but I don't remember what I did about it, which means I might have just commented it out and forgotten to fix it. :-) If so, I'll try unmapping the window first as you did.
Agreed. It would be nice to have this fixed in a future release so that I can get rid of my hack. Other projects use OpenGL directly when using CreateWindowFrom() rather than use the Render API, but since I want the video code to be (mostly) portable and my rendering needs are simple (blit one big texture to the screen with HW-accelerated scaling), I didn't want to do that. |
|||||||||||||||
|