iPhone & iPad: Is an OpenGL ES Universal App a pain to write for multiple devices? - iphone

I've had experience writing a cocoa touch app as a universal app (for ipad, iphone) and it wasn't too hard. I only needed to use different .xib for each device but atleast it was the same binary.
Is it possible to have a universal opengl es app as well? Is it difficult given I have to have the resolution different for each devices (iphone 3gs, iphone 4, ipad)? So most probably my code would be different for each device???

While difficulty is a subjective measure, I would argue that it is a simpler process to develop an OpenGL-ES-centric application for the various devices than one based on more standard user interface elements. Where an iPad version of a standard iPhone application may require a completely different interface layout, if you are doing fullscreen OpenGL ES drawing, you just simply need to have the rendering layer scale to the appropriate screen size.
For example, take a look at the code to my Molecules application (it's available under a BSD license). It is a universal iPhone / iPad application and shares a lot of code between the two interfaces. In fact, almost none of the OpenGL ES portion changes based on the platform.
When it comes to something like the Retina displays, you just need to add one little bit of code in your CAEAGLLayer-hosting view's initialization to account for the new scale factor:
if ([self respondsToSelector:#selector(setContentScaleFactor:)])
{
self.contentScaleFactor = [[UIScreen mainScreen] scale];
}
Nothing else needs to change, and your OpenGL ES content will now render at the higher resolution.
Probably the biggest issue you will encounter is that by going to the higher-resolution displays you may find yourself being fill rate limited where you weren't before on the older iPhones. If you see the Renderer Utilization getting near 100% in the OpenGL ES instrument, that's what is happening. For the Retina displays, you may then want to not render at the full 2X scale factor, but something a little lower.

I can't speak to your particulars, but I have a universal app and it uses OpenGL-ES. For my purposes, glViewport() call takes care of things.

Related

Can I scale my iPAD app to fit on a iphone automatically

I have an iPad application built in objective-c i wanted to know if there were any tricks with UIWindow to scale the app to run on an iphone in landscope mode. So that all my assumptions of the frames being ipad size would be ok but it would fit on an iphone. Just to carry around pocket demos etc. I realize things would be hard to press.
No, you have it backwards: apps made for the phone can run on the ipad unaltered in either 2x mode (stretched) or in a letterbox.

Graphics on iPhone Application

I have a graphic designer who is doing some graphics for my iPhone app. Most recently she made me a background pattern and posed me two questions that I'm unsure of how to answer:
1) What should the size of the background pattern be?
-For this I know that when I'm programming my app,the screen is in terms of 320 by 480 (when in portrait mode), however is this the appropriate unit that I should give her (I'm only worried about iPhone 4 and below for now)? Like for instance, I know there is a retina display and I've seen the phone resolution of my phone also be listed as 640 x 960. I'm just confused of what the best thing to tell her regarding this is, she does not have any iPhone experience and will be using the traditional graphic programs like illustrator, photo shop etc to do the graphic design.
2) What file type should it be?
-I've read the iPhone supports mostly all of the most popular graphic file types, but is there anyone particular that would work best on an iPhone app?
The standard for iPhone resource images is PNG. If you want to target iPhone 4+ with retina display, have the designer provide two versions of the PNG: A standard version and a double-sized version which should have #2x appended after the filename, but before the extension.
So
image.png
for regular resolution and
image#2x.png
for retina resolution. iOS will automatically pick the best one to use based on the screen available.

Ipod application compatibility

Is any iphone application can run into ipod with proper screen resolution?
I am little bit confuse among designing that if i make an application for iPhone and iPod so should i need to design different screen for both.
The iPod and iPhone currently have the same size screen. As other commenters noted, there are differing models between retina and non-retina which have different resolution, so you will have provide #2x and normal size graphics for them.
However, the iPad has vastly different screen size and resolution. If you only write for the iPhone/iPod, you can run on the iPad too but it will only use a small portion of the screen.
No, it is basically the same. However, you need to take care of the device capabilities, e.g. the iPod has no phone functionality (if you intend to make use of it).
At the moment the iPod touch and the iPhone have the same screen size. They may have different resolutions, but the screen size is the same and apart from providing image assets at different sizes there should be no issues.

