SFML community forums

Help => Window => Topic started by: BlueCobold on January 13, 2015, 11:55:19 pm

Title: [Mac] Fullscreen modes not scaled to screen size
Post by: BlueCobold on January 13, 2015, 11:55:19 pm
Hi.

I'm using master branch SFML on OS X 10.10 and when setting fullscreen-modes with a resolution smaller than my desktop resolution, I get a small window in the middle of the screen and large black areas around it. It doesn't get scaled to the full screen size on OS X, but it does scale to the full screen on Win7. Other games on OS X in fullscreen do scale properly, just SFML doesn't. The smaller resolution I chose, the smaller gets the displayed window in the center of my screen. The used resolutions are valid fullscreen-modes and are retained/confirmed via sf::VideoMode::getFullscreenModes().
What am I missing? I am not using multiple monitors or something.

Edit: The sf::Mouse::getPosition() call does return 0/0 for the left upper point of the screen, but not when moving it to the area at which my SFML-window is displayed. When using an 800x600 window on a 1440x900 screen, the upper left coordinate where my window is displayed returns a mouse-coordinate of 320/150. That I can even move the mouse outside of the area at which my window is displayed, feels odd.

Greetings.
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: Hiura on January 14, 2015, 09:44:50 am
It was a design choice some time ago. What I won't do, because of Apple's policy (*), is perform a hard switch as it's currently done on Windows. Actually, the Linux impl is being revised (https://github.com/SFML/SFML/pull/780) to follow the same behaviour.

But should the view be stretched to fit the screen (with proper ratio), or should it use letterboxing? That question is still open to discussion since I had not enough feedback when implementing fullscreen support.


(*)
Quote from: Apple
Avoid changing the display resolution from that chosen by the user.
(Source (https://developer.apple.com/library/mac/documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_fullscreen/opengl_cgl.html))
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: eXpl0it3r on January 14, 2015, 11:47:42 am
If you don't scale the window at all, then what's the point of specifying a different resolution?
I mean if it's just a question of maintaining the ratio or fully stretching it, then I guess one could discuss this, but otherwise when I request a 800x600 resolution in fullscreen, I want this to actually scale to my "full screen". ;)
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: Hiura on January 14, 2015, 11:59:55 am
Quote
when I request a 800x600 resolution in fullscreen, I want this to actually scale to my "full screen".
That's a valid point.

But the question remains: should it be scaled to fit the screen with the proper ratio (with letterboxing), or just stretched.

I feel keeping a letterboxing solution -- but not a mini window -- would be better. Having something distorted just to fill the screen is really ugly and since we don't provide any monitor API (yet) the dev has no idea of the actual ratio of the display so (s)he cannot choose automatically a proper video mode.

Another solution would be to introduce more specialised fullscreen flag such as HardSwitchFullscreen which would result in a fully stretched window.
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: Tank on January 14, 2015, 12:18:25 pm
I would not automatically do letterboxing. A monitor API isn't needed as well: If you set 800*600, then you can simply do letterboxing yourself, since you now how to transform it to maintain the correct ratio.

I don't think that SFML should interfere with this. I've never seen this happening elsewhere, and I really would not expect SFML to "fix" my things without me explicitly saying so.
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: Hiura on January 14, 2015, 01:34:41 pm
I would have to search again for it but if remember correctly at least one guy complained about the screen being stretched... So I'm *really* interested in everybody's opinion on the subject as I am myself not on any side (yet).

If I've got only one guy every two years or so complaining about my impl, I just have no idea if I'm doing my job right or not.  ::)
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: binary1248 on January 14, 2015, 01:49:04 pm
Requirements change, and I guess the hardest part for us is judging from the opinions (if any ;D) of the community what those requirements are.

As a general rule of thumb, I like to say: The effort required to perform a task should be inversely proportional to the frequency in which that task has to be performed.

This in my opinion leads to wide acceptance and usability of an API. The important thing to remember as well, is to always allow users to do what they want (i.e. not limit them in any way), no matter how crazy it is ;). The effort it should take them to do what they want, the rule above already explains.

I don't think it is safe to assume that a single individual complaining about stretching is enough to warrant the library being designed around that sole individual's requirements. If you look at all operating systems and their users, this really becomes just another edge case. I haven't experienced first-hand any letterboxed fullscreen applications/games on Windows/Linux yet, and even in videos of such games, it is a generally accepted opinion that the developer just didn't want to give the extra effort to support "real fullscreen" properly :P.
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: eXpl0it3r on January 14, 2015, 03:08:06 pm
As said on GitHub I think it should probably fully expand. If I go fullscreen, I'd personally expect that I get every last pixel on the monitor to manipulate. Sure if the resolution doesn't match you might get odd scaling, however this is a development issue and not a graphics library issue.
Maybe one could compare it a bit to the sf::View. If you scale the window SFML won't just keep the view's ratio and it won't stay the same size as it was before, instead it's "attached" to the window itself and will scale with the resizing window.

I mean sure automatic letter boxing can be useful if you're too lazy to adjust the view yourself or if you don't know how to support proper fullscreen mode. But from my point of view it's effectively making decisions for the developers and thus limiting them in a certain way. ;)
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: dabbertorres on January 14, 2015, 05:54:52 pm
I haven't experienced first-hand any letterboxed fullscreen applications/games on Windows/Linux yet, and even in videos of such games, it is a generally accepted opinion that the developer just didn't want to give the extra effort to support "real fullscreen" properly :P.

Just to add to this... The game, Faster Than Light (great game btw), which (iirc) uses SDL (1.2 is the version of the lib shipped with the game), and runs on Windows, OSX, Linux, offers 4 options for windowing.
1. Windowed mode
2. Fullscreen Stretch
3. Fullscreen Border
4. Fullscreen Native

Windowed mode works as expected.
Stretch works as expected, stretching the game to fit the monitor, then letterboxing as needed to keep the game's aspect ration (16:9).
Border works as expected, letterboxing the game.
Native though, changes the native resolution of the monitor to the game's resolution and turns off any other monitors.

This is all on Linux; Windows behaves similarly. Don't know about OSX.

I'm not sure of the inner workings of the game to support all of these options, but, SFML, in the past at least, has always done #4 on Linux. Which, as a user, I consider to be the least favorable, since I have to go and reset my display settings in my WM afterwards. It also seems to ignore my primary monitor setting.
Stretch, is what I consider to be the best option, though Border could be fine. I'm just not a fan of letterboxing. :P

As a programmer though, I think having options like FTL does would be best. So, a style flag for each:

sf::Style::FullscreenStretch - would stretch to fill the monitor. If the programmer wants to then letterbox to match an aspect ratio, leave it up to them
sf::Style::FullscreenBorder - letterbox completely
sf::Style::FullscreenNative - not preferred, but, would do the "hard switch" that has been mentioned if I understood correctly

Would be best in my opinion. I don't know how much work this entails, as I don't know Xlib or XCB very well, but that would be my preference. I'd be happy to learn and help with it if needed though.


tl;dr: As a user, I prefer stretch fullscreen, and not having my resolution and monitor settings adjusted by the program.
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: BlueCobold on January 14, 2015, 06:50:27 pm
Quote from: Apple
Avoid changing the display resolution from that chosen by the user.
(Source (https://developer.apple.com/library/mac/documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_fullscreen/opengl_cgl.html))
I don't want to change the games resolution without asking the user. The user will change it on his own demand by using an ingame-option-menu. Allowing the user to change the resolution, does not violate this policy at all. A graphics library though shouldn't care about any policies from Apple at all (at least in this case), it is the developer who uses the library who has to make sure he complies to it. The library only should provide the technical possibility to the developer who is using it.

However, I do not expect any letterboxing to happen either. If I want fullscreen, I expect the full screen to be used. Letterboxing isn't really full screen. And if the user selects a mode which doesn't fit the screen aspect ratio, the game would need to take care of that, not the fullscreen mode. If it doesn't want bad aspect-ratios, it shouldn't allow these to be used.

It would be fine by me if internally SFML would use desktop resolution and only scale the chosen resolution to the full screen. Looks like Diablo 3 is doing the same (the screenshots are 2880x1800 even in 1920x1200 fullscreen resolution).

PS: The mouse-coordinates should also be scaled when using the stretch-to-full-thing ;)
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: Hiura on January 14, 2015, 07:25:52 pm
There is something I remember now that I need to add while other continue posting their opinion: on OS X, a hard switch will result in a (potentially scaled) view that is not stretched. Regarding the UX on that OS, having a stretched view is not necessarily what the developer might expect. However, a dev working on multiple OS might like a library that has the same behaviour on all platform. So all in all I don't mind either way.

But if we don't perform a hard switch, on OS X, Linux or Windows, the next question is what should getFullscreenModes return. I guess if we introduce HardSwitchFullscreen we are fine, with perhaps a LetterboxedFullscreen mode too (that scales but not stretches).
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: BlueCobold on January 14, 2015, 07:31:00 pm
Well, I'm using SFML for a game on Windows, OS X and iPad (plus Android in some time). That's why I don't like what the current OS X implementation does in regard to fullscreen-modes. How this will be solved I don't really bother with. I'm fine with a hard switch and also with a stretched mode. I guess stretching would cause less issues for SFML in case of a crash or when alt+tabbing out of the application. Since Blizzard seems to also just stretch, sounds like a plausible way to me.
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: BlueCobold on March 21, 2015, 08:08:56 pm
So what's up with that? Is there anything planned or will it require me to implement my own stuff to do proper fullscreen display? Just that I know if I should wait or just go for it myself.
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: Hiura on March 22, 2015, 04:01:01 pm
Since the discussion is quite long and comments are scattered in various places, let's try to recap with a proposition. Please tell me if it makes everybody happy.  ;)

I'd say we should introduce a second fullscreen style flag:
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: BlueCobold on March 22, 2015, 05:49:49 pm
That would be the perfect solution.
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: BlueCobold on September 22, 2015, 01:09:53 pm
Any news on this topic?
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: Hiura on September 23, 2015, 01:58:59 pm
No, not really. :-/

Since the discussion is quite long and comments are scattered in various places, let's try to recap with a proposition. Please tell me if it makes everybody happy.  ;)

I'd say we should introduce a second fullscreen style flag:
  • one for hard switch, and
  • one for soft switch which would fill most of the screen without stretching (i.e. it would respect the ratio asked by the user).


What do others think?
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: Laurent on September 23, 2015, 02:07:08 pm
I haven't read the full topic, but that:
Quote
one for soft switch which would fill most of the screen without stretching (i.e. it would respect the ratio asked by the user).
... sounds like an ugly hack :P

It also sounds like a user problem (scaling, stretching, resizing, whatever... properly the window and/or view inside it) rather than a feature to add to SFML.
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: mkalex777 on September 24, 2015, 08:14:16 am
I have a small question about it.
What is the better:
1) adjust all View parameters on resize event only
2) adjust all View parameters on every frame

