SFML community forums

Help => Window => Topic started by: DasOhmoff San on June 12, 2019, 11:42:12 pm

Title: How to check if sf::RenderWindow is fullscreen?
Post by: DasOhmoff San on June 12, 2019, 11:42:12 pm
Hello, I have a very small question.
If I have a sf::RenderWindow, how can I check whether it is fullscreen or not?
Title: Re: How to check if sf::RenderWindow is fullscreen?
Post by: G. on June 13, 2019, 12:30:59 am
Hi.
You have to save what style you used at the window creation yourself.
Title: Re: How to check if sf::RenderWindow is fullscreen?
Post by: DasOhmoff San on June 13, 2019, 11:12:42 am
Oh, ok, is there no some kind of get function for that?
For example getStyle() or so?
Title: Re: How to check if sf::RenderWindow is fullscreen?
Post by: eXpl0it3r on June 13, 2019, 12:43:50 pm
Not yet, no. :)
Title: Re: How to check if sf::RenderWindow is fullscreen?
Post by: DasOhmoff San on June 13, 2019, 10:13:19 pm
Ah ok thx.
Title: Re: How to check if sf::RenderWindow is fullscreen?
Post by: LastStrawLasb on June 10, 2021, 09:51:18 pm
There is no "isFullscreen()" in SFML, but it is easy to make your own:

sf::RenderWindow window(sf::VideoMode(WIDTH, HEIGHT), TITLE, sf::Style::Resize | sf::Style::Close);
bool isFullscreen()
{
  sf::Vector2u window_size = window.getSize();
  sf::VideoMode videomode = sf::VideoMode::getDesktopMode();
  return(
    window_size.x == videomode.width &&
    window_size.y == videomode.height
  );
}

Rob
Title: Re: How to check if sf::RenderWindow is fullscreen?
Post by: Hapax on June 16, 2021, 10:33:56 pm
Strange necro... :P

It should be noted that that isFullscreen method is unreliable. Not to mention some quirks of certain operating systems, but if there are two (or more) displays, the size of the fullscreen window would not match the desktop.
Title: Re: How to check if sf::RenderWindow is fullscreen?
Post by: kojack on June 17, 2021, 12:01:39 pm
Yep, plus usually fullscreen is a mode that behaves differently, it doesn't only mean the window is the size of the screen (since borderless windowed is the size of the screen but isn't "fullscreen").

There's a function in WindowBase that tells you if the window is fullscreen, but it's private so can't be called from user code.  (WindowBase::getFullscreenWindow() returns 0 if the window isn't fullscreen).