Re: Exceedingly expensive glReadPixels operation on Mac
Posted by karelknoes on May 08, 2012; 9:30am
URL: https://forum.jogamp.org/Exceedingly-expensive-glReadPixels-operation-on-Mac-tp3968736p3970839.html
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);