Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canvas Transformations not Preserved when Drawn in Update() #39

Open
nequals30 opened this issue Dec 27, 2020 · 0 comments
Open

Canvas Transformations not Preserved when Drawn in Update() #39

nequals30 opened this issue Dec 27, 2020 · 0 comments

Comments

@nequals30
Copy link

When the game dimensions are a different aspect ratio than the screen dimensions, all canvases are drawn shifted relative to what they should be. It was an issue that was bugging me for a while, and pgimeno on the love2d forums helped me resolve it.

This only happens when the canvases are drawn in love.update (it works fine if the canvases are drawn in love.load).

pgimeno helped me resolve the issue by adding love.graphics.origin() before i draw the canvas. This resolves the issue, but the behaviour is still not what I'dve expect, so it might be considered a bug.

Example:

This should a 1280x720 blue rectangle over a 1280x720 game (when the screen is 1500x720):

The conf.lua

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

The main.lua:

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant