title: I suspect glReadPixel doesn't return the right depth value. Why?
body: <p>In my program I've loaded a mesh model on my canvas and initially read its depth values with glReadPixels. </p>
  
  <p>This code is written after gl.glFlush() in the display function:</p>
  
  <pre><code>FloatBuffer depth_mann = FloatBuffer.allocate(width*height);
  </code></pre>
  
  <p>...</p>
  
  <pre><code>gl.glPixelStorei(GL2.GL_PACK_ROW_LENGTH, width);
  gl.glPixelTransferf(GL2.GL_DEPTH_SCALE, 1.0f);
  gl.glPixelTransferf(GL2.GL_DEPTH_BIAS, 0.f); 
  gl.glReadPixels(0, 0, width, height, GL2.GL_DEPTH_COMPONENT, GL2.GL_FLOAT, depth_mann); 
  </code></pre>
  
  <p>Later I accessed the depth values to be used in a glUnproject and assign the resulting z-value to a set of vertices, and added with an offset, the vertices will lie on top of the mesh model. Sort of elevated. In other words, I'm trying to come up with an inflation function. However, not all of the vertices are elevated, and after a bit of testing, it turns out that the depth values returned by glReadPixels are not always the same. </p>
  
  <p>Now, I'm trying to figure out what's wrong for four days but I think it's time for some help. I feel like there are things that I should know which I don't know and your help in filling those missing pieces will be appreciated. Thanks in advance! </p>