如何从Z缓冲区获取Z值 [英] How to get Z values from Z Buffer
本文介绍了如何从Z缓冲区获取Z值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在OpenGL中绘制时遇到问题,我需要确切地查看在深度缓冲区中放置了什么值.谁能告诉我如何检索这些值? 谢谢 克里斯
I'm having problems with drawing in OpenGL and I need to see exactly what values are being placed in the depth buffer. Can anyone tell me how to retrieve these values? Thanks Chris
推荐答案
使用 glReadPixels ,格式为GL_DEPTH_COMPONENT,例如:
Use glReadPixels with format = GL_DEPTH_COMPONENT, for example:
float depth;
glReadPixels(0, 0, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
将获得像素的深度(0,0).
Will get the depth of pixel (0, 0).
这篇关于如何从Z缓冲区获取Z值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文