Jump to content
  • Advertisement
Sign in to follow this  
Vortez

OpenGL Nicer way to switch between windowed and fullscreen mode?

This topic is 2130 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Edited by Vortez

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Edited by Vortez

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!