I have drawn a specific scene using from a specific point of view (using view and projection matrices). I used VBOs of triangles and so one. I can get the RGB of the image using:
data = glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE)
data = np.frombuffer(data, dtype=np.uint8).reshape(width, height, 3)[::-1]
cv2.imwrite(r"c:\temp\image1.png", data)
But getting the depth map gets some strange result that consists mostly of 255:
data2 = glReadPixels(0, 0, width, height, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE)
data2 = np.frombuffer(data2, dtype=np.uint8).reshape(width, height)[::-1]
cv2.imwrite(r"c:\temp\image2.png", data2)
I tried replacing GL_UNSIGNED_BYTE
-> GL_FLOAT
and uint8
-> float32
But that didn't help