glReadPixels

Hardware Platform: DRIVE AGX Pegasus™ Developer Kit
Software Version: DRIVE Software 10
Host Machine Version: native Ubuntu 18.04
SDK Manager Version: 1.4.0.7363

Currently using glReadPixels to get GL_DEPTH_COMPONENT for further processing.

Although glReadPixels works on the host Ubuntu PC (i.e. it results in sensible values of depth: 0.0 < depth < 1.0), it does not work on the target Pegasus platform.

Simple reproduction:

  1. Insert the following into render_engine/main.cpp after dwRenderEngine_screenToWorld3D (around line 229):
    GLfloat depth = 0;
    glReadPixels(screenPos.x, screenPos.y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
    std::cout << "glReadPixels depth: " << depth << std::endl;
  1. Build and run sample_render_engine.

  2. Press F2 to show the large static point cloud, and F1 to remove the help tile.

  3. Click on the point cloud, and off the point cloud.

Behaviour on Linux host PC:

  • The depth values when clicked on the point cloud are non-zero, e.g. 0.998279
  • The depth values when clicked outside the point cloud is 1.
  • This is the correct behaviour.

Behaviour on Pegasus target:

  • The depth values are always zero.
  • This is the wrong behaviour.

This post is related to this: screenToWorld3D

Hi @gpu_power,

I think it’s because GL_DEPTH_COMPONENT isn’t supported in OpenGLES.
Please refer to glReadPixels() document in OpenGL ES 2.0 Reference Pages.