Nicer way to switch between windowed and fullscreen mode?

Started by
3 comments, last by 21st Century Moose 10 years, 7 months ago

Hi, i have this program that i can switch from windowed mode to fullscreen and vice versa, but i don't really like the way it work.

For now, the only thing that work is to "shutdown" and reinitialize opengl, then reload textures, which introduce some lag when doing the switch.

Also, if i switch too fast (ie: pressing my switch mode key fast twice in a row), sometime the context failed to create so it's not very good.

The thing is, i've seen games like warcraft that can switch pretty fast, especially between fullscreen and a mix of fullscreen and windowed mode (how do you even do this???).

The ps2 emulator does this very nicely too when you double click on the main window.

Another thing that bug me is that, since im using delphi for this app, every time i change the window style from normal to a borderless fullscreen window, the window handle change, so i got a completely different window. This is not a serious problem though, since i could just use CreateWindowEx and do it myself if i really wanted to, although i dunno if i would be able to add a TScrollbox window component afterward, which is needed sometime when the image i draw is not stretched but drawn at normal size.

What am i doing wrong? I think someone shoud create a tutorial on that because it's a pretty common thing in games and program like mine, but the information on the subject is almost non existant...

Also, does DirectX handle this better?

Advertisement
With OpenGL you don't, and never did on Windows, have to kill the window to resize/swap modes - using Win32 you can just resize the window, change the OpenGL viewport and carry on as before.

If your API kills the window, then yes, you are out of luck (SDL was dumb in this respect too), but you certainly don't have to destroy it to switch modes.

This is what you had to do in SDL 1.2 but SDL 2.0's fullscreen toggle works perfectly without reinitializing anything

I just found this thread and that seem to do the trick, except for the "fullscreen (windowed)" mixed mode like warcraft i was talking about. Guess ill have to figure that part out later.

It's soooo much better now cool.png

I believe that under older drivers (I'm talking 1990s here), killing the window and restarting was the only 100% reliable way, but nowadays - unless you need to change the pixel format - you shouldn't need to do that.

D3D9 and below handled it cleanly by just requiring a "Reset" of the device, but messily in that there were "lost devices" to deal with (although if you design your video code around this it wasn't such a big deal). D3D10+ no longer have "lost devices" but the process potentially involves two mode switches (one to go fullscreen, one to set the resolution) and is really badly documented.

With D3D the API is more closely tied to the windowing system so it can make mode switching part of the API; with OpenGL the API is not tied to the windowing system but this disconnect means that OpenGL is at the mercy of the windowing system for switching; it does however allow OpenGL to be more cross-platform. There are pros and cons to both.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

This topic is closed to new replies.

Advertisement