Does Orx support @2x naming convention for iOS?

edited January 2012 in Help request
The Retinal displays on the 4th generation iOS device series requires high resolution graphics for the best quality.

Apple supports placing two images with the same base filename in the Xcode project, one high-res, one low-res. For example:

[email protected]

And the correct file is automatically loaded by the iOS device on program launch.

Is Orx compatible with this? In other words, is it enough to have one Orx config file and just supply two images in the Xcode project as described above?



  • edited January 2012
    It currently won't work, simply because I'm bypassing the cached loading method of UIImage and load the data manually. It's easy enough to fix though, I'll try to do that tonight.

    So far I'm uding high def images for both retina and non-retina displays. The scaling down didn't show any visible artifacts in my cases but I guess that depends on what's in your bitmap. :)
  • edited January 2012
    Hmm, so what method do you use to tell Orx to scale down?

    I'm using this tutorial to work in landscape mode:

    I positioned our bitmaps and scaled text graphics so that everything looks correct on my iPod Touch 4 and on my partner's iPhone 4.

    But on my other partner's iPhone 3GS everything is 2x too large..this is also how it looks on iPhone Simulator unless I change Hardware to "Retina" mode. Then everything is correct.
  • edited January 2012
    First of all, are you using the SVN version or the 1.3rc0? I'm asking as retina support was fixed after the 1.3rc0 release.

    As for scaling down, orx works in a resolution independent way, which is a great strength when one want to support multiple resolutions or even different aspect ratios (especially for UI items or any camera relative positioning).

    Can you tell me what you have for your viewport/camera settings?

    Let's say your primary targeted resolution is 640x960 (to match the iPhone retina in portrait mode).
    First you need to define all your assets with that size in mind and then set your camera frustum to have a width of 640 and a height of 960.
    That means that the camera will "see" 640x960 pixels of your world, wherever it's placed. So an object of size 640x480 will exactly occupy half of the camera's "view" (horizontally).

    Now your camera is linked to a viewport, which size by default matches the display size (always fullscreen on iOS).

    So on a retina iPhone, the display size will be 640x960 which means there won't be any up or down scaling as that matches exactly the camera's frustum.

    On a non-retina iPhone, the display size will be 320x480, which means orx will downscale everything to fit the 640x960 seen by the camera into the 320x480 pixels of the viewports. Actually it'll scale all the rendering by 0.5 on both axes.

    If you want a landscape rendering, you simply need to rotate your game by 90°.

    Be careful to harcode the camera frustum with fixed values. If you do something like:
    FrustumWidth = @Display.ScreenWidth
    FrustumHeight = @Display.ScreenHeight

    The camera will not see the same amount of world space depending on the screen size, ie. on retina display it'll see much more world space than on a non-retina display.

    Let me know if this helps.
  • edited January 2012
    LoL, I see you guessed exactly what I was doing and replied as I'm typing this. Noob error.

    I was having my Camera inherit its dimensions from the display, like so:
    FrustumWidth  = @Display.ScreenWidth
    FrustumHeight = @Display.ScreenHeight

    The problem is Display.ScreenWidth and Display.ScreenHeight are different between the two devices (480x320 or 960x640), so you end up with two different Camera dimensions.

    If I make sure the .ScreenWidth and .ScreenHeight values stay consistent between devices, there is no positioning problem.


    Thanks again.
  • edited January 2012
    Also, that's a great practical example of the display/Viewport/Camera relationship and would also be good in the iPhone Wiki section.
  • edited January 2012
    Yep, I realize the concept of camera/viewport isn't that trivial, especially for people coming with a strictly 2D-oriented background.

    A wiki section about that would be great but I don't know when I'll be able to write one. Don't hesitate to do it yourself if you feel like it though. :)

    Also, I'm glad that fixed your issue. I'll still add support for the @2x, but downscaling should give acceptable visual results till then. :)
  • edited January 2012
    Ok, I tried to add the support of @2x, ~iphone and such, but the only way to do it is to use the API that keeps all the images in cache. Which is definitely not something I want to happen for orx by default.

    Another option would be to try manually adding the different extensions and loading the correct image, but I'm not satisfied with it either. I'm not even sure everything would work smoothly as OpenGL doesn't care of the scale property of the images and I'd have to rescale everything manually at some point. For now I suggest simply using hi-rez all the time and if this brings artifacts on low-rez devices, we'll define a battle plan. :)
  • edited January 2012
    Great, thank you. I'll just use hi-res images everywhere for now. We'll be testing on at least iPhone 4, iPod Touch 4, iPhone 3GS, iPhone 2G, so I'll let you know about the image quality.

    If there's any trouble, I don't think it would be a big problem to load different images for the low res device at run-time for the short term.

    iOS exact device detection code

    Does device have Retina display
  • edited January 2012
    Thanks for the link for the exact iOS detection code, btw. As for the retina, that's already how we detect it in the iOS display plugin.
Sign In or Register to comment.