[SOLVED] Incorrect aspect ratio (Patch needed?)

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
Post Reply
Ologon
Halfling
Posts: 70
Joined: Sun Dec 02, 2007 11:10 am
Location: Italy

[SOLVED] Incorrect aspect ratio (Patch needed?)

Post by Ologon » Wed Oct 24, 2012 9:27 pm

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?
Last edited by Ologon on Sat Oct 27, 2012 10:39 am, edited 1 time in total.
0 x

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

Re: [Bug?] Incorrect aspect ratio

Post by masterfalcon » Wed Oct 24, 2012 9:45 pm

That's interesting. I'd check in the ViewController to see if it's receiving some events and making changes for some reason.
0 x

Ologon
Halfling
Posts: 70
Joined: Sun Dec 02, 2007 11:10 am
Location: Italy

Re: [Bug?] Incorrect aspect ratio

Post by Ologon » Wed Oct 24, 2012 10:00 pm

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 :/
0 x

Ologon
Halfling
Posts: 70
Joined: Sun Dec 02, 2007 11:10 am
Location: Italy

Re: [SOLVED] Incorrect aspect ratio (Patch needed?)

Post by Ologon » Sat Oct 27, 2012 10:42 am

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:

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;
I put it right after:

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.
0 x

User avatar
DanielSefton
Ogre Magi
Posts: 1235
Joined: Fri Oct 26, 2007 12:36 am
Location: Mountain View, CA
Contact:

Re: [SOLVED] Incorrect aspect ratio (Patch needed?)

Post by DanielSefton » Sat Nov 10, 2012 7:12 pm

+1 to this. I have to make that change every time I rebuild Ogre.
0 x

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

Re: [SOLVED] Incorrect aspect ratio (Patch needed?)

Post by masterfalcon » Sun Nov 11, 2012 10:17 am

Don't worry about it. I'll apply it to the 1.8 branch this weekend.
0 x

User avatar
DanielSefton
Ogre Magi
Posts: 1235
Joined: Fri Oct 26, 2007 12:36 am
Location: Mountain View, CA
Contact:

Re: [SOLVED] Incorrect aspect ratio (Patch needed?)

Post by DanielSefton » Fri Mar 01, 2013 7:19 pm

Hey David, did you get chance to apply this yet? :)
0 x

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

Re: [SOLVED] Incorrect aspect ratio (Patch needed?)

Post by masterfalcon » Fri Mar 01, 2013 7:58 pm

I have not yet. But i'll check it out tonight.
0 x

Post Reply