SFML community forums

General => General discussions => Topic started by: Xorlium on May 07, 2010, 03:31:02 am

Title: Changing video mode
Post by: Xorlium on May 07, 2010, 03:31:02 am
Hi,

I'm new to SFML, but I'm liking it so far. Just one quick (perhaps newbie) question:

How can I change video mode while the app is running?

I want that if the user presses F o something, it toggles full screen. I've looked through all the possibilities of
a sf::RenderWindow, but I can't find one that says SetVideoMode.

When you create the sf::RenderWindow you need to set video mode, but then how to change it after, I can't figure it out.

Thanks!
Title: Changing video mode
Post by: nulloid on May 07, 2010, 03:58:10 am
You just simply recreate the renderwindow with the correct settings :)
Title: Changing video mode
Post by: Xorlium on May 07, 2010, 04:36:12 am
Hmm... How do I do that then?

This is what I have:

Code: [Select]
sf::RenderWindow App(sf::VideoMode::GetMode(0), "App");

while (App.IsOpened())
{
 /* STUFF HAPPENS */
}


And in there I have something catching events, like on the tutorial. Then when button F is released, I want it to toggle full screen. How can I create a new window, if I'm inside the main loop?
Title: Changing video mode
Post by: OniLinkPlus on May 07, 2010, 04:38:55 am
Quote from: "Xorlium"
Hmm... How do I do that then?

This is what I have:

Code: [Select]
sf::RenderWindow App(sf::VideoMode::GetMode(0), "App");

while (App.IsOpened())
{
 /* STUFF HAPPENS */
}


And in there I have something catching events, like on the tutorial. Then when button F is released, I want it to toggle full screen. How can I create a new window, if I'm inside the main loop?
Inside the while loop when you get a f pressed event run App.Close then App.Create
Title: Changing video mode
Post by: Xorlium on May 07, 2010, 05:09:45 am
Thanks!!

That works perfectly, thanks! And it's even fast an unnoticeable.