SFML community forums
Help => Window => Topic started 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?
-
Hi.
You have to save what style you used at the window creation yourself.
-
Oh, ok, is there no some kind of get function for that?
For example getStyle() or so?
-
Not yet, no. :)
-
Ah ok thx.
-
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
-
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.
-
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).