If you use google to try and find out how to read the depth (z) buffer in openGLES2/3 you'll find lots of articles that say "You can't do it, it's not supported".
Looking at the extensions that are supported on the Pi's GLES3 I saw "GL_NV_read_depth"
This took me to https://www.khronos.org/registry/OpenGL ... tencil.txt where it says you CAN read the depth buffer.
So I tried it, and lo and behold you can read the depth buffer with glReadPixels. Luckily my Intel desktop machine supports the same extension.
Has anyone else used this extension ?
My "test jig" shows that calling "glReadPixels(x,y,1,1,GL_DEPTH_COMPONENT,GL_UNSIGNED_SHORT,&depth);" is returning something to do with the depth but I'm not sure how exactly to interpret the returned value. The background returns -1 and I'm getting values between -3000 and -4000 for rendered objects in my scene.
Does anyone know how to convert the values into "world z" coordinates ?
PS: It's possible that I've got the type/size of the returned values wrong !