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

Author Topic: Swapping fullscreen and windowed mode  (Read 2193 times)

0 Members and 1 Guest are viewing this topic.

Beta_Ravener

  • Jr. Member
  • **
  • Posts: 51
    • ICQ Messenger - 271426715
    • View Profile
Swapping fullscreen and windowed mode
« on: July 26, 2010, 01:46:48 am »
Is there way to switch between video modes without recreating whole class?

My current code, reacts on ctrl+enter:

Code: [Select]
if (Event.Key.Code == sf::Key::Return)
{
if(Event.Key.Control){
fullsize = !fullsize;
delete App;
if(fullsize)
App = new sf::RenderWindow(sf::VideoMode(VAL->ScreenX,
VAL->ScreenY, 32), caption,sf::Style::Fullscreen);
else
App = new sf::RenderWindow(sf::VideoMode(VAL->ScreenX,
VAL->ScreenY, 32), caption);
if(!App)
return EXIT_FAILURE;
}
}

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Swapping fullscreen and windowed mode
« Reply #1 on: July 26, 2010, 09:04:59 am »
Use the Create function instead of creating a new instance. This has the exact same effect, but you can keep the same instance ;)
Laurent Gomila - SFML developer

Beta_Ravener

  • Jr. Member
  • **
  • Posts: 51
    • ICQ Messenger - 271426715
    • View Profile
Swapping fullscreen and windowed mode
« Reply #2 on: July 26, 2010, 01:38:31 pm »
Thanks works like charm and I don't have to update pointer through all classes.

One more question, SFML outputs this line into console while switching to fullscreen: "The requested video mode is not available, switching to a valid mode".

It comes to fullscren fine, there's just little blink, but I would like to know what's that "valid" mode when this one isn't:

Code: [Select]
App.Create(sf::VideoMode(VAL->ScreenX, VAL->ScreenY, 32), caption,sf::Style::Fullscreen)

And does it point to sf::VideoMode or sf::Style?

Edit: Nevermind I got it, it's complaining about screen resolution. Is there way to check if the screen resolution is valid for computer?

Edit 2: got that too... just for anyone looking there:

Code: [Select]
sf::VideoMode::GetModesCount
sf::VideoMode::GetMode


or

Code: [Select]
sf::VideoMode::IsValid

Thanks for help with that switching though :)

 

anything