SFML community forums

Help => Graphics => Topic started by: Beta_Ravener on July 26, 2010, 01:46:48 am

Title: Swapping fullscreen and windowed mode
Post by: Beta_Ravener 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;
}
}
Title: Swapping fullscreen and windowed mode
Post by: Laurent 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 ;)
Title: Swapping fullscreen and windowed mode
Post by: Beta_Ravener 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 :)