[Solved] Android would double the size of canvases?

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
User avatar
Bigfoot71
Party member
Posts: 287
Joined: Fri Mar 11, 2022 11:07 am

[Solved] Android would double the size of canvases?

Post 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.
Last edited by Bigfoot71 on Tue Dec 20, 2022 10:22 pm, edited 1 time in total.
My avatar code for the curious :D V1, V2, V3.
User avatar
dusoft
Party member
Posts: 715
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: Android would double the size of canvases?

Post by dusoft »

Possibly DPI of mobile screen (240dpi)?
User avatar
Bigfoot71
Party member
Posts: 287
Joined: Fri Mar 11, 2022 11:07 am

Re: Android would double the size of canvases?

Post 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.
My avatar code for the curious :D V1, V2, V3.
User avatar
zorg
Party member
Posts: 3470
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: [Solved] Android would double the size of canvases?

Post 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.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
dusoft
Party member
Posts: 715
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: Android would double the size of canvases?

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

Who is online

Users browsing this forum: Google [Bot], Semrush [Bot] and 6 guests