Problem with glReadPixels() on OS X retina display

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with glReadPixels() on OS X retina display

martinezmj
I am using this line of code as part of a surface "picking" method.  It all works except in one case, OS X using JRE 7 on a retina display:

gl.glReadPixels((int) winX, (int) winY, 1, 1, GL2ES2.GL_DEPTH_COMPONENT, GL.GL_FLOAT, winZ);

Here is a platform breakdown in OS X:
JRE 6 Non-retina = works
JRE 7 Non-retina = works
JRE 6 retina = works
JRE 7 retina = fails

When it fails, it just returns the wrong value in winZ, as if the picking is not intersecting a surface.  The bottom-right quadrant of the projection view returns real data in winZ (although it's not accurate).  The rest of the view just returns 1 (which is what it does when the pick does not intersect with anything).

I've tried things like multiplying winX and winY by 2, but haven't been able to get around this issue.  This obviously has something to do with the pixel doubling of the retina display.  Are there any JOGL settings I can use to toggle this behavior on/off?  Or is there anything I'm missing?

I am testing using JOGL 2.2.4 in OS X 10.9.5.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with glReadPixels() on OS X retina display

martinezmj
This appeared to fix it:
canvas = new GLCanvas(caps);
canvas.setSurfaceScale(new int[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE });
Reply | Threaded
Open this post in threaded view
|

Re: Problem with glReadPixels() on OS X retina display

Sven Gothel
Administrator
On 10/21/2014 08:38 PM, martinezmj [via jogamp] wrote:
> This appeared to fix it:
> canvas = new GLCanvas(caps);
> canvas.setSurfaceScale(new int[] { ScalableSurface.IDENTITY_PIXELSCALE,
> ScalableSurface.IDENTITY_PIXELSCALE });
>

This removes HiDPI ofc.

Otherwise .. simply use getSurface[Width|Height]() which returns pixel units
for ReadPixels.

~Sven




signature.asc (828 bytes) Download Attachment