## push - a resolution-handling library

kuzika
Prole
Posts: 16
Joined: Tue Apr 21, 2020 3:58 pm

### Re: push - a resolution-handling library

Ok. That makes sense. Thanks I’ll first remove the translation and see how the camera works. If I get any trouble I’ll start a new thread.
"kuzika" literally means "to burry"
nequals30
Prole
Posts: 9
Joined: Sun Sep 22, 2019 5:54 pm

### Re: push - a resolution-handling library

I've been trying to figure out a major problem I've been having with this library -- when the game dimensions are a different aspect ratio than the screen dimensions, all canvases are drawn shifted relative to what they should be.

After spending a lot of time trying to track it down, I noticed that this only happens when the canvases are drawn in update (it works fine if the canvases are drawn in load).

Here's an example I made which draws a 1280x720 blue rectangle over a 1280x720 game (when the screen is 1500x720).

The conf.lua

Code: Select all

function love.conf(t)
t.window.width = 1500
t.window.height = 720
end

The main.lua:

Code: Select all

push = require("push")

local gameWidth, gameHeight = 1280,720

local windowWidth, windowHeight = love.window.getMode()
push:setupScreen(gameWidth,gameHeight,windowWidth,windowHeight,{fullscreen=false})

function love.update(dt)
thisCanvas = love.graphics.newCanvas(1280,720)
love.graphics.setCanvas(thisCanvas)
love.graphics.clear()

love.graphics.setColor(0,1,1,1)
love.graphics.rectangle('fill',0,0,1280,720)
love.graphics.setColor(1,1,1,1)

love.graphics.setCanvas()
end

function love.draw()
push:start()

love.graphics.rectangle('line',1,1,1280,720)
love.graphics.draw(thisCanvas,0,0)

push:finish()
end


The canvas (blue) appears shifted right relative to where it should be by 110px (which is the same as how much the game is shifted relative to the screen, but this is an extra 110px on top of that).

I don't see the same issue if the code inside of love.update() gets run inside of love.load(). I'm not trying to draw a canvas on every iteration of the game, but occasionally things inside of love.update will trigger new canvases to be drawn.
pgimeno
Party member
Posts: 3375
Joined: Sun Oct 18, 2015 2:58 pm

### Re: push - a resolution-handling library

push is not preserving the user transform. As a workaround, you can use love.graphics.origin() at the beginning of your love.update.

Note you don't need to create a canvas on every update. You can move the creation line to love.load, and leave the rest in love.update.
nequals30
Prole
Posts: 9
Joined: Sun Sep 22, 2019 5:54 pm

### Re: push - a resolution-handling library

love.graphics.origin() worked perfectly! Thanks so much for the help, that issue has been bugging me for ages.

My canvas creation and drawing only gets called once (e.g. when a UI element such as the game map is created), but it happens in love.update() because it might get triggered from there (e.g. loading a game).

Push not preserving the user transform -- is this a bug? It's not the functionality I would have expected. Should I report an issue on the Github? I see this one which might be the same question.
pgimeno
Party member
Posts: 3375
Joined: Sun Oct 18, 2015 2:58 pm

### Re: push - a resolution-handling library

I would call it a bug, but Ulydev might have a different opinion. Best is to report it to the author to at least let him know so he can decide. The issue you linked doesn't seem related.
SoupremeChickn
Prole
Posts: 1
Joined: Wed Mar 15, 2023 2:51 am

### Re: push - a resolution-handling library

Thanks for making this, this is really helpful.
Sometimes my brain just

doesn't
dusoft
Party member
Posts: 270
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

### Re: push - a resolution-handling library

nequals30 wrote: Sat Dec 26, 2020 5:03 pm
My canvas creation and drawing only gets called once (e.g. when a UI element such as the game map is created), but it happens in love.update() because it might get triggered from there (e.g. loading a game).
The point was that love.update() gets called repeatedly and often (dt) and any resource heavy operations (canvas creation, fonts, sounds etc.) should be moved out, e.g. into love.load().
GVovkiv
Party member
Posts: 526
Joined: Fri Jan 15, 2021 7:29 am
Contact:

### Re: push - a resolution-handling library

dusoft wrote: Sat Mar 18, 2023 5:24 pm The point was that love.update() gets called repeatedly and often (dt) and any resource heavy operations (canvas creation, fonts, sounds etc.) should be moved out, e.g. into love.load().
Well, after 3 years finally someone answered!
pgimeno
Party member
Posts: 3375
Joined: Sun Oct 18, 2015 2:58 pm

### Re: push - a resolution-handling library

dusoft
Party member
Posts: 270
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact: