QuantumBadger / Speedy2D

Rust library for hardware accelerated drawing of 2D shapes, images, and text, with an easy to use API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WindowSize::ScaledPixels doesn't work correctly

blaumeise20 opened this issue · comments

  1. I would expect windows with a scale factor higher than 1 to automatically scale its content. If you open a website on a retina display, it isn't smaller, but has better resolutions.
  2. For some reason when the window opens on a monitor with scale factor 1 but my main monitor is retina, it is still scaled (has correct size on main monitor, but also has problem 1.)

I would expect windows with a scale factor higher than 1 to automatically scale its content. If you open a website on a retina display, it isn't smaller, but has better resolutions.

What you're describing sounds like the intended behaviour -- Speedy2D's drawing functions work with physical pixels, and it's up to the application to decide how to perform scaling. Speedy2D notifies the application when the scale factor changes, but will not attempt to scale your content automatically or change the size of the window.

Simply multiplying the coordinates by the scaling factor isn't always a sensible thing to do. For example, if the scaling factor is 150%, some lines which were previously pixel-aligned will now be halfway between two pixels, and the result will be blurry. The application may want to handle this more intelligently, e.g. by rounding to an integer number of pixels. Similarly, when drawing images, the application needs to be aware of the real physical resolution of the screen.

For some reason when the window opens on a monitor with scale factor 1 but my main monitor is retina, it is still scaled (has correct size on main monitor, but also has problem 1.)

Could you give more details please? Specifically:

  • Which OS you're using
  • The scale factor of each monitor
  • Are you setting a position when creating the window? I.e. what are the window creation options
  • Which monitor is the window opening on?

What you're describing sounds like the intended behaviour

Hmm ok, I unserstand. So that means I have to do calculations by hand, if I understood correctly?

Could you give more details please?

I'm using MacOS 10.15.7.
Also I have 3 monitors, the main integrated retina display in the iMac, and the 3rd monitor is where the window opens.