Hi, All!

I have a problem with glReadPixels function.
There is an empty result.


My code:
Code :
 
    // initialization
    depthMapFBO = glGenBuffers();
    glBindBuffer(GL_PIXEL_PACK_BUFFER, depthMapFBO);
    glBufferData(GL_PIXEL_PACK_BUFFER, display.getWidth() * display.getHeight() * 4, GL_DYNAMIC_DRAW);
    glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
    ....
 
    // using after moment when scene become rendered
    glBindBuffer(GL_PIXEL_PACK_BUFFER, depthMapFBO);
    ByteBuffer buffer = BufferUtils.createByteBuffer(display.getWidth() * display.getHeight() * 4);
    glReadPixels(0, 0, display.getWidth(), display.getHeight(), GL_DEPTH_COMPONENT, GL_FLOAT, buffer);
    ByteBuffer glMapBuffer = glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_WRITE, buffer); // is not null. it seems buffer initialized ok.
    makeScreenShot(display.getWidth(), display.getHeight(), glMapBuffer);
    glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);


But if I make screenshot like this, all is ok:
Code :
      ByteBuffer buffer = BufferUtils.createByteBuffer(display.getWidth() * display.getHeight() * 4);
      glReadPixels(0, 0, display.getWidth(), display.getHeight(), GL_DEPTH_COMPONENT, GL_FLOAT, buffer);
      makeScreenShot(display.getWidth(), display.getHeight(), buffer);


What is wrong with depthMapFBO's variant?


Thanks for answer!