Page 1 of 1

Android Resolution Problem [SOLVED]

Posted: Sat May 04, 2019 9:53 am
by test
When I open my love file, the screen resolution is not 1920x1080. But my phone's resolution is 1920x1080. When I open with an old version of Love, it works in 1920x1080. I do not use google play version. I use the updated APK verslon which is on the love's website. I used t.window.width and t.window.height in conf.lua but nothing changed. How can I set resolution to my phone's current resolution on Android? Thanks...

Re: Android Resolution Problem

Posted: Sat May 04, 2019 1:16 pm
by pgimeno

Re: Android Resolution Problem

Posted: Sat May 04, 2019 1:18 pm
by test
So if I use old version of love, dpi is off as default right? Because there is no problem for old versions.

Re: Android Resolution Problem

Posted: Sat May 04, 2019 2:00 pm
by raidho36
Yes you could simply use older version if you don't need new version's features. This problem should be fixed in the future versions.

Re: Android Resolution Problem

Posted: Sat May 04, 2019 2:34 pm
by pgimeno
Note that it's not a problem of resolution. The resolution is the same. It's just that the coordinates don't match pixels.

A quick and dirty workaround is to use this at the beginning of love.draw:

Code: Select all

  love.graphics.scale(1/love.window.getDPIScale())
and use love.graphics.getPixelWidth etc instead of love.graphics.getWidth etc.

Re: Android Resolution Problem

Posted: Sat May 04, 2019 3:04 pm
by test
Thanks pgimeno. But why did you say dirty for the code you writed? It works. If I use this code and build APK, is it bad pratice? What is the correct way?

Re: Android Resolution Problem

Posted: Sat May 04, 2019 3:07 pm
by pgimeno
It doesn't cover all functions, e.g. canvas creation, and if you use vertex shaders, it may not work properly, but for a simple game it works.

Edit: The "correct" way is to use the coordinates unmodified, and use love.window.toPixels/fromPixels if you really need to convert to/from real pixels. You still have the full resolution if you draw images.

Re: Android Resolution Problem

Posted: Sat May 04, 2019 3:14 pm
by test
Thanks. I think I am going to solve this situation (not a problem) by creating a 1920x1080 canvas and setting dpi to 1.