iPhone VS ipad development process (differences and similarities)

I am new to iOS development. I am trying to figure out these things.
A project both in iPhone and iPad. what things are same for both (coding, graphics or UI)?
Design Pattern of apps are same or different?
waiting for answer
Thanks :)
Personally, I find that the only real difference between the iPhone and the iPad is the UI and UX. Most of the code is the same for both applications. (In fact, you can even reuse a lot of code if you are doing a universal app!)
The main difference really is the screen size. The iPad is huge in comparison to the iPhone, and this difference gives you a lot more options to work with.
Another thing to note is that the iPad is usually done in landscape orientation, whereas the iPhone is done in portrait. This is not an absolute rule however, it's just the way I see it.
The graphics aren't too different between the devices, except that because of the large screen size, you can do a bit more detailed work with the iPad images then the iPhone images. (Even with the retina display, too fine detail on the iPhone is barely noticeable.)
The other thing I wanted to mention is the flow of the devices. Again, because of the screen size of the iPad, you can fit a lot more content on the screen, and therefore have to push to new views less frequently. I've worked on apps where we had 3 UIViewController's for the iPhone version, and only 1 for the iPad version.
In short, it depends really on your type of app. If you have a lot of content, and want to display it all at once, go for the iPad. If you want a streamlined, minimal approach to your app, go for the iPhone.
Again, this is all just my personal opinion. Hope that Helps!
You can use native controls without much theming and customization on the iPhone. But iPad is a bigger beast. Users use your iPad app for a longer time. iPhone apps are used for a short stint and then closed, used again for a short stint and so on.
Analytics published by Flurry showed that the average time an iPhone app is kept open is about 1.2 minutes. Design and develop it in a way that data is available as fast as you can.
iPad apps are used in a relaxed setting. While I don't have the numbers, it's probably used more often and for a longer time than an iPhone app. Themes and custom UI elements do matter a lot there
Second, iPad apps need to be supported on all orientation (or at least a minimum of two orientations)

iPad Content Scale Factor x2 for iPhone application

I'm hoping to recursively change every single View in my application to use the iPhone 4 graphics, and change the content scale factor to 2.0, such that it's the zoomed in version of my iPhone application on the iPad by default.
Currently, the iPad starts out in x1 Zoom, which is the 320x480 pixel version displayed on the 1024x768 real estate of the iPad, where the powers that be have declared that they're too cheap to actually invest in an iPad app, instead requesting that we have the application use iPhone retina graphics with a default content scale factor of 2.0
Upon googling and searching stackoverflow it seems my query is unique, though some questions are sort of similar such as -> Problem adapting scale factor for iPad x2 compatibility mode
And the best way to go about doing this remains undocumented, so I hope to implement this 'hack' so to speak in the best most succinct way possible.
If anyone has done this before, please share the code, otherwise I will update this with my own answer once I've figured it out.
The Answer: THIS CANNOT BE DONE.
The iPad will treat the screen as 480x320, even at 2x, so even if you change the contentScaleFactor appropriately and force it to use #2x.png images, you won't get any better resolution.
This is built into the iphone Operating system, only the Jailbroken iPads can get around this. Which isn't an option to consider.
It's easier to just duplicate the target for iPad, and realign the nib files appropriately, and make the app a Universal App.
It's a daft idea, and even if Apple change this in future SDK releases, it won't be backward compatible which again isn't an option, at least for our development team.
I think the best way to do it rules out using nib files.
If you create your views in code, you can easily use conditional code ([[UIDevice currentDevice] userInterfaceIdiom]) and based on that set the scale for the UIView elements.