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

Author Topic: SFML 2.1 getSize() Returns Incorrectly with Devices Using Autoscaling (Bug?)  (Read 5883 times)

0 Members and 1 Guest are viewing this topic.

Acumen

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
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.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
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?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Acumen

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
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.
« Last Edit: May 08, 2014, 07:48:07 pm by Acumen »

Acumen

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Any other information I can provide?

Should I submit a report/request?

Daerst

  • Newbie
  • *
  • Posts: 12
    • View Profile
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?

Acumen

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
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.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

majesty2450

  • Newbie
  • *
  • Posts: 2
    • View Profile
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.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
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. :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

majesty2450

  • Newbie
  • *
  • Posts: 2
    • View Profile
I made an issue here: 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.

 

anything