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
EngineerSmith
Prole
Posts: 38
Joined: Thu Dec 02, 2021 11:38 am
Contact:

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 = 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
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: Google [Bot], SelfDotX and 16 guests