I tried to create a shader chaining functionality to my game engine, but I have to render a canvas to itself somehow. I know that I have to use offscreen buffers somehow, but I'm not sure how. Here's what I'm ultimately trying to achieve:
canvas = nil
function love.load()
canvas = love.graphics.newCanvas()
end
function love.draw()
love.graphics.setCanvas(canvas)
-- [set the first shader]
love.graphics.draw(canvas) -- here's where the method fails
-- [set the second shader]
love.graphics.draw(canvas)
-- etc
end
function love.draw()
love.graphics.setCanvas(canvas2)
-- [set the first shader]
love.graphics.draw(canvas)
-- [set the second shader]
love.graphics.setCanvas(canvas)
love.graphics.draw(canvas2)
-- etc
end
function love.draw()
love.graphics.setCanvas(canvas2)
-- [set the first shader]
love.graphics.draw(canvas)
-- [set the second shader]
love.graphics.setCanvas(canvas)
love.graphics.draw(canvas2)
-- etc
end
That's what I tried to do: have two canvases, draw onto the first canvas, swap them (first becomes second and vice versa) using