|
A work around I discoved: first store the depth information as a texture and then read out the texture.
FloatBuffer pickingZBuffer = Buffers.newDirectFloatBuffer(canvasWidth * canvasHeight);
int depthTexture = 0;
gl.glBindTexture(GL2.GL_TEXTURE_2D, depthTexture);
gl.glTexImage2D(GL2.GL_TEXTURE_2D, 0, GL2.GL_DEPTH_COMPONENT, canvasWidth, canvasHeight, 0,
GL2.GL_DEPTH_COMPONENT, GL2.GL_FLOAT, null);
gl.glCopyTexSubImage2D(GL2.GL_TEXTURE_2D, 0, 0, 0, 0, 0, canvasWidth, canvasHeight);
gl.glGetTexImage(GL2.GL_TEXTURE_2D, 0, GL2.GL_DEPTH_COMPONENT, GL2.GL_FLOAT, pickingZBuffer);
|