Landscape mode problem on iPhone

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Adversus
Posts: 128
Joined: Sun Oct 05, 2008 10:58 pm
Contact:

Landscape mode problem on iPhone

Post by Adversus »

Hi Guys,

I'm trying to fix the bug due to the landscape mode in my game.

Basically even though the Windows and iPhone version are identical I need to do:

Code: Select all

// landscape mode
#if defined( GR_IPHONE_DEVICE )
	core::matrix4 landscapeMatrix;
	landscapeMatrix.setRotationDegrees( core::vector3df(0.0, 0.0, -90.0) );
	driver->setTransform(video::ETS_PROJECTION, ViewArea.Matrices[video::ETS_PROJECTION]*landscapeMatrix );
				#else
	driver->setTransform(video::ETS_PROJECTION, ViewArea.Matrices [ video::ETS_PROJECTION ] );
#endif
And while this works and it gives me a landscape it doesn't work exactly. The iPhone version looks a little zoomed in. I think this is due to having to pass the screen dimensions into glViewport and during the creation of the Window as they are different due to the fact the Windows one is "true" landscape while the iPhone one is "faked" using a rotated projection matrix.

For reasons specific to my type of game this is now causing issues.

I can't simply swap the values around in glViewport as then I don't fill the screen and I'm not sure mathematically how to fix this.

Does anyone have a solution?

Cheers,
Adversus
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Maybe it's related to the aspect ratio?
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

The iPhone VIEW (key word for looking in the iPhone docs) is a UIView component, rotate that instead and use 480x320. That will also handle when you want to use autorotation or device orientation notification rotations.

Inside the iPhone driver theres a UIView, in the initialisation, just change its rotation.
Adversus
Posts: 128
Joined: Sun Oct 05, 2008 10:58 pm
Contact:

Post by Adversus »

I tried swapping the width and height for the aspect ratio however it now looks like the field of view is right i.e. an object looks the same distance away however it also gives a weird stretching effect. The vertical is squashed showing more and the horizontal is stretched showing less if that makes sense.

I can't just rotate the UIView, it's slow because it has to be done by coreAnimation and they recommend you do it by rotating the projection matrix instead.
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

Adversus wrote:I tried swapping the width and height for the aspect ratio however it now looks like the field of view is right i.e. an object looks the same distance away however it also gives a weird stretching effect. The vertical is squashed showing more and the horizontal is stretched showing less if that makes sense.
I bet you are doing the same i did...when assigning the AspectRatio make sure you are deviding floats and not ints!!!! this easy bug gave me a lot of trouble.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Adversus
Posts: 128
Joined: Sun Oct 05, 2008 10:58 pm
Contact:

Post by Adversus »

I wish it was that easy :-)

Nope here's my code in the camera

Code: Select all


video::IVideoDriver* d = mgr->getVideoDriver();
if (d)
 Aspect = (f32)d->getCurrentRenderTargetSize().Width/(f32)d->getCurrentRenderTargetSize().Height;

Post Reply