haxeui / haxeui-openfl

The OpenFL backend of the HaxeUI framework -
http://haxeui.org
MIT License
42 stars 14 forks source link

html5, on high density screens (bigger DPI), game contents appears zoomed-in and cut #30

Closed Helgiii closed 3 years ago

Helgiii commented 5 years ago

Android, Chrome and Firefox

class WndTest extends Component
{
    public function new()
    {
        super();

        graphics.beginFill(0xff0000, 1);
        graphics.drawRect(0, 0, 320, 480);
        graphics.endFill();

        graphics.beginFill(0x00ff00, 1);
        graphics.drawRect(320, 0, 640, 480);
        graphics.endFill();
    }
}

I tried to add this test wnd using mere this.addChild (need to inherit from Sprite) - works and looks fine everywhere. And then with haxeui

        Toolkit.init();
        Screen.instance.addComponent( new WndTest() );

With haxeui it works ok in desktop browser, and as I said appears cut and zoomed-in in mobile browser (with high density screen). Alarm!))))

Helgiii commented 5 years ago

most mobile devices nowadays have high dpi screens, any chances this problem could be fixed? or at least some hints where to watch and try fix it myself..

looks like I'll have to rewrite all gui I have in my app to not use haxeui, or switch to unity

ianharrigan commented 5 years ago

Hi, sorry, this seems to have slipped through the net somewhat... does Toolkit.scale have any effect? What does Screen.instance.dpi return?

Helgiii commented 5 years ago

Hi, thanx for pointing out those params, just checked them on a device and screen dpi is: 288 toolkit scale: 2

ianharrigan commented 5 years ago

Does playing with the scale have any decent effect? Like, what would be a "good" value for example?

Helgiii commented 5 years ago

I was testing on Meizu m6 note smartphone, and Screen.instance.dpi was 288 there but physically (in specs) the device has 403 ppi. By the way are those terms used properly here? (no confusion?) ok I'll try chaning, playing with those parameters

Helgiii commented 5 years ago

Toolkit.init(); Toolkit.scale = 1;//solves the problem

so I guess the autoScaleDPIThreshold and autoscale in general is a work in progress or some test code nyah? thanx, we can close this:)

ianharrigan commented 5 years ago

Im not sure this should be closed. It seems something isnt working correctly with the autoscale feature, so, to understand, when you have dpi of 288 the UI is too big? Or too small?

Helgiii commented 5 years ago

game contents (the whole picture) seemed 2x upscaled (zoomed in). looking though the code back then I saw that dpi was 288 which is more than autoScaleDPIThreshold(160), and thus autoscale got turned on and was equal to 2..