Copying depth render buffer to the depth buffer

核能气质少年 提交于 2020-01-04 06:19:06

问题


Currently I am rendering some stuff to a FBO with an attached depth render buffer.

However, after I am done with the render buffer, the depth information is pretty much lost.

How can I copy the data from the render buffer to the fixed function depth buffer?


回答1:


You can use glBlitFramebuffer, enabling the GL_DEPTH_BUFFER_BIT flag.

Example code:

glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo_id);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);

glBlitFramebuffer(offset_x, offset_y, offset_x + size_x, offset_y + size_y,
                  offset_x, offset_y, offset_x + size_x, offset_y + size_y,
                  GL_DEPTH_BUFFER_BIT,
                  GL_NEAREST);

This will copy only the depth buffer.



来源:https://stackoverflow.com/questions/11315534/copying-depth-render-buffer-to-the-depth-buffer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!