SFML community forums

Help => Window => Topic started by: Wander on August 15, 2010, 08:47:59 am

Title: Toggling Between Video Modes
Post by: Wander on August 15, 2010, 08:47:59 am
I'm trying to make my program have the ability to toggle between two video modes: Desktop Mode and Windowed Mode.

Code: [Select]
           if (DONT KNOW WHAT TO PUT HERE && (Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::W))
                App.Create(DesktopMode, sf::Style::Fullscreen);
           
            if (DONT KNOW WHAT TO PUT HERE && (Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::W))
                App.Create(sf::VideoMode::GetMode(0), sf::Style::Resize | sf::Style::Close);


I'm not sure what to put in the if statement for checking the video modes. It seems like I've tried everything. Ugh.
Title: Toggling Between Video Modes
Post by: Hiura on August 15, 2010, 08:57:00 am
You can use something like :
-- when you create the window the first time, let's say in fullscreen
bool am_i_fullscreened = true;

-- later, in the event loop:
if (the event you want) then
if am_i_fullscreened then create a classic window
else create a fullscreen window
end else

switch am_i_fullscreened's value.
end if
Title: Toggling Between Video Modes
Post by: Wander on August 15, 2010, 09:00:09 am
Thank you very much! I'll definitely try that.