Using iPhone 4 Retina Display - Higher Res Art
by John Sear · in iTorque 2D · 07/05/2010 (2:26 am) · 22 replies
I'm just curious as to how compatible iTorque is with the new Retina Display on iPhone 4?
Is it just a case of double sized artwork and the @2x in the filename?
Will text work at a double sized font automatically?
I've only skimmed over the documentation on Apple Dev Center and it all seems quite simple. Has anyone done anything with the Retina Display?
Thanks,
John.
Is it just a case of double sized artwork and the @2x in the filename?
Will text work at a double sized font automatically?
I've only skimmed over the documentation on Apple Dev Center and it all seems quite simple. Has anyone done anything with the Retina Display?
Thanks,
John.
About the author
Recent Threads
#2
Thanks, will have to try another way to impress Apple with the latest game so that we have the best chance of being featured!
07/05/2010 (4:59 am)
Ahh right, so I guess it's not really do-able or worth it.Thanks, will have to try another way to impress Apple with the latest game so that we have the best chance of being featured!
#3
09/01/2010 (10:01 pm)
Anyone managed to get 1.4 (or 1.3.1) to auto detect the retina display and load the large art work, bigger fonts sizes?
#4
09/02/2010 (10:14 pm)
Nobody? More important now that we have that nice shiny high-res iPod Touch to support as well ;-)
#5
it only has knowledge of 480x320 and 1024x768 (ipad)
09/02/2010 (10:34 pm)
unless you integrated a 3rd mode (or kicked them for proper window bounds based size), iT2D does not even know it exists.it only has knowledge of 480x320 and 1024x768 (ipad)
#6
09/03/2010 (10:17 am)
Thanks Marc, I was thinking of "replicating" the iPad code and allow for the additional resolution.
#7
Did you every try getting the retina display working? I am working on getting iPad and iPhone4 support for War Evolved, and I am having trouble with the retina display.
I am setting the resolution to 960 by 640 similar to how I set the iPad resolution, but when I run the game it looks like it is only showing the bottom left of the corner.

The iPad image is what I expect, I didn't change the locations of the GUI objects so that is why they appear in the top left. However, the iPhone4 doesn't act the same way the iPad does. If I change the GUI extents back to "480 320" then it works fine, but I'm not using the retina resolution.
If I get this working I'll gladly post code on how I did it (although I'm still using iTGB 1.2 as the base, so it may be a little different).
10/16/2010 (12:26 am)
@Scott,Did you every try getting the retina display working? I am working on getting iPad and iPhone4 support for War Evolved, and I am having trouble with the retina display.
I am setting the resolution to 960 by 640 similar to how I set the iPad resolution, but when I run the game it looks like it is only showing the bottom left of the corner.

