push - a resolution-handling library

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
kuzika
Prole
Posts: 15
Joined: Tue Apr 21, 2020 3:58 pm

Re: push - a resolution-handling library

Post by kuzika » Thu Apr 30, 2020 10:28 am

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

Post by nequals30 » Sat Dec 26, 2020 3:51 am

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.

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

Re: push - a resolution-handling library

Post by pgimeno » Sat Dec 26, 2020 12:26 pm

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

Post by nequals30 » Sat Dec 26, 2020 5:03 pm

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.

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

Re: push - a resolution-handling library

Post by pgimeno » Sat Dec 26, 2020 10:53 pm

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 39 guests