I'm using 2, so the view always contains correct parameters.
But may be it's bad from performance perspective...

View parameters: center position, size, viewport
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: BlueCobold on September 24, 2015, 08:38:58 am
Wrong topic, dude. But in the end, it doesn't matter, you won't notice any performance issues. It would be enough to make it on resize, but it's no problem to do it every frame.
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: Hiura on September 25, 2015, 11:07:19 am
... sounds like an ugly hack :P

Tell that to SDL's team =P https://wiki.libsdl.org/SDL_SetWindowFullscreen

More seriously:

After reading this discussion again plus the one on github, I understand and agree that a hard-switch is needed, but the question remains if we want to provide a soft-switch.

Beside going along Apple's policy, it can be seen as a convenience feature for the users. Regarding SFML's philosophy (http://www.sfml-dev.org/contribute.php#philosophy), it's indeed against the "slim API" aspect, but I believe it fits well in the "pragmatic" one.
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: Laurent on September 25, 2015, 11:20:36 am
I guess we need a concrete example: how would the soft-switch be implemented, if done entirely on user side?
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: BlueCobold on September 25, 2015, 01:19:11 pm
Basically by rendering into a RenderBuffer and then rendering this in a scaled version (keeping aspect-ration by adding black areas or not keeping it by filling the full screen) to the desktop resolution. I still understand the Apple hint like: "Don't change without asking" which actually is a good advise for any kind of game imo - switch only if the user wants to explicitely (via menĂ¼ or config files). However, I'm not sure that Apple compliance is a topic for SFML at all. And even if SFML would implement soft & hard-switch, the games using SFML would still need different code for different systems, because of not allowing to hard-switch resolutions on OS X (and thus using soft-switch on OS X and using hard-switch everywhere else). So either make it a hidden soft-switch on OS X being true fullscreen or change it to a hard-switch. Both of these would result in what the devs expect. I don't think the devs need both options as long as the result looks correct.
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: Hiura on September 25, 2015, 04:05:42 pm
There's not only the display to be taken care of. The inputs (e.g. mouse coordinates) need to be adjusted as well.

Performance wise, it might be better to take advantage of some unexposed backbuffer -- but I didn't test this theory so it's probably not a valid argument.
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: 6Dragon6 on June 26, 2016, 09:28:23 pm
 Hello there, I am so sorry to do this necropost but would this work? It does work in Windows.

sf::RenderWindow window(sf::VideoMode(640, 320), "Proyecto001",sf::Style::Fullscreen);
view.reset(sf::FloatRect(1, 1, 640, 320));
window.setView(view);
 

 This creates a "camera" that stares only at whatever you chose, in this case the first 640x320 pixels, and stretches them to the full screen.

 This would solve the problem, however, this will not respect the aspect ratio, obviously.

 Greetings!
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: BlueCobold on June 26, 2016, 11:09:11 pm
No, it doesn't work. Because on OS X, the window does not fill the entire screen. The view is unimportant here. The code fills the remaining area with black. See the screenshots I had attached in my first post.
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: 6Dragon6 on June 27, 2016, 12:22:17 am
 That's exactly what it does in Win7 if I am understanding correctly:

 Before, the remaining space of the screen is filled with black instead of stretching the game screen, the sprite and the red background keep their size (the red background represents the size of the game screen, the rest is black):
https://s32.postimg.org/a4fpvem45/project001_2016_06_26_23_19_08_91.png

 After applying a view, the game screen fills the whole thing, the sprite and the background are stretched:
https://s32.postimg.org/h4nf24bjp/project001_2016_06_26_23_19_16_49.png


 Unless I am misunderstanding something it looks like we are on the same boat, except that code worked for me.

PS: I can't seem to find the attachments you left here :/
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: BlueCobold on June 27, 2016, 06:32:50 am
Windows and OS X behave different. No matter if I apply a proper view (which I'm doing) or not. Please stop discussing until you have it running with OS X. You're not helping at the moment. It works fine on Windows, Linux, Android and iOS. It does not on OS X.
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: 6Dragon6 on June 27, 2016, 12:34:21 pm
  At least I was trying to help, you are welcome, nice manners by the way.
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: BlueCobold on June 27, 2016, 12:40:39 pm
Don't get me wrong, but the topic and reason for the behaviour on OS X had been discussed long enough. I know you're only trying to help, but posting things about how they work on a different system, are practically not helpful. I am glad you did revive this necro-thread though, it probably still has not been changed. Has it?
The worst thing that could happen is that the thread gets closed with: "Works for me. 6Dragon6 has proven so" - although the problem still remains. Just because someone didn't read the topic in it's entirety. I want to prevent an upcoming of the idea that there is no problem on OS X at all and I'm just not clever enough to set a proper view. But it's not related to views at all.
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: Hiura on June 27, 2016, 02:35:59 pm
I want to prevent an upcoming of the idea that there is no problem on OS X at all

For the record, I know and accept that the current implementation is not to everyone's taste. But there're two problems: I don't have time to fix this myself nor is there a consensus on the way to fix it. Until the latter is resolved and someone offer a PR, this issue is not going to progress...

You guys are welcome to start and animate a (new) discussion on the (broad) different issues and alternative ways to fix them, partially or entirely based on what was presented in this thread.
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: BlueCobold on June 27, 2016, 03:39:17 pm
Well, I am not in the position to decide what needs to be done.

The possible solutions are:
1) A soft-switch (as currently) which actually incorporates the entire screen and doesn't care about aspect-ratio
2) A soft-switch (as currently) which actually incorporates the entire screen and does letter-boxing
3) A hard-switch
4) A combination of all the other three, up to the developer to chose from
Personally I prefer (1) or (3) as (2) is something the user needs to implement himself also on all other platforms if not using a native aspect-ratio and therefor it's not a business of SFML. Version (3) gives a damn on Apples guideline (or doesn't, depending on how you want to read/interpret them). Version (1) would work quite closely to the current implementation, but it would actually use the entire screen. Version (2) would give the user/programmer an unexpected result since that is not what happens on Linux or Windows iirc. The resulting solution should of course be consistent to the other OS-specific behaviours.

I could possibly implement it myself and make a PR, but that would be useless until there's a decision made by the SFML-team on which solution is the desired one. (4) is not something I might be willed to invest my time in as it would be too much time-consuming.
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: Hiura on July 03, 2016, 04:43:32 pm
Seen the lack of answer from other community and core members, I would review and accept a PR for (1) were you or someone else create one, for consistency sake among OSes. I would, however, still welcome the ability to let the user decide between a true hard switch and a soft, ratio-preserving fullscreen mode as I suggested previously (http://en.sfml-dev.org/forums/index.php?topic=17246.msg127678#msg127678).
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: zTn on August 08, 2021, 05:23:23 pm
As it stands, I can't find a solution to this and it appears that my beloved SFML is just broken on MacOS.  Since all other apps/games are not broken by what Apple has done here, isn't this a question of what SFML is doing differently?  I must be missing something.  Can someone explain to me why SFML cannot just do what everyone else is doing?  Anyone?
Title: Re: [Mac] Fullscreen modes not scaled to screen size
Post by: ppnl on January 25, 2023, 03:04:22 pm

As someone new to SFML and graphics generally my suggestion is that you make it clear what SFML is doing. I expect VideoMode to change the video mode. I expect Fullscreen to be, you know, full screen. I am ok with SFML supplying or not supplying whatever functionality you wish. I do resent the time I have wasted trying to understand why Fullscreen isn't full screen. The names of the functions and the documentation should show clearly what is happening.

Beyond that I would suggest that SFML ultimately allow people to do whatever they want even if it is ugly, OS dependent or unwise. Maybe by using #include <SFML/unwise.hpp>. That should be warning enough.