简体   繁体   English

glReadPixels(Depth_Component) 在 Android OpenGL ES20 中不起作用

[英]glReadPixels(Depth_Component) not working in Android OpenGL ES20

I use the following code to retrieve the depth buffer:我使用以下代码来检索深度缓冲区:

FloatBuffer pixels = ByteBuffer
    .allocateDirect(4).order(ByteOrder.nativeOrder()).asFloatBuffer();

GLES20.glReadPixels(pointx, pointy, 1, 1, 
    GLES20.GL_DEPTH_COMPONENT16, GLES20.GL_FLOAT, pixels);

Problem is, whichever point I am requesting, the pixels is giving me 0.0;问题是,无论我要求哪一点,像素都给我 0.0;

I have enabled the following in onSurfaceCreated :我在onSurfaceCreated中启用了以下功能:

GLES20.glEnable(GLES20.GL_DEPTH_TEST);
GLES20.glEnable(GLES20.GL_BLEND);
GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
GLES20.glDepthFunc(GLES20.GL_LEQUAL);
GLES20.glDepthMask(true);
GLES20.glClearColor(1, 1, 1, 1);

I've been struggling with this issue for days.这几天我一直在为这个问题苦苦挣扎。 Please help.请帮忙。

According to the OpenGL ES 2.0 docs, glReadPixels() doesn't support reading the depth buffer.根据OpenGL ES 2.0文档, glReadPixels()不支持读取深度缓冲区。 What does glGetError() return? glGetError()返回什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM