Detecting a retina display

Hello,
I’m still having lots of bugs in the runtime, and having to hack around them all. :frowning: It’s a serious waste of time. Anyways, a large amount of them are sprites not displaying or being created correctly on the retina displays. Either a sprite was created in the larger version, and not being scaled to the set width and height when I draw the sprite, or it just doesn’t make a larger version and comes out as nil on the retina displays. It’s very confusing when what happens.
Anyways, I can’t find a reliable way to detect a retina display to fix these bugs. If there is, that’d be great.
Thanks!
P.S. No, this is not an iOS 7 only bug

A retina display holds .5 values for the position on the screen as there are twice as many pixels, if you can use that somehow to figure it out?

@Zoyt that is unusual, do you have code that duplicates the issue in Codea? The runtime is identical to the code used in the app version of Codea, so we should be able to recreate the issue there if there are retina-related bugs.

To detect retina display use ContentScaleFactor:

if ContentScaleFactor == 2 then
    -- This is a retina display
else 
    -- This is not a retina display
end

@Simeon - The issue I’m working with right now is actually not a bug. I’m trying to make soft shadows by scaling images, but on retina displays, it creates an image double the size and when I draw into it with setContext and then scale it, it doesn’t blur the same way because the images are twice as large in the retina iPad, so the shadows are half as large. Anyways, I’ll see if I can recreate my other image bugs sometime.
Thanks!
P.S. A great feature would be the ability to have an image not create a retina version.

You can stop an image being retina by toggling off the retina mode when copying images in to your library, is that what you meant?

@Luatee - I’m generating my images through code, so I can’ trust click a box that defines if it’ same retina image.

@Zoyt if you detect retina using @Simeons code just generate a shadow image half the normal resolution. That should give you the same effect.

@John - Thanks. That’ sweat I’ve been doing.