SFML community forums

Help => Window => Topic started by: CreaM on June 11, 2015, 09:33:02 pm

Title: Fullscrean falling
Post by: CreaM on June 11, 2015, 09:33:02 pm
Hello, this is code cut off my game - strange thing is that fullscrean sometimes (randomly) falls. Sometimes it stays windowed, sometimes it falls to window and then resize back to fullscrean...
while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event)){
                        if (event.type == sf::Event::Closed)window.close();
                        if (event.key.code == sf::Keyboard::F4)window.create(sf::VideoMode(800, 650), "My window", sf::Style::Fullscreen);
                        if (event.key.code == sf::Keyboard::Escape)window.create(sf::VideoMode(800, 650), "My window", sf::Style::Default);
                }
 
is there a mistake in code? , is good idea to use events for this? Any ideas?
Thanks for replies.
Title: Re: Fullscrean falling
Post by: AlejandroCoria on June 11, 2015, 09:45:07 pm
You have to check if the event type is KeyPressed or KeyRelease before seeing what the key code.
Title: Re: Fullscrean falling
Post by: Hapax on June 11, 2015, 10:31:05 pm
Aside from failing to check the correct type before attempting read the key code as AlejandroCoria already mentioned, your resolution is not a typical monitor resolution so could be failing to create fullscreen as the monitor doesn't have the mode available.
Maybe try this test (http://www.sfml-dev.org/documentation/2.3/classsf_1_1VideoMode.php#aa64ff5420dde3b31c24b9c4e2be9cd9c).
Title: Re: Fullscrean falling
Post by: AlejandroCoria on June 12, 2015, 01:45:04 am
Wow, I completely overlooked that :P
Title: Re: Fullscrean falling
Post by: CreaM on June 12, 2015, 08:18:21 am
Oh, 800 x 650 isnt a valid mode, stupid mistake...
Thank you for solving it.  :-*