I'm having a little problem with Ogre 1.8 and the iPhone. My project works in portait mode (In the XCode proj preferences, only portrait is enabled) so nothing happens when i roteate the device in landscape postion.
However when i open an UIView modal to the one created by Ogre while the device is held in landscape position (For example Game Center leaderboards or iAds full screen advertisements), Ogre automatically sets the aspect ratio to landscape (and it shouldn't) but it keeps the view orientation to portrait.
The result is that the whole scene is "streched out"! If these modal windows are opened while the device is being held in portrait position everything works fine.
I believe there's something to be fixed in the way Ogre handles the UIView.
Any hint about where is the pertinent code located and what could be causing this issue?
[SOLVED] Incorrect aspect ratio (Patch needed?)
-
- Halfling
- Posts: 70
- Joined: Sun Dec 02, 2007 11:10 am
- Location: Italy
- x 2
[SOLVED] Incorrect aspect ratio (Patch needed?)
Last edited by Ologon on Sat Oct 27, 2012 10:39 am, edited 1 time in total.
-
- OGRE Retired Team Member
- Posts: 4270
- Joined: Sun Feb 25, 2007 4:56 am
- Location: Bloomington, MN
- x 126
Re: [Bug?] Incorrect aspect ratio
That's interesting. I'd check in the ViewController to see if it's receiving some events and making changes for some reason.
-
- Halfling
- Posts: 70
- Joined: Sun Dec 02, 2007 11:10 am
- Location: Italy
- x 2
Re: [Bug?] Incorrect aspect ratio
My ViewController doesn't do anything suspicious, it just listens to touch events. My application never switches orientation and/or aspect ratio either... The most plausible cause I can think is that ogre is receiving an event informing that the device switched to landscape mode (even if it didn't), which would cause it to set the wrong aspect ratio (640/320 instead of 320/640), the orientation is kept to portrait because landscape is disable in Xcode, which causes the stretched view :/
-
- Halfling
- Posts: 70
- Joined: Sun Dec 02, 2007 11:10 am
- Location: Italy
- x 2
Re: [SOLVED] Incorrect aspect ratio (Patch needed?)
Okay, I've solved this bug.
Basically what caused the issue is the "layoutSubviews" method in OgreEAGLView.mm
This method resizes the window (and adjusts the aspect ratio) but doesn't check if the rotation is actually supported before doing that. So the fix was to simply add this check to the method:
I put it right after:
I don't know if a patch should be submitted for this? Btw, I'm still using Ogre 1.8.0, as 1.8.1 strangely hangs at startup sometimes.
Basically what caused the issue is the "layoutSubviews" method in OgreEAGLView.mm
This method resizes the window (and adjusts the aspect ratio) but doesn't check if the rotation is actually supported before doing that. So the fix was to simply add this check to the method:
Code: Select all
//Check if orientation is supported
NSString *rotateToOrientation = @"";
if(deviceOrientation == UIInterfaceOrientationPortrait)
rotateToOrientation = @"UIInterfaceOrientationPortrait";
else if(deviceOrientation == UIInterfaceOrientationPortraitUpsideDown)
rotateToOrientation = @"UIInterfaceOrientationPortraitUpsideDown";
else if(deviceOrientation == UIInterfaceOrientationLandscapeLeft)
rotateToOrientation = @"UIInterfaceOrientationLandscapeLeft";
else if(deviceOrientation == UIInterfaceOrientationLandscapeRight)
rotateToOrientation = @"UIInterfaceOrientationLandscapeRight";
NSArray *supportedOrientations = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UISupportedInterfaceOrientations"];
BOOL supported = [supportedOrientations containsObject:rotateToOrientation];
if (!supported)
return;
Code: Select all
// Return if the orientation is not a valid interface orientation(face up, face down)
if(!UIDeviceOrientationIsValidInterfaceOrientation(deviceOrientation))
return;
I don't know if a patch should be submitted for this? Btw, I'm still using Ogre 1.8.0, as 1.8.1 strangely hangs at startup sometimes.
-
- Ogre Magi
- Posts: 1235
- Joined: Fri Oct 26, 2007 12:36 am
- Location: Mountain View, CA
- x 10
Re: [SOLVED] Incorrect aspect ratio (Patch needed?)
+1 to this. I have to make that change every time I rebuild Ogre.
-
- OGRE Retired Team Member
- Posts: 4270
- Joined: Sun Feb 25, 2007 4:56 am
- Location: Bloomington, MN
- x 126
Re: [SOLVED] Incorrect aspect ratio (Patch needed?)
Don't worry about it. I'll apply it to the 1.8 branch this weekend.
-
- Ogre Magi
- Posts: 1235
- Joined: Fri Oct 26, 2007 12:36 am
- Location: Mountain View, CA
- x 10
Re: [SOLVED] Incorrect aspect ratio (Patch needed?)
Hey David, did you get chance to apply this yet? 

-
- OGRE Retired Team Member
- Posts: 4270
- Joined: Sun Feb 25, 2007 4:56 am
- Location: Bloomington, MN
- x 126
Re: [SOLVED] Incorrect aspect ratio (Patch needed?)
I have not yet. But i'll check it out tonight.