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

Author Topic: c# switch fullscreen/window  (Read 6110 times)

0 Members and 1 Guest are viewing this topic.

hechelion

  • Newbie
  • *
  • Posts: 24
    • View Profile
c# switch fullscreen/window
« on: May 27, 2022, 08:16:34 pm »
Hi.

I would like to know how I can switch between fullscreen and windows mode but without having to restart the game (To implement a mode switch with Alt-Enter).

Searching in google I found that with C it can be done with "Window->create", but I have not been able to find how to do it with C# in .NET Core.

Thank in advance
« Last Edit: May 29, 2022, 04:32:50 am by hechelion »

hechelion

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: c# switch fullscreen/window
« Reply #1 on: May 29, 2022, 05:12:41 am »
After several trial and error. I have managed to switch between modes with the following code, I don't know if it will be optimal or if it will have some disadvantage, but for now it works.

if (Keyboard.IsKeyPressed(Keyboard.Key.Enter) == true && Keyboard.IsKeyPressed(Keyboard.Key.LAlt) == true) {
                    auxStyle = (auxStyle == Styles.Default)? Styles.Fullscreen: Styles.Default;
                    window.Close();
                    window = new RenderWindow(new VideoMode(oProperties.ScreenWidth, oProperties.ScreenHeight), "SFML running in .NET Core", auxStyle);
                    window.Closed += (_, __) => window.Close();
                } //Alternar ente pantalla completa y ventana con Alt-Enter
 

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: c# switch fullscreen/window
« Reply #2 on: May 31, 2022, 09:02:57 am »
Yes, in C# you'll have to create a new window. Biggest down side of the current design is that you'll need to reassign the event handlers...
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

hechelion

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: c# switch fullscreen/window
« Reply #3 on: June 01, 2022, 04:05:59 am »
Yes, in C# you'll have to create a new window. Biggest down side of the current design is that you'll need to reassign the event handlers...

Thank.

 

anything