2012/9/23 urkle <@Edward_Rudd>
I’m trying to use SDL2 in my future game ports (Improved keyboard support, window control, and separation of GL context creation are BIG wins for me on this), however fullscreen support seems to be utterly broken in SDL2.
I have the issue described here http://bugzilla.libsdl.org/show_bug.cgi?id=1571 where the users desktop resolution does not restore. A workaround seems to be disabling Xinerama support and making sure I position the window @ 0,0 when creating it. Other issues that have been reported are issues with Ubuntu’s Unity desktop where the resolution will change but the window will not go properly into full-screen mode.
In an ideal world (and ideal API) I would like to query both monitors independently (i.e. Xinerama give me this) and allow the user to choose which monitor goes full-screen (kinda like we did back in SDL1.2 via the SDL_VIDEO_FULLSCREEN_DISPLAY env var). There seems to be no API to choose which “display” I make the window go fullscreen on? (unless I am missing something)…
The game that is having all of these lovely issues is Torchlight in the current humble bundle. I’m going to try my “disabling” xinerama and set position hacks to see if that resolves many of the issues. but it seems there are some more serious deep rooted issues in the fullscreen code in SDL2 that need some major cleanup… Any insight into the code there would be grateful as I will most likely be digging into this mess as I plan on using SDL2 still for 6 more game ports over the next few months.
I’m using SDL2 under Ubuntu with Nvidia Twinview and it works very well on fullscreen for me (you need fairly recent binary Nvidia drivers, as old drivers didn’t had the proper Xrandr support). I contributed a few patches for this issue a while back because it was really broken, and at least as far as I can see it’s working fine (I can position my window full screen on both monitors, regular windows across both screens, etc).
On a system with two monitors, you should get two video displays, one for each monitor, and you select which display you want to be fullscreen at by using the x,y position of the window and the SDL_WINDOWPOS_UNDEFINED_MASK
This is my window setup code (it’s Cython, but you may be able to get an idea of what I’m doing anyway).
ndisplays = SDL_GetNumVideoDisplays()
if display > ndisplays-1:
display = 0
x = SDL_WINDOWPOS_UNDEFINED_MASK | display
y = SDL_WINDOWPOS_UNDEFINED_MASK | display
width = dm.w
height = dm.h
self.window = SDL_CreateWindow(“Ignifuga”,x, y,width, height, SDL_WINDOW_FULLSCREEN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL)
Ahh, so that’s what those macros are for… Wouldn’t you just use the helper SDL_WINDOWPOS_UNDEFINED_DISPLAY(display) :). Oh way… Cython…
I am running the latest stable nvidia driver (304.37). Which one difference between what I’m doing and you, is that I have not been setting the resizable flag. Which that right there has been the cause of MUCH frustration among ubuntu users of Torchlight. I have actually put together a patch for this bug http://bugzilla.libsdl.org/show_bug.cgi?id=1153 which works around Compiz’s “odd behavior” of not allowing a window to go fullscreen unless it is resizable.
However the issue I still have with enabling xinerama is that the desktop resolution does not restore. I have similar issues with SDL 1.2 and have xinerama disabled there as well. From further debugging into things… When SDL tries to restore the desktop resolution with Xinerama enabled it only tries to restore one monitor to it’s original resolution, not both. And for some reason that fails. The other difference between my code and your’s is you are changing to the Desktop resolution, where Torchlight isn’t always going to do that (if I go w/ the desktop resolution on my box everything works fine as well)
Thanks for the input and sample code.
SDL mailing list
SDL at lists.libsdl.org
317-674-3296On Sep 27, 2012, at 9:24 , Gabriel Jacobo wrote: