Hi thanks for replying so quickly! Yeah, I definitely have the allow-high-dpi flag set in my project.xml file - that was one of the first things I tried, but it doesn’t seem to make a difference, the scale returns 1 no matter what.
I’ve also noticed Hashlink it doesn’t act like I’d expect - I’m running a HL build on windows on a high resolution display which has a scaling of 1.5x. Lime is reporting the scale as 1x but is also internally scaling the window contents up (I guess behind the scenes) so that the contents of the window are kind of blurry. I guess this makes the 1x scale accurate, but also means you can’t really have properly DPI aware apps using it. We don’t use HL as a production platform so it’s not the end of the world for us, but thought it worth mentioning. It’s worth noting that running the same app on html5 target in chrome it picks up the scale as 1.5 correctly and doesn’t scale up the window contents - this is what I would expect to happen ideally.
PS. I don’t mean to sound critical or anything, Lime is an amazingly useful platform, I’d love to be able to contribute at some point once I know a bit more about it.
var scaler = new ScreenDensityScaleCalculator();
scaler.addScaleForDensity(120, 0.75); // ldpi
scaler.addScaleForDensity(160, 1); // mdpi
scaler.addScaleForDensity(240, 1.5); // hdpi
scaler.addScaleForDensity(320, 2); // xhdpi
scaler.addScaleForDensity(480, 3); // xxhdpi
scaler.addScaleForDensity(640, 4); // xxxhpi
var result = scaler.getScale(Capabilities.screenDPI);
You can define any set of DPI buckets that you prefer.
Unfortunately, allow-high-dpi doesn’t work yet on Windows targets that use lime.ndll or lime.hdll yet. That includes C++, HashLink, and Neko on Windows. allow-high-dpi works with html5 on Windows, though.
This is because we use SDL, which is a C++ library, and didn’t support high DPI on Windows until somewhat recently (even though it supported high DPI on other OSes). Unfortunately, someone tried to enable it by upgrading to a new SDL update, and they ran into some issues that seem to indicate that it may still need some improvements on the SDL side.
We’d definitely like to support high DPI on Windows, as long as these issues can be cleared up.
Hey, thanks for your in-depth answer, that’s a great help thanks! I didn’t think about looking at OpenFL’s code, but I guess that’s a great place to start!
The above method you mentioned works great.
Regarding HL I did wonder if that would be some kind of SDL issue - I didn’t know what its high density screen support was like. Good luck in getting that working at some point though.