1

I would like to switch between fullscreen and windowed mode. Is there some way to do that without restarting whole game?

Etwus
  • 549
  • 5
  • 15

2 Answers2

2

I would suggest calling the create method on your window (C++, but I'm sure it works in C# as well):

yourWindow->create(sf::VideoMode::getDesktopMode(), "Title", sf::Style::Fullscreen);
Tymo Tymo
  • 93
  • 1
  • 6
  • 1
    I am marking this as answer because it helped me to find the solution. The c# version does not have the create method, but it can be done similarly by closing existing window and assigning newly created window to the existing reference. – Etwus May 27 '20 at 14:30
0

Under C# you can't access ->create like C. you have to close the old RenderWindows and create a new one.

if (Keyboard.IsKeyPressed(Keyboard.Key.Enter) && Keyboard.IsKeyPressed(Keyboard.Key.LAlt) && !auxChangeStyle)
{
  auxStyle = (auxStyle == Styles.Default)? Styles.Fullscreen: Styles.Default;
  window.Close();
  window = new RenderWindow(new VideoMode(800, 600), "Title", auxStyle);
  window.Closed += (_, __) => window.Close(); //reassign the event handlers 
}
Hechelion
  • 1
  • 1