Page 1 of 1
[Solved] Android would double the size of canvases?
Posted: Tue Dec 20, 2022 8:15 pm
by Bigfoot71
The question may seem weird but basically in one of my projects I create a canvas of 1100x2400, on PC the dimension tells me this size in the console but once on Android I get an error which is:
Code: Select all
Cannot create texture: pixel height of 4800 is too large for this system.
What is the reason for this error (I mean why the value was doubled)?
Knowing that the given value cannot change at any time.
Re: Android would double the size of canvases?
Posted: Tue Dec 20, 2022 8:40 pm
by dusoft
Possibly DPI of mobile screen (240dpi)?
Re: Android would double the size of canvases?
Posted: Tue Dec 20, 2022 9:52 pm
by Bigfoot71
dusoft wrote: ↑Tue Dec 20, 2022 8:40 pm
Possibly DPI of mobile screen (240dpi)?
Indeed I have just noticed it, however the DPI is 320 on my device. I'm looking in the Löve documentation but does anyone have a solution to solve this problem?
Edit: Problem solved by adding the mention
dpiscale = 1 when creating the canvas, like this:
Code: Select all
local canvas = lg.newCanvas(
width, height, { dpiscale = 1 }
)
Thanks for pointing me in the right direction!
Re-edit: I want to clarify for others who would have this problem because I think that now, if the canvas is made to be displayed it is surely not the best idea, you would have to look for another solution, in my particular case that suits me.
Re: [Solved] Android would double the size of canvases?
Posted: Wed Dec 21, 2022 10:40 pm
by zorg
Looking into conf.lua and seeing that that also has a dpiscale setting might illuminate that you can also set dpi scaling on the actual screen/window/backbuffer, whatever you want to call it; it's not just a canvas/texture setting.
Re: Android would double the size of canvases?
Posted: Wed Dec 21, 2022 10:41 pm
by dusoft
Bigfoot71 wrote: ↑Tue Dec 20, 2022 9:52 pm
Thanks for pointing me in the right direction!
Re-edit: I want to clarify for others who would have this problem because I think that now, if the canvas is made to be displayed it is surely not the best idea, you would have to look for another solution, in my particular case that suits me.
Also see this older thread discussing the same issue:
viewtopic.php?t=86215
And this related function:
https://love2d.org/wiki/love.graphics.getDPIScale