I've built 1.8.1 for iOS with orientation support enabled. But getOrientationMode() always returns 0 as I rotate the display.
I'm not doing anything with the orientation in my code, letting Ogre do whatever it does... it is rotating the rendered output and I have all 4 orientations permitted in my plist file.
[solved] Viewport::getOrientationMode() always returns 0
-
- Goblin
- Posts: 257
- Joined: Tue Sep 02, 2008 9:41 pm
- x 1
[solved] Viewport::getOrientationMode() always returns 0
Last edited by d000hg on Mon Sep 17, 2012 8:41 pm, edited 1 time in total.
-
- Goblin
- Posts: 257
- Joined: Tue Sep 02, 2008 9:41 pm
- x 1
Re: Viewport::getOrientationMode() always returns 0
Bump. I must also be misunderstanding iOS rotations because using OIS, my X/Y coords are always switched - I want to only let my app run in landscape modes. Am I supposed to explicitly TELL my viewport about the current orientation... I'd assumed Ogre was somehow doing this but thinking about it that seems unlikely.
-
- OGRE Retired Team Member
- Posts: 4270
- Joined: Sun Feb 25, 2007 4:56 am
- Location: Bloomington, MN
- x 126
Re: Viewport::getOrientationMode() always returns 0
That was kind of a hacky way of dealing with orientation. How about just doing this?
Code: Select all
[UIDevice currentDevice].orientation
-
- Goblin
- Posts: 257
- Joined: Tue Sep 02, 2008 9:41 pm
- x 1
Re: Viewport::getOrientationMode() always returns 0
I'm not hot on OBJ-C, is that effectively a line I can put anywhere to access a sort of global var? i.e. make sure the file is compiled as obj-c and put it between #ifdefs?
-
- OGRE Retired Team Member
- Posts: 4270
- Joined: Sun Feb 25, 2007 4:56 am
- Location: Bloomington, MN
- x 126
Re: Viewport::getOrientationMode() always returns 0
Yeah I guess so
-
- Goblin
- Posts: 257
- Joined: Tue Sep 02, 2008 9:41 pm
- x 1
Re: Viewport::getOrientationMode() always returns 0
Oh I looked around and found some samples doing this kind of thing, that was a daft question.
But whatever I try to do with orientation makes things worse. All I did was base my code off the sample app but my mouse X/Y axes are swapped and trying to fix it just screws up the render orientation.
All I want is to force it in landscape mode and make the mouse work, I don't even need to support multiple rotations!
But whatever I try to do with orientation makes things worse. All I did was base my code off the sample app but my mouse X/Y axes are swapped and trying to fix it just screws up the render orientation.
All I want is to force it in landscape mode and make the mouse work, I don't even need to support multiple rotations!
-
- OGRE Retired Team Member
- Posts: 4270
- Joined: Sun Feb 25, 2007 4:56 am
- Location: Bloomington, MN
- x 126
Re: Viewport::getOrientationMode() always returns 0
Then all you need to do is change what orientations are supported in your app's Info.plist. Ogre reads those values and will limit rotation events appropriately.
From the sample browser, this is what you need for the input. It assumes you're using OIS but is easily adapted for any input system.
From the sample browser, this is what you need for the input. It assumes you're using OIS but is easily adapted for any input system.
Code: Select all
void transformInputState(OIS::MultiTouchState &state)
{
int w = mWindow->getViewport(0)->getActualWidth();
int h = mWindow->getViewport(0)->getActualHeight();
int absX = state.X.abs;
int absY = state.Y.abs;
int relX = state.X.rel;
int relY = state.Y.rel;
UIInterfaceOrientation interfaceOrientation = [UIApplication sharedApplication].statusBarOrientation;
switch (interfaceOrientation)
{
case UIInterfaceOrientationPortrait:
break;
case UIInterfaceOrientationLandscapeLeft:
state.X.abs = w - absY;
state.Y.abs = absX;
state.X.rel = -relY;
state.Y.rel = relX;
break;
case UIInterfaceOrientationPortraitUpsideDown:
state.X.abs = w - absX;
state.Y.abs = h - absY;
state.X.rel = -relX;
state.Y.rel = -relY;
break;
case UIInterfaceOrientationLandscapeRight:
state.X.abs = absY;
state.Y.abs = h - absX;
state.X.rel = relY;
state.Y.rel = -relX;
break;
}
}
-
- Goblin
- Posts: 257
- Joined: Tue Sep 02, 2008 9:41 pm
- x 1
Re: Viewport::getOrientationMode() always returns 0
That looks far too easy 