The iPad image is what I expect, I didn't change the locations of the GUI objects so that is why they appear in the top left. However, the iPhone4 doesn't act the same way the iPad does. If I change the GUI extents back to "480 320" then it works fine, but I'm not using the retina resolution.
If I get this working I'll gladly post code on how I did it (although I'm still using iTGB 1.2 as the base, so it may be a little different).
#8
10/17/2010 (2:25 am)
The problem there is that it takes the resolution and does a scale up as you likely didn't extend iTGBs code to use the contentScale factor correspondingly. as such the rendered screen is considered "normal iphone" and then gets blown up by a factor of 2, thats exactly what you see there.
#9
Awesome, you were right. The retina display works!
For anybody else interested, I added the following line to iPhoneWindow.mm:
I added this right after glView was initialized,
For me this was on line 198 within Platform::initWindow.
I'm now unable to click on any buttons, but I'll look into that tomorrow. If the problem isn't something related to the code that I added then I'll post a solution as soon as I find it.
10/17/2010 (4:50 am)
Marc,Awesome, you were right. The retina display works!
For anybody else interested, I added the following line to iPhoneWindow.mm:
glView.contentScaleFactor = [[UIScreen mainScreen] scale];
I added this right after glView was initialized,
glView = [[iPhoneOGLVideo alloc] initWithFrame: rect];
For me this was on line 198 within Platform::initWindow.
I'm now unable to click on any buttons, but I'll look into that tomorrow. If the problem isn't something related to the code that I added then I'll post a solution as soon as I find it.
#10
Next on the list is retina but this will be version 3.1. Looking forward to confirmation of how straightforward it is though :)
10/17/2010 (9:21 am)
Justin, still on my list of things to do - I am almost finished the iPad version of IWT. It took long than expected because of screen coordinates, velocities etc. I also reworked a number of the effects, we updated skylines etc etcNext on the list is retina but this will be version 3.1. Looking forward to confirmation of how straightforward it is though :)
#11
The code that I am checking this against is:
These touches aren't even getting to iTGB yet. I have gotten the touches to work with the following:
But this seems like a really bad way to handle it. I have outputted the UIView size that locationInView is hitting against, and that is the correct size. I have also set the main UIWindow to the correct size.
I am still playing with it, but I wanted to give a quick update in case anybody had any ideas.
10/17/2010 (6:59 pm)
Well I am a little bit further. I am looking in iPhoneOGLVideo.mm and the touches began/move/end events only have the touches in the range of (0-480) for x and (320-640) for y (keep in mind this is the horizontal aspect). I am not sure why the touches are not responding to the full width and height.The code that I am checking this against is:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSUInteger touchCount = [activeTouches count];
// Enumerates through all touch objects
for (UITouch *touch in touches){
CGPoint point = [touch locationInView:touch.view];
NSLog(@"TouchBegan %f %f",point.x,point.y);
....These touches aren't even getting to iTGB yet. I have gotten the touches to work with the following:
for (UITouch *touch in touches){
CGPoint point = [touch locationInView:touch.view];
if([[UIScreen mainScreen] scale] == 2){
point.x *= 2;
point.y = (point.y-320) * 2;
}But this seems like a really bad way to handle it. I have outputted the UIView size that locationInView is hitting against, and that is the correct size. I have also set the main UIWindow to the correct size.
I am still playing with it, but I wanted to give a quick update in case anybody had any ideas.
#12
10/17/2010 (9:01 pm)
Unless your project is iOS4+ only, that fix won't be enough actually. And it will get rejected cause contentScale is not present on iOS 3
#13
It's slightly dirty, as it directly checks for iPad. But this is usable code for properly detecting stuff, until Apple shows us a better way. I guess we could consider "iPad" a capability :)
(All credit goes to some Cocos2D poster)
That code handles detection, and should only be used once. Set a flag, test for that wherever dimensions affect operation, or in a customised image loading routine. UIImage (in some cases, not all) will load imagename@2x.extension. Cocos2D uses the simpler imagename-hd.extension pattern. There were some technical reasons for this, so perhaps you should avoid the @2x naming scheme.
10/22/2010 (2:45 pm)
Code you could use somewhere in initialisation:// Ask if this iOS version has the scale method
if([[UIScreen mainScreen] respondsToSelector:NSSelectorFromString(@"scale")])
{
if ([[UIScreen mainScreen] scale] == 1.0)
{
// Old devices - don't scale
}
if ([[UIScreen mainScreen] scale] == 2.0)
{
if([[[UIDevice currentDevice] model] compare:@"iPad"] == NSOrderedSame)
{
// iPad - do whatever special stuff needed here - all the Retina stuff minus scaling, or
// unique graphics?
} else {
// Sweet hardware! Flag for hires graphics and enlarged fonts
}
}
}It's slightly dirty, as it directly checks for iPad. But this is usable code for properly detecting stuff, until Apple shows us a better way. I guess we could consider "iPad" a capability :)
(All credit goes to some Cocos2D poster)
That code handles detection, and should only be used once. Set a flag, test for that wherever dimensions affect operation, or in a customised image loading routine. UIImage (in some cases, not all) will load imagename@2x.extension. Cocos2D uses the simpler imagename-hd.extension pattern. There were some technical reasons for this, so perhaps you should avoid the @2x naming scheme.
#14
But good code there :)
Actually this one could be used to set up iTGB before its starting for universal binary (and is what I hoped 1.4 to use instead of using 2 defines to just ignore and workaround one of iTGBs larger problems again)
10/23/2010 (7:46 am)
"sweet hardware" hehe ... the iPhone 4 is weaker in every aspect than the iPad aside of RAM ;)But good code there :)
Actually this one could be used to set up iTGB before its starting for universal binary (and is what I hoped 1.4 to use instead of using 2 defines to just ignore and workaround one of iTGBs larger problems again)
#15
People from MGT have been reporting issues with the iPad, but since the devices aren't officially sold in my country I haven't seen what the difference is. Something is up with the speed on iPad, which doesn't affect the 4th generation handhelds! (Rumours about iOS 4.2 making all well again are semi-confirmed in various other forums…)
10/23/2010 (11:32 am)
I have only iPod touches, and they're performing pretty well for me ;)People from MGT have been reporting issues with the iPad, but since the devices aren't officially sold in my country I haven't seen what the difference is. Something is up with the speed on iPad, which doesn't affect the 4th generation handhelds! (Rumours about iOS 4.2 making all well again are semi-confirmed in various other forums…)
#16
If it is possible, I am wondering if there are performance implication.
11/09/2010 (9:56 pm)
According to Ronny code you should have different images for different devices, so 480 for iphone/ipod and 960 for iphone4. Is there any way we could just use 960 (even for not 4G)? Doubling the arts will make the game much bigger in size.If it is possible, I am wondering if there are performance implication.
#17
Another option is to make hi-res data an in-app downloadable option. I would think this is a decent solution for larger games which might be pushing the 20MB limit already.
Thank goodness there isn't surround hardware with the latest updates so we had to upgrade the sounds too ;)
11/09/2010 (10:40 pm)
Yes, scaling down is a possibility. I haven't tested how this would perform, but if it only happens at load time it shouldn't bee too drastic, especially with per-level asset loading.Another option is to make hi-res data an in-app downloadable option. I would think this is a decent solution for larger games which might be pushing the 20MB limit already.
Thank goodness there isn't surround hardware with the latest updates so we had to upgrade the sounds too ;)
#18
11/10/2010 (12:12 am)
even if there were you wouldn't upgrade would you. cause the speakers suck that badly that sound is always opted for headphones ;) (ok going by tests even that sucks quality wise, the itouch / iphone have horrible sound hardware and don't qualify for their mp3 player name anymore at all)
#19
11/10/2010 (8:51 am)
You think the sound quality is bad? I use Sony Studio monitor headphones and I think the sound is pretty good. The frequency response is not as good as CD quality, which is essentially as good as analog audio (which cannot be improved upon), but MP3 will never sound perfect because of the data compression, until we get to the point where digital surpasses analog, like we now have with images and with video. You never get something for nothing, so if you compress the audio data it cannot possibly sound as good, at least for now until the audio compression techniques improve. The same applies to every MP3 player. It's all about the level of compression and the current technology, which will improve over time. Right now, I have not heard a better MP3 player than the iPod.
#20
(Oh, and my music is lossless CD rips for the most part!)
@Marc: It doesn't matter what we, the people who actually pay attention, do. People would DEMAND surround games if that was an option :P
(P.S.:Wooosh.)
11/10/2010 (4:42 pm)
I use Sennheisers. No problems with sound here :)(Oh, and my music is lossless CD rips for the most part!)
@Marc: It doesn't matter what we, the people who actually pay attention, do. People would DEMAND surround games if that was an option :P
(P.S.:Wooosh.)
Torque 3D Owner Marc Dreamora Schaerer
Gayasoft
So if you want double the font size you must generate a font for that doubled size / double sized images.
the @2x stuff is for UIKit driven things only, not for "all in OpenGL ES" applications to my understanding. (and you wouldn't want it as having larger assets for all stuff could become a problem, cause on iphone 4 / ipad you must keep an eye on all alpha blending or your game will just stop to run playable on these oversized devices with their 3GS gpu