Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Toggling Between Video Modes  (Read 2589 times)

0 Members and 1 Guest are viewing this topic.

Wander

  • Full Member
  • ***
  • Posts: 170
    • View Profile
    • Email
Toggling Between Video Modes
« 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.
-Wander

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Toggling Between Video Modes
« Reply #1 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
SFML / OS X developer

Wander

  • Full Member
  • ***
  • Posts: 170
    • View Profile
    • Email
Toggling Between Video Modes
« Reply #2 on: August 15, 2010, 09:00:09 am »
Thank you very much! I'll definitely try that.
-Wander

 

anything