Code: Select all
local lg = love.graphics
local w, g = lg.getPixelDimensions()
local depthcanvas = lg.newCanvas(w, h, {format="depth24", readable=true})
lg.setDepthMode("always", true)
love.draw = function()
lg.setCanvas({depthstencil=depthcanvas})
lg.setColor(1,1,1)
lg.rectangle("fill", 50,50,50,50)
--lg.setCanvas()
--lg.draw(depthcanvas) -- Only the depth buffer being drawn to and not the back buffer using the depth buffer
end
Another solution, if possible, is if there's an option to make the back buffer's depth buffer readable (if the system allows) - but I'm unaware of such an option.