Löve for Android runs on a different resolution than the native one

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
pauls313
Prole
Posts: 46
Joined: Tue Aug 02, 2016 3:07 am

Löve for Android runs on a different resolution than the native one

Post by pauls313 » Thu Apr 11, 2019 3:39 am

The phone I'm using is a Galaxy A9 Pro 2016 with a display of 1920x1080, but the Löve app is running on a 731x411 resolution

I've tried using the love.window.setMode and love.conf to no avail, even though setMode returns true. I have no idea why this is happening, considering it used to run just fine on this same phone.

Has anyone else experienced this? Is it a native bug? Is there anything I could do to fix it?

User avatar
pgimeno
Party member
Posts: 1682
Joined: Sun Oct 18, 2015 2:58 pm

Re: Löve for Android runs on a different resolution than the native one

Post by pgimeno » Thu Apr 11, 2019 12:03 pm

This is, unfortunately, not a bug. The coordinates/dimensions are no longer in pixels when highdpi is on, and it's forced to on in Android. Even worse, for some reason, the returned size is rounded, making calculations inaccurate. The real pixel dimensions can be obtained with love.graphics.getPixelDimensions (or ...Width/...Height, see See Also section), and can be converted to coordinates using love.window.fromPixels.

There's been quite some discussion about providing a way to disable this, to no avail, see viewtopic.php?f=4&t=86215.

pauls313
Prole
Posts: 46
Joined: Tue Aug 02, 2016 3:07 am

Re: Löve for Android runs on a different resolution than the native one

Post by pauls313 » Thu Apr 11, 2019 5:52 pm

I'm not sure if I understand?

Using getPixelDimensions I got the actual resolution of my display, but from the looks of it I'm still limited to only 731x411 pixels on the screen (I see some pixel rounding errors). I'm used to making my games adaptive to all screen sizes so making it DPI scalable doesn't help me at all. Reading the linked thread didn't give me any concrete answers and even when rendered to a canvas I'm still limited to a small resolution.

User avatar
pgimeno
Party member
Posts: 1682
Joined: Sun Oct 18, 2015 2:58 pm

Re: Löve for Android runs on a different resolution than the native one

Post by pgimeno » Fri Apr 12, 2019 1:44 am

I think you're confusing coordinates with pixels. You don't only have 731x411 pixels accessible. The maximum coordinates of the screen are 731 point something and 411 point something; you can use love.window.fromPixels(love.graphics.getPixelWidth()) and ...Height()) to find out the exact values, because the numbers returned by getDimensions() are rounded.

That doesn't mean you only have 731 pixels available horizontally; it just means that the coordinates don't match the pixels, but using fractional coordinates you can access all the pixels. For example, to draw a pixel on the bottom right corner of the screen you can use:

Code: Select all

  local fp = love.window.fromPixels
  love.graphics.rectangle("fill", fp(1919), fp(1079), fp(1), fp(1))
As for canvases, they're affected too. For example, if you use the settings version of love.graphics.newCanvas to set the dpiscale value of the canvas to 1, you can specify the width and height directly in pixels.

Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests