Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Detecting a retina display

edited August 2013 in Bugs Posts: 2,820

Hello,
I'm still having lots of bugs in the runtime, and having to hack around them all. :( 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

Comments

  • Posts: 1,595

    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?

  • SimeonSimeon Admin Mod
    Posts: 5,708

    @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
    
  • Posts: 2,820

    @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.

  • Posts: 1,595

    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?

  • Posts: 2,820

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

  • JohnJohn Admin Mod
    Posts: 643

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

  • Posts: 2,820

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

Sign In or Register to comment.