[iOS] How can I tell device information (iPhone Vs iPad etc)

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
Post Reply
simedj
Goblin
Posts: 262
Joined: Fri Nov 18, 2011 6:50 pm

[iOS] How can I tell device information (iPhone Vs iPad etc)

Post by simedj » Sat Feb 22, 2014 3:11 pm

I want to build a combined iPhone/iPad app rather than separate apps, to quickly test some things. I'll support retina iPhone only, iPad2 and above.

But resolutions on these devices are different - in fact on iPhone you have 3.5" AND 4" versions. And then, on iPhone I want to always use full retina resolution (Scaling Factor=2) but on iPad I want to never use retina (Scaling Factor=1).
How can I sort this out in code, and/or by using multiple ogre.cfg files? Does Ogre know what device it runs on or do I need to use OBJ-C for this? When creating my RenderWindow, can I tell Ogre "just use the device resolution"?

Thankyou.
0 x
Looking to find experienced Ogre & shader developers/artists. PM me with a contact email address if interested.

User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
Contact:

Re: [iOS] How can I tell device information (iPhone Vs iPad

Post by masterfalcon » Sat Feb 22, 2014 5:35 pm

I would recommend taking a look at Apples UIDevice class for determining what device you are running on and then set window parameters accordingly.
0 x

simedj
Goblin
Posts: 262
Joined: Fri Nov 18, 2011 6:50 pm

Re: [iOS] How can I tell device information (iPhone Vs iPad

Post by simedj » Mon Feb 24, 2014 9:38 am

Thanks. I came across this useful macro - UI_USER_INTERFACE_IDIOM() - which trivially identifies between phone and tablet form factor.

I also hadn't realised that Ogre automatically sets a resolution in the GLES2 RenderSystem configuration based on the device screen resolution, in EAGL2Support::addConfig():

Code: Select all

CGSize screenSize = [[UIScreen mainScreen] bounds].size;
I found this after finding the same thing on StackOverflow and was about to implement it when I realised Ogre already did it for me :)

However there seemed to be some debate on iPhone status bar and device orientation in that link so I raised this PaperCut: http://www.ogre3d.org/forums/viewtopic.php?f=22&t=80243
0 x
Looking to find experienced Ogre & shader developers/artists. PM me with a contact email address if interested.

Post Reply