Strange bug with uiview orientations

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
User avatar
Brocan
Orc
Posts: 441
Joined: Tue Aug 01, 2006 1:43 am
Location: Spain!!
x 8

Strange bug with uiview orientations

Post by Brocan »

Hi everyone!

I'm suffering a strange bug regarding orientations. I'm using the device in landscape right mode, so I create the window using the bounds of the parent view (which is shown in a right way), the bounds are width 480 and height 320.

Next, the window is created, into "EAGL2Window::create" mWidth is assigned to 480 and mHeight to 320, all ok at this moment.
But we arrive to initNativeCreatedWindow, here the mWidth and mHeight params are not taken in account, it creates the view using mGLSupport->......find("Video Mode"). This Video Mode says that my window must have a width of 300 and a height of 480 , and the view is created using this dimensions but the FrameBuffer is using a backing width of 480 and height of 300:
iOS: Window created 300 x 480 with backing store size 480 x 300 using content scaling factor 1.0
At last, it goes to resize function and the line: UIInterfaceOrientationIsPortrait(mViewController.interfaceOrientation) returns false, so the w *= std::max(width, height); h *= std::min(width, height); returns w=480 and h=300 (which is not true) and as the resize function has received the same parameters, it doesn't resize anything.

The final result of this, is that my ogre view is rotated 90º and it only covers the half of the screen (300 pixels).

For more information: i'm passing a custom window to destroy it after ogre init and attach the ogre view to my parent view (this view is perfectly fit in the screen) and the dummy window is also created with the same params. I've try also without passing a custom window and let ogre to create them, without success.

I'm not an expert on iOS programming, so its easy that i've forgot something or to add some line of code to deal with orientations :lol:. BTW the info.plist sets that the orientation available is only landscape right.

I think that the problem comes from take the resolution from mGLSupport->......find("Video Mode") instead of using the passed params. And i haven't also any idea where is the file where these "Video Mode" values are read. :|

Any idea of how solve the problem?

I'm using iOS 5.1 and XCode 4.3.3 running over an iPhone 3GS with iOS 5.1.1

Thanks in advance!
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: Strange bug with uiview orientations

Post by masterfalcon »

The code for supporting Ogre as a subview on iOS has only gotten minimal testing. Would you be able to put together a simple test case for reproducing this bug?
User avatar
Brocan
Orc
Posts: 441
Joined: Tue Aug 01, 2006 1:43 am
Location: Spain!!
x 8

Re: Strange bug with uiview orientations

Post by Brocan »

masterfalcon wrote:The code for supporting Ogre as a subview on iOS has only gotten minimal testing. Would you be able to put together a simple test case for reproducing this bug?
I will try to make a minimal example to reproduce it, tomorrow or the next week (depends on my job load amongs other projects :mrgreen: ). :D

Thus, the current implementation needs of passing (or create) always a window to autoattach the ogre view to it. It could be possible to pass a parent view to attach to it? or there is some reason for need a window?
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: Strange bug with uiview orientations

Post by masterfalcon »

Yes. The view needs to know what window it's attached to.

You can check out a number of other samples for passing a "externalWindowHandle" by searching the forums for now at least.

But whenever you can get me a sample that'd be great. Thanks!
User avatar
Brocan
Orc
Posts: 441
Joined: Tue Aug 01, 2006 1:43 am
Location: Spain!!
x 8

Re: Strange bug with uiview orientations

Post by Brocan »

masterfalcon wrote:Yes. The view needs to know what window it's attached to.

You can check out a number of other samples for passing a "externalWindowHandle" by searching the forums for now at least.

But whenever you can get me a sample that'd be great. Thanks!
And you can't attach the ogre view to a parent view? The parent view needs to be already attached to a window? it (the parent view) can't be attached to a window after attach the ogre view?
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: Strange bug with uiview orientations

Post by masterfalcon »

For the time being, yes. The Ogre view must be a first level subview.
User avatar
Brocan
Orc
Posts: 441
Joined: Tue Aug 01, 2006 1:43 am
Location: Spain!!
x 8

Re: Strange bug with uiview orientations

Post by Brocan »

After two days without having any idea about how to fix or deal with the problem, i've forced the system to work in portrait mode. It goes well.
User avatar
Brocan
Orc
Posts: 441
Joined: Tue Aug 01, 2006 1:43 am
Location: Spain!!
x 8

Re: Strange bug with uiview orientations

Post by Brocan »

Now i'm trying to allow all rotations. After enabling it into xcode, i'm having the same issue that this post (http://www.ogre3d.org/forums/viewtopic.php?f=21&t=60949), the viewport seems to be rotated correctly (the ogre head rotates with the mobile) but the window doesn't seem to be resized. :|