How to give the back buffer a depth buffer without using conf

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Posts: 38
Joined: Thu Dec 02, 2021 11:38 am

How to give the back buffer a depth buffer without using conf

Post by EngineerSmith »

Is there a way to give the back buffer (default canvas) a depth buffer without using conf? I tried the following, but it doesn't work.

Code: Select all

local lg =
local w, g = lg.getPixelDimensions()
local depthcanvas = lg.newCanvas(w, h, {format="depth24", readable=true})
lg.setDepthMode("always", true)
love.draw = function()
  lg.rectangle("fill", 50,50,50,50)
  --lg.draw(depthcanvas) -- Only the depth buffer being drawn to and not the back buffer using the depth buffer
Context: Why do I want this behaviour? I want to have a setting to switch between post processing and not for my 3D game. The easy solution is to always have the back buffer have a depth buffer, but that feels wasteful as it isn't readable for post processing - requiring additional buffers for post processing as they won't be able to use the back buffer's depth buffer.
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.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 13 guests