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

Author Topic: How to check if sf::RenderWindow is fullscreen?  (Read 10940 times)

0 Members and 1 Guest are viewing this topic.

DasOhmoff San

  • Guest
How to check if sf::RenderWindow is fullscreen?
« 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?

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: How to check if sf::RenderWindow is fullscreen?
« Reply #1 on: June 13, 2019, 12:30:59 am »
Hi.
You have to save what style you used at the window creation yourself.

DasOhmoff San

  • Guest
Re: How to check if sf::RenderWindow is fullscreen?
« Reply #2 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?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: How to check if sf::RenderWindow is fullscreen?
« Reply #3 on: June 13, 2019, 12:43:50 pm »
Not yet, no. :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

DasOhmoff San

  • Guest
Re: How to check if sf::RenderWindow is fullscreen?
« Reply #4 on: June 13, 2019, 10:13:19 pm »
Ah ok thx.

LastStrawLasb

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
Re: How to check if sf::RenderWindow is fullscreen?
« Reply #5 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

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: How to check if sf::RenderWindow is fullscreen?
« Reply #6 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.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

kojack

  • Sr. Member
  • ****
  • Posts: 343
  • C++/C# game dev teacher.
    • View Profile
Re: How to check if sf::RenderWindow is fullscreen?
« Reply #7 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).

 

anything