landscape viewport orientation on Windows

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
User avatar
suny2000
Halfling
Posts: 72
Joined: Sun Sep 06, 2009 12:36 pm
x 12
Contact:

landscape viewport orientation on Windows

Post by suny2000 »

Hi,

I'm looking for a way to orient the Ogre viewport in lanscape, in order to use a full screen scene on a 90 degrees rotated LCD screen.
I tried to use the orientation mode of the camera, or of the viewport, and of course, it throws an exception because it only works on IOS.
Dammed.
Anyone can think of a way to orient in landscape an Ogre viewport on Windows or Mac?

S.
http://bulostudio.com: website and devlog of a small indie studio working on SHMUP CREATOR
https://twitter.com/bulostudio : follow me on twitter!
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: landscape viewport orientation on Windows

Post by Kojack »

Try this:

Code: Select all

	m_camera->setAspectRatio(float(m_window->getWidth()) / float(m_window->getHeight()));
	Ogre::Matrix4 mat = m_camera->getProjectionMatrix();
	mat = mat * Ogre::Quaternion(Ogre::Degree(90.0f), Ogre::Vector3::UNIT_Z);
	m_camera->setCustomProjectionMatrix(true, mat);
It rotates the projection matrix of the camera by 90 degrees. You might need to change it to -90 if the screen ends up upside down.
Auto aspect ration was having trouble with it, I needed to manually set the aspect ratio for it to work.
User avatar
suny2000
Halfling
Posts: 72
Joined: Sun Sep 06, 2009 12:36 pm
x 12
Contact:

Re: landscape viewport orientation on Windows

Post by suny2000 »

Thanks a lot Kojack!
It's working perfectly for the 3D scene.
Unfortunately, it doesn't rotate the overlay.
But, it's a great step in the right direction :)
http://bulostudio.com: website and devlog of a small indie studio working on SHMUP CREATOR
https://twitter.com/bulostudio : follow me on twitter!
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: landscape viewport orientation on Windows

Post by Kojack »

Overlays will use their own projection matrix to remove the perspective calculation. It can be rotated too, you just need to find it (or use a shader and do the multiply there.
I'm not sure how easy to replace an overlay's matrix would be, I've never tried. :)
Post Reply