Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Nicer way to switch between windowed and fullscreen mode?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Vortez   Crossbones+   -  Reputation: 2704

Like
0Likes
Like

Posted 19 September 2013 - 04:05 AM

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, 19 September 2013 - 04:24 AM.


Sponsor:

#2 phantom   Moderators   -  Reputation: 7555

Like
1Likes
Like

Posted 19 September 2013 - 04:11 AM

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.

#3 3TATUK2   Members   -  Reputation: 730

Like
0Likes
Like

Posted 19 September 2013 - 08:33 AM

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



#4 Vortez   Crossbones+   -  Reputation: 2704

Like
0Likes
Like

Posted 19 September 2013 - 10:10 AM

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, 19 September 2013 - 10:12 AM.


#5 mhagain   Crossbones+   -  Reputation: 8270

Like
1Likes
Like

Posted 19 September 2013 - 11:43 AM

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.


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS