Android Resolution Problem [SOLVED]

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
test
Prole
Posts: 28
Joined: Sun Apr 14, 2019 2:36 pm

Android Resolution Problem [SOLVED]

Post 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...
Last edited by test on Tue May 07, 2019 7:14 pm, edited 1 time in total.
test
Prole
Posts: 28
Joined: Sun Apr 14, 2019 2:36 pm

Re: Android Resolution Problem

Post by test »

So if I use old version of love, dpi is off as default right? Because there is no problem for old versions.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Android Resolution Problem

Post 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.
User avatar
pgimeno
Party member
Posts: 3548
Joined: Sun Oct 18, 2015 2:58 pm

Re: Android Resolution Problem

Post 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.
test
Prole
Posts: 28
Joined: Sun Apr 14, 2019 2:36 pm

Re: Android Resolution Problem

Post 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?
User avatar
pgimeno
Party member
Posts: 3548
Joined: Sun Oct 18, 2015 2:58 pm

Re: Android Resolution Problem

Post 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.
Last edited by pgimeno on Sat May 04, 2019 3:16 pm, edited 1 time in total.
test
Prole
Posts: 28
Joined: Sun Apr 14, 2019 2:36 pm

Re: Android Resolution Problem

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 154 guests