How to access depth buffer of a QQuickWindow app?
-
Hi, in a project I need to access the depth buffer of a Qt Quick application. I have read docs of
QQuickRenderControl
andQOpenGLFramebufferObject
.
But I am not sure what is the correct approach to get the depth buffer, or even if possible to achieve with QML.In principle, I'd like to render the whole application to a custom framebuffer with color and depth texture so I could apply some postprocessing to both of the textures after the QML rendering. But I don't have enough Qt/QML knowledge to do that.
QQuickWindow exposes QQuickRenderTarget but QQuickRenderTarget does not expose the underlying depth buffer. So the QQuickRenderControl example does not apply to my use case, I think.
I have also checked the Rendering FBOs example. However, I am not sure if I can include other QML elements in the framebuffer item. I asked chatGPT and it said no.
I also tried to directly access the default framebuffer in a slot connected to
QQuickWindow::afterRendering()
. But OpenGL always returns error code GL_INVALID_ENUM, no matter what parameters I pass the functionglGetFramebufferAttachmentParameteriv
.Any advice will be appreciated! Thanks.