Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions lib/util.lua
Original file line number Diff line number Diff line change
@@ -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
Expand Down