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

Author Topic: Changing video mode  (Read 7355 times)

0 Members and 1 Guest are viewing this topic.

Xorlium

  • Jr. Member
  • **
  • Posts: 84
    • View Profile
Changing video mode
« 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!

nulloid

  • Full Member
  • ***
  • Posts: 134
    • View Profile
Changing video mode
« Reply #1 on: May 07, 2010, 03:58:10 am »
You just simply recreate the renderwindow with the correct settings :)

Xorlium

  • Jr. Member
  • **
  • Posts: 84
    • View Profile
Changing video mode
« Reply #2 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?

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
Changing video mode
« Reply #3 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
I use the latest build of SFML2

Xorlium

  • Jr. Member
  • **
  • Posts: 84
    • View Profile
Changing video mode
« Reply #4 on: May 07, 2010, 05:09:45 am »
Thanks!!

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