Dynamic Scaling and Retina Only

I have been searching the forums and cant find the info im looking for.

I have 2 questions.

  1. To save on resources and space, is it better to just create retina size graphics and scale by 0.5 instead of including 2 copies of every graphic and using dynamic scaling? What are any disadvantages of this, aside from technically more code? I am having a lot of trouble with the iPhone 5 support and dynamic scaling.

  2. If I decided that I ONLY want to support retina devices, how can I accomplish this? Is it in the build.settings file?

Any help is great, thanks! [import]uid: 71971 topic_id: 32124 reply_id: 332124[/import]

Hi there,

On #1, the disadvantage of creating only hi-res graphics is that low-res devices generally have less texture memory, so by forcing them to use a hi-res graphic, you might run out of texture memory more quickly.

Happy to try to help with the dynamic image resolution and/or dynamic content scaling issues you’re having (note that these are two different things). Could you explain in more detail the challenges you’re having? Meantime, if you haven’t come across it already, this is worth reading closely: http://developer.coronalabs.com/content/configuring-projects.

  • Andrew [import]uid: 109711 topic_id: 32124 reply_id: 127989[/import]

Great response aukStudios, I see your replies often in the forums and I appreciate your wisdom and effort in helping out other developers.

@kbeheman,
You could probably find a way to support Retina-only devices by detecting certain hardware unique to them, but I don’t suggest it when there are so many non-Retina (but still widely-used) devices in the marketplace. I suggest you create your apps for at LEAST the iPad 1&2 and iPhone4 upward, basically 640 x 960 up to 1536 x 2048 (iPad3).

Brent
[import]uid: 9747 topic_id: 32124 reply_id: 127994[/import]

@aukStudios basically nailed it.

If I understand correctly, OpenGL, the graphics engine that Corona SDK uses allocates texture memory based on the size of the texture rounded up to the next power of two. For instance:
120x60 graphic ends up using a 128x128 block of texture memory. Ergo, if you have a 2048x1536 background image for instance, that becomes a 2048x2048 block of texture memory. There are 4 color channels per pixel, (Red, Green, Blue and Alpha) so that’s 4 bytes of memory for each pixel in that 2048x2048 block of texture memory or 16Mb of memory to hold that graphic. That same graphic if it’s scaled would be 1024x768 or would take up 1024x1024x4 bytes of memory or 4Mb. Scaled to 512x384 it would be 512x512x4 or 1Mb of memory.

Given older devices like the iPad1 and the 3Gs and tons of android devices may only have 256Mb of memory, you can’t have a lot of those 16Mb textures running around before you run out of memory. Having 1x, @2x, and @4x graphics takes up more storage space, but only having @4x graphics kills memory on older devices. You have to try and strike a balance where possible.

Use JPEGs for non-transparent graphics to keep storage space low (yea, there PNGcrush going on, but I don’t see the gains with JPEGs.). Figure out what graphics will scale up without having to have @4x versions of them: gradients, things with solid areas, etc) and don’t include @4x versions in the bundle for those, resuse graphcis where possible. In other words if you have two graphics that are only different by things on a common background, don’t have two large graphics with the artwork on them, but have a background and then the differences in separate files so that you’re only having to have that large graphic once and then build the different versions with smaller bits. Then you can save enough to let you have the 3 different sizes in the bundle [import]uid: 19626 topic_id: 32124 reply_id: 128007[/import]

Great info! I actually solved the dynamic scaling issue. It was error on my part (I had a type in my config.lua file).

Texture memory is a big deal and based on my project it is best that I continue to use dynamic scaling!

Thanks a lot for the info aukStudios and robmiracle! Very detailed and informative. [import]uid: 71971 topic_id: 32124 reply_id: 128028[/import]

Hi there,

On #1, the disadvantage of creating only hi-res graphics is that low-res devices generally have less texture memory, so by forcing them to use a hi-res graphic, you might run out of texture memory more quickly.

Happy to try to help with the dynamic image resolution and/or dynamic content scaling issues you’re having (note that these are two different things). Could you explain in more detail the challenges you’re having? Meantime, if you haven’t come across it already, this is worth reading closely: http://developer.coronalabs.com/content/configuring-projects.

  • Andrew [import]uid: 109711 topic_id: 32124 reply_id: 127989[/import]

Great response aukStudios, I see your replies often in the forums and I appreciate your wisdom and effort in helping out other developers.

@kbeheman,
You could probably find a way to support Retina-only devices by detecting certain hardware unique to them, but I don’t suggest it when there are so many non-Retina (but still widely-used) devices in the marketplace. I suggest you create your apps for at LEAST the iPad 1&2 and iPhone4 upward, basically 640 x 960 up to 1536 x 2048 (iPad3).

Brent
[import]uid: 9747 topic_id: 32124 reply_id: 127994[/import]

@aukStudios basically nailed it.

If I understand correctly, OpenGL, the graphics engine that Corona SDK uses allocates texture memory based on the size of the texture rounded up to the next power of two. For instance:
120x60 graphic ends up using a 128x128 block of texture memory. Ergo, if you have a 2048x1536 background image for instance, that becomes a 2048x2048 block of texture memory. There are 4 color channels per pixel, (Red, Green, Blue and Alpha) so that’s 4 bytes of memory for each pixel in that 2048x2048 block of texture memory or 16Mb of memory to hold that graphic. That same graphic if it’s scaled would be 1024x768 or would take up 1024x1024x4 bytes of memory or 4Mb. Scaled to 512x384 it would be 512x512x4 or 1Mb of memory.

Given older devices like the iPad1 and the 3Gs and tons of android devices may only have 256Mb of memory, you can’t have a lot of those 16Mb textures running around before you run out of memory. Having 1x, @2x, and @4x graphics takes up more storage space, but only having @4x graphics kills memory on older devices. You have to try and strike a balance where possible.

Use JPEGs for non-transparent graphics to keep storage space low (yea, there PNGcrush going on, but I don’t see the gains with JPEGs.). Figure out what graphics will scale up without having to have @4x versions of them: gradients, things with solid areas, etc) and don’t include @4x versions in the bundle for those, resuse graphcis where possible. In other words if you have two graphics that are only different by things on a common background, don’t have two large graphics with the artwork on them, but have a background and then the differences in separate files so that you’re only having to have that large graphic once and then build the different versions with smaller bits. Then you can save enough to let you have the 3 different sizes in the bundle [import]uid: 19626 topic_id: 32124 reply_id: 128007[/import]

Great info! I actually solved the dynamic scaling issue. It was error on my part (I had a type in my config.lua file).

Texture memory is a big deal and based on my project it is best that I continue to use dynamic scaling!

Thanks a lot for the info aukStudios and robmiracle! Very detailed and informative. [import]uid: 71971 topic_id: 32124 reply_id: 128028[/import]