Just curious if this is a feature or a bug:
In Windows, my game can switch on the fly between windowed and fullscreen mode. In Linux however, it's a no go - it'll always fall back to windowed mode. I'm mostly just interested, because I'd like the user to be able to select their resolution from within the game, and then have it switch for them without having to restart it.
Most drivers on most OSs actually fail to do this correctly. It's probably wisest to just force your app to restart from scratch.
Cas :)
It can switch just fine here on my SuSE with the latest nvidia drivers and kde 3.3.
- elias
I think I'm going to create a SWING based startup menu (you know, the kind that's just a little window that asks what resolution and graphic options you want, and then you hit a button to launch it). It seems like the cleanest way to implement this.
It would seem to me that an in-game configuration menu would be better than an external Swing based configuration. Launch the game in windowed mode on the first run. The player can switch to fullscreen from the menu and from then on you load the last configuration at startup. It doesn't take much to destroy and recreate the context. The tricky part is reloading textures, but if you have a good resource management system it's trivial.
LWJGL is still supposed to support on-the-fly switching if you maintain the bit depth between windowed and fullscreen. I'd like to know more about this linux issue. Which OS, version, graphics card, driver etc. And debug output would be nice too.
- elias
I've been fiddling around with this quite a bit... looks like the issue isn't actually the Display.setFullScreen() call. It had something to do with the keyboard polling. On Linux, it would grab the key twice, causing the system to switch it twice (although, why it always defaulted to windowed mode, I couldn't tell you - same thing for why it only happened in linux - something weird with the keyboard polling perhaps?).
In order to solve the problem, I create a boolean flag (set to false) and set it to "true" if the keyevent occurs at any time during the keyboard polling loop. I then switch the mode and set the flag back to false.
Sorry for zeroing in on the wrong function. I had gotten used to using java keylisteners, and the lwjgl keyboard functions act quite differently (I get all sorts of double "returns" on key presses - I'm guessing because it's just detecting the raw input).
Are you using getKeyState() to determine if it was a key down or up event?
- elias
QuoteAre you using getKeyState() to determine if it was a key down or up event?
LOL... nope... didn't even know that existed! :?
That should simplify things substantially, huh? :P