easier way to ignore DPI on android?

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.
User avatar
eouppdru
Prole
Posts: 10
Joined: Tue Feb 20, 2018 3:39 pm

Re: easier way to ignore DPI on android?

Post by eouppdru » Tue Jan 08, 2019 2:47 am

slime wrote:
Tue Jan 08, 2019 1:26 am
So you're hard-coding your render resolution? Documentation about the units of numbers in love.graphics APIs might be a bit lacking right now, and the fact that the dpi scale value is optional instead of required in newCanvas doesn't help this use-case, but that also doesn't seem very flexible in terms of performance across devices. I know some older / low-end phone GPUs really struggle with 1080p.

I don't consider dpiscale=1 to be a hack FWIW, it's the way you set the DPI scale for anything which has a DPI scale (aside from the screen, which is set by the device manufacturer and OS).
in my only publicly released game (mino bueno) there's several different "styles" which have a variety of different resolutions (and aspect ratios) and are self-contained backgrounds with their own scripts and sounds. most of them are around 240p, two of them are 1080p. the bulk of the rendering load is just background textures that fill the screen, though some of the fancy ones have several canvas layers with shaders. my thinking is, devices powerful enough to run the shaders can show a 1080p canvas and have at least a 1080p screen (though I do plan to add a half-res option, whether your device needs it or you just want the battery life.) I also have some games that are pixel art, around 240p, but with variable aspect ratios. the DPI stuff doesn't really help that either.

my main issue is that DPI scaling is a confusing abstraction you can't disable on one platform for some reason (why is it just android, anyway?)
I think a lot of people are going to make games with no use for the feature and not even know they're making a bunch of canvases that are 12x larger for no reason, and it will only show up on the platform that is affected by it most (where texture drawing alone is hard and battery life matters)

I don't consider just {dpiscale=1} to be a hack, but I do consider redefining a game engine function to work around a specific platform ignoring a configuration flag to be a bit of a hack.
PGP: 9D05F9CC4FB3DEA617ADCDDA355A9D99CBE1CC1B

User avatar
slime
Solid Snayke
Posts: 2809
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: easier way to ignore DPI on android?

Post by slime » Tue Jan 08, 2019 3:50 am

eouppdru wrote:
Tue Jan 08, 2019 2:47 am
my main issue is that DPI scaling is a confusing abstraction you can't disable on one platform for some reason (why is it just android, anyway?)
SDL hasn't implemented DPI-scaling emulation on Android yet (whereas it has on iOS and macOS).

When highdpi is disabled, the backbuffer itself (and all units that were in pixels) directly use the DPI-scaled resolution, on platforms that support it. So if it worked on Android, when highdpi is not enabled a 1080p pixel resolution screen with a DPI scale of 2 would use a 960x540 backbuffer, the reported dpi scale would be 1, and that 960x540 resolution is the only resolution that would be exposed.

When you enable highdpi in that situation, nothing in your game should get bigger or smaller or change positions since the units stay the same, it's only the backing pixel dimensions of the framebuffer that change.

In lieu of SDL supporting that itself, I had hoped to get something in LÖVE's source code which would achieve the same effect: https://bitbucket.org/rude/love/issues/ ... n-specific

It didn't make it into LÖVE 11 unfortunately, but I'll still probably implement that feature.

Nelvin
Citizen
Posts: 63
Joined: Mon Sep 12, 2016 7:52 am
Location: Germany

Re: easier way to ignore DPI on android?

Post by Nelvin » Tue Jan 08, 2019 10:04 am

Is there no way to implement (in future Löve version) an option to globally set a DPI scale? That would, IMO, be good enough for those who care - that would include me, as I, in general, like to have control over what my code does as much as possible. That does not mean I don't use and like to benefit from features already implemented, but as a framework that's more on the lower level side of things, it would be great if those are options.

User avatar
slime
Solid Snayke
Posts: 2809
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: easier way to ignore DPI on android?

Post by slime » Tue Jan 08, 2019 12:17 pm

Nelvin wrote:
Tue Jan 08, 2019 10:04 am
Is there no way to implement (in future Löve version) an option to globally set a DPI scale?
Not really for the backbuffer, since on some operating systems it's either off (and behaves as described above, with the OS doing scaling itself) or completely on, with it always using the size and units provided by the OS.

You could render to a canvas you create that has a DPI scale of 1, and just always use that, of course. Maybe it's a good idea to add a function to set the default DPI scale for canvases... or maybe not, since it might end up making things more confusing in real codebases and libraries.

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

Re: easier way to ignore DPI on android?

Post by pgimeno » Tue Jan 08, 2019 2:09 pm

slime wrote:
Tue Jan 08, 2019 1:26 am
What do you use pixel snapping for?
To draw with an integer zoom so that all pixels are the same size.

slime wrote:
Tue Jan 08, 2019 1:26 am
pgimeno wrote:
Mon Jan 07, 2019 4:16 pm
To create canvases with the desired dimensions.
This seems either too vague or an X->Y problem.
[...]
In T2R I use canvases for pixel-perfect collision detection. This usage needs to minimize the size of the canvases, because the amount of data to import back to the CPU and compare is big, so I need them to be 1:1. I also use a canvas for the actual screen, which I stretch by an integral factor. This is working well on all desktops and even on RPi, at many different resolutions, but fails for Android with LÖVE 11, and since I support all versions from 0.9.1, this is being a problem as I need to add several wrappers specific to Android for 11.x.

slime wrote:
Tue Jan 08, 2019 1:26 am
I understand that updating from a codebase that never used the DPI scale factor to LÖVE 11 will probably cause issues.
Even more when you support all of them at the same time.
Thrust II Reloaded - GifLoad for Löve - GSpöt GUI - My NotABug.org repositories - portland (mobile orientation)
The MS-Github repositories I had have been closed after the acquisition announcement and will be removed in the near future.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 73 guests