OpenGL ES2.0 glReadPixels() read data from renderbuffer through framebuffer

吃可爱长大的小学妹 提交于 2019-12-04 11:27:45
umlum

You can not glReadPixels() from GL_DEPTH_COMPONENT in OpenGL ES 2.0. Only from the color buffer. See API Reference here.


void glReadPixels(  GLint x,
    GLint y,
    GLsizei width,
    GLsizei height,
    GLenum format,
    GLenum type,
    GLvoid * data);

format
Specifies the format of the pixel data. The following symbolic values are accepted: GL_ALPHA, GL_RGB, and GL_RGBA


Workaround1: If precision is not that important, you can write depth to one of the 8bit color channels instead.

Workaround2: You can write depth into the RGBA channels by packing the float into a vec4: See for example this SO thread.

Workaround3: You can try the OES_depth_texture extension and, if supported, render to a depth texture instead.

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