1

I want to read the depth component of a scene rendered to a framebuffer object. I initially used glReadPixels() but found that it could only read pixels from the default framebuffer.

The answers to some relevant questions on this website suggest using PBO, but I haven't tried it yet. It seems that the PBO reading is asynchronous, therefore, using which command can synchronize the reading at the end?

4

1 回答 1

2

PBO 在这里对您没有帮助,因为它们只是一种不同类型的要读入的缓冲区(而不是主机上的内存到 OpenGL 实现的内存中)。

在 OpenGL 中使深度组件可读的常用方法是使用深度纹理,附加到深度附件,并在渲染后使用glGetTexImage检索日期。

在正常颜色附件的情况下,您可以使用 glReadPixels 和先前调用 glReadBuffer 来选择GL_COLOR_ATTACHMENT<i>绑定的 FBO。

于 2013-09-22T16:05:17.730 回答