SFML community forums

Help => Window => Topic started by: Acumen on May 08, 2014, 03:49:43 am

Title: SFML 2.1 getSize() Returns Incorrectly with Devices Using Autoscaling (Bug?)
Post by: Acumen on May 08, 2014, 03:49:43 am
New high DPI Windows (possibly other platforms as well) devices incorporate an autoscaling feature which does not work properly with SFML's getSize().

getSize() returns actual display pixels with sf::VideoMode::getDesktopMode() and sf::Style::None but then autoscaling doubles it so 1 pixel is 4 I only see the center quarter of my draw call.

getSize() returns half the actual display pixels (width/2, height/2) with sf::VideoMode(width, height) and sf::Style::Default and it stretches everything to the full size (width, height). Again 1 pixel is 4, but at least I am not offscreen.

Disabling autoscaling in the programs properties menu resolves these issues.

Is this a bug or an un-requested feature? I feel like SFML's default setting should have AutoScaleMode set to None? Is there a reason it is not? Should I submit a bug report and or feature request? Is there an alternate resolution to this issue?

I have not found anything about this as it relates to SFML by searching. I am using SFML 2.1 so if it has been addressed already I apologize. I do not have regular access to a high DPI device so I may not be the best person to spearhead this if there is someone out there who owns one.
Title: Re: SFML 2.1 getSize() Returns Incorrectly with Devices Using Autoscaling (Bug?)
Post by: eXpl0it3r on May 08, 2014, 04:54:19 pm
I think you need to be a bit more detailed. Maybe it's just me, but what is "Autoscaling"?

Where does one set AutoScaleMode to none?
Title: Re: SFML 2.1 getSize() Returns Incorrectly with Devices Using Autoscaling (Bug?)
Post by: Acumen on May 08, 2014, 07:45:20 pm
I really don't know much about it, but apparently it is a Windows form property as of Vista SP2:

http://msdn.microsoft.com/en-us/library/system.windows.forms.autoscalemode(v=vs.110).aspx
http://msdn.microsoft.com/en-us/library/system.windows.forms.containercontrol.autoscalemode(v=vs.110).aspx
http://msdn.microsoft.com/en-us/library/ms229605(v=vs.110).aspx

It seems like it tricks the program into drawing at half scale, then Windows scales it up when displaying. This "feature" apparently exists so that fonts/buttons/etc are large enough to see on new high density displays.

You can see the flag by right clicking on an exe or shortcut:

Properties -> Compatibility -> Disable display scaling on high DPI settings

Display scaling is apparently enabled by default, and when a device has high enough DPI that it is activated getSize() returns incorrectly/inconsistently. As a secondary issue I would prefer SFML disabled it by default and/or that there was some way to set the flag.
Title: Re: SFML 2.1 getSize() Returns Incorrectly with Devices Using Autoscaling (Bug?)
Post by: Acumen on May 12, 2014, 10:50:58 pm
Any other information I can provide?

Should I submit a report/request?
Title: Re: SFML 2.1 getSize() Returns Incorrectly with Devices Using Autoscaling (Bug?)
Post by: Daerst on May 14, 2014, 11:51:55 am
I experience the same problem, and the solution your provided fixes the error. Thanks! I think its a (so-far) unrequested feature, but I really would like to see it in SFML, or at least have a workaround. Can you think of anyway to disable AutoScaling in the code itself?
Title: Re: SFML 2.1 getSize() Returns Incorrectly with Devices Using Autoscaling (Bug?)
Post by: Acumen on May 19, 2014, 04:30:01 am
Ah! Good to know it is not just me. This issue will be more prevalent very shortly as 4k screens are hitting.

I think it should be straight forward to implement in the SFML code, not sure if we can do it without compiling our own version in the mean-time. Should probably wait a bit more to see if the devs have anything else to add about it before submitting anything but I guess it needs both a bug report and feature request for the misreporting of size and lack of ability to turn auto-scaling off.
Title: AW: SFML 2.1 getSize() Returns Incorrectly with Devices Using Autoscaling (Bug?)
Post by: eXpl0it3r on May 19, 2014, 05:28:19 pm
Not sure how I or others could test it, but feel free to create a pull request, that way we could at least see what needs to be changed.
Title: Re: SFML 2.1 getSize() Returns Incorrectly with Devices Using Autoscaling (Bug?)
Post by: majesty2450 on August 16, 2014, 08:40:45 pm
I am new to this forum, so sorry in advance if it was a bad idea posting this here, especially on an old topic...

I am new to SFML, and really like it. I was working on stretching the screen contents with the window while maintaining aspect ratio of the contents. I was able to get it working, however on fullscreen it was all distorted. After much frustration and what now appears wasted time I have come to the conclusion that it does not appear to be my code, and the problem is fixed by following the solution posted here...

I do not actually now if it is from getSize(), but the solution fixed the issue and the dpi made some sense.

I was wondering if there are any other solutions to this other than manually setting compatibility settings on the exe. Any progress / updates / anything really on this. I was unable to find this under bugs.
Title: Re: SFML 2.1 getSize() Returns Incorrectly with Devices Using Autoscaling (Bug?)
Post by: eXpl0it3r on August 16, 2014, 11:31:10 pm
Unfortunately no issue has been created on GitHub and Acumen didn't investigate further, thus it was forgotten.
If you could, it would be nice if you opened an issue on GitHub with a minimal and complete example that reproduces the issue. :)
Title: Re: SFML 2.1 getSize() Returns Incorrectly with Devices Using Autoscaling (Bug?)
Post by: majesty2450 on August 17, 2014, 06:53:19 am
I made an issue here: https://github.com/SFML/SFML/issues/679 (https://github.com/SFML/SFML/issues/679)

Sorry in advance if there are problems with anything I do using github. I have never used github in my life.