We are about to switch to a new forum software. Until then we have removed the registration on this forum.
My client has a new Mac that uses the "retina" display. To support this, I added the following line in setup()
:
pixelDensity(displayDensity());
However, my code uses PGraphics objects defined as follows:
layers[0] = createGraphics( width, height);
(and so on for other layers).
I suspect the pixel density is not being inherited by the PGraphics objects in this instance. It's tough for me to debug this as I don't have access to an HD display so I am sending code back and forth to the client. My existing code runs fine on his old Mac (and every machine I have access to) but the layers are displaying at double size on the newer one.
Could someone provide some guidance to using Processing with displays where displayDensity() != 1
?
BTW I tried explicitly using P2D in size()
and createGraphics()
as per a suggestion on another site but he gets an OpenGL error in that case (again, it works fine for me, but then so did my original code).
Answers
On a non-retina display, pixelDensity will be 1. On a retina display, it'll be 2.
I don't have any way to test this, but from the sound of what you are describing, that means PGraphics are coming out twice the size when code runs on a retina display.
So you may just need to test for displayDensity()>1 and then adjust the position/scale of any PGraphics accordingly?