SFML community forums
Help => Window => Topic started by: pkersey on November 30, 2011, 12:54:20 am
-
Hello. I've been doing my first experiments with SFML 1.6 and came with this issue.
Would somebody please explain how do I switch from windowed mode to fullscreen, and then back to windowed mode? It's not working under Ubuntu 11.04, NVidia GTX 560.
Here's the code fragment.The mode switch was supposed to happen whenever the user pressed ALT+ENTER, and sometimes it works when going from windowed to fullscreen, but when trying to get back to windowed mode all I have is a black screen and I need to kill the process using the console to get my Desktop back.
EDIT: The problem doesn't happen under Win XP / Intel G33/G31 Express. The exact same code switches video modes perfectly as desired with those key presses.
if (window.GetInput().IsKeyDown(sf::Key::LAlt) && window.GetInput().IsKeyDown(sf::Key::Return))
{
if (windowStyle == sf::Style::Fullscreen)
{
windowStyle = sf::Style::Close;
}
else
{
windowStyle = sf::Style::Fullscreen;
}
window.Create(sf::VideoMode(800, 600), "X", windowStyle);
}
Thanks in advance!
-
Not sure if this will fix what you described.
The way you are processing the input is by checking if the keys are currently pressed. If this code is being called every iteration of a loop (say 60 times a second), then the if statement will be entered say, 30 times if you hold the buttons down for half a second.
Instead what you should do is window.PollEvents(), and look for a KeyPressed event for sf::Key::Return, and && with window.GetInput().IsKeyDown(sf::Key::LAlt)
-
Thanks for your considerations, but sorry, I think your information is innacurate because, as I've reported previously, I've been using SFML 1.6. PollEvents() is SFML 2.0 only.
And I just found out the problem is Linux-only (see "EDIT:"), then it's presumably either a NVidia driver issue or a platform-specific bug. The key combination switches video modes perfectly back and forth under Windows XP.
Thanks for your willing to help. If you have any other ideas, just let me know. Let's see what others have to say about this, too. Meanwhile I'll be researching the problem.
-
Thanks for your considerations, but sorry, I think your information is innacurate because, as I've reported previously, I've been using SFML 1.6. PollEvents() is SFML 2.0 only.
sbroadfoot90's information is still valid. You don't seem to have read this tutorial on the tutorial section:
http://www.sfml-dev.org/tutorials/1.6/window-events.php
PollEvents is just the 2.0 version of GetEvent.
About your problem, I'm sorry, but I cannot help.
-
Let's make all things clear. First:
PollEvents is just the 2.0 version of GetEvent.
That was exactly what I wrote here, and you seem to have completely overlooked it:
PollEvents() is SFML 2.0 only.
Now this:
You don't seem to have read this tutorial on the tutorial section:
http://www.sfml-dev.org/tutorials/1.6/window-events.php
Sorry but you are wrong. I not only have read that as my code is following the instructions. I have read all the tutorials, the documentation, many forum posts and websites before started coding and also seeking any help, what I consider should be standard behaviour for everybody.
This topic has nothing to do with key events. Please let's keep in the subject.
Lastly:
About your problem, I'm sorry, but I cannot help.
Please don't get me wrong, but if you can't help others, don't just go posting anything that can't be of any use, moreover when you seem not to be reading the posts with due attention and don't care about the problem.
I'm not flaming you, again don't get it wrong, but your message was completely irrelevant. I'll be glad to be of any help to you in the future if the time comes. In fact I'm your colleague.
So people, back into the subject... any information? Thanks.
-
I've just commented that what sbroadfoot90 might help you, you would just had to use the right command to get the events. I said that it was SFML 2.0 only, and I said that there was another equivalent method for SFML 1.6, just that.
Sorry if I sounded offensive, that was not my intention.
-
I've just commented that what sbroadfoot90 might help you, you would just had to use the right command to get the events.
No problem, pal. I didn't get it wrong. Let's just stick to the subject. You're always welcome, thanks.
-
I tested the code in my friend's Linux box with a Radeon card and the problem doesn't happen. Currently researching ways on how to work around the issue. As this turns out not to be a SFML related problem, I'm considering this topic done at least for now.
Thanks everybody.