From af1da9c14d45050773b8e04d409e7467a0aeb61e Mon Sep 17 00:00:00 2001 From: SETTORB Date: Wed, 26 Feb 2025 15:26:35 +0100 Subject: [PATCH] tempCanvas size bug fixe --- lib/util.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/util.lua b/lib/util.lua index 9115f04..bca7470 100644 --- a/lib/util.lua +++ b/lib/util.lua @@ -1,12 +1,19 @@ local util = {} local tempCanvas +local lastCanvasWidth, lastCanvasHeight + --TODO: the whole stencil/canvas system should be reviewed since it has been changed in a naive way function util.process(canvas, options) - --TODO: now you cannot draw a canvas to itself - if not tempCanvas then - tempCanvas = love.graphics.newCanvas() + + local canvasWidth, canvasHeight = love.graphics.getDimensions() + + -- If canvas size has changed, recreate tempCanvas + if not tempCanvas or canvasWidth ~= lastCanvasWidth or canvasHeight ~= lastCanvasHeight then + tempCanvas = love.graphics.newCanvas(canvasWidth, canvasHeight) + lastCanvasWidth, lastCanvasHeight = canvasWidth, canvasHeight end + util.drawCanvasToCanvas(canvas, tempCanvas, options) util.drawCanvasToCanvas(tempCanvas, canvas, options) end