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: 51
Joined: Sun Sep 06, 2009 12:36 pm
x 2
Contact:

landscape viewport orientation on Windows

Post by suny2000 » Sat Aug 30, 2014 9:40 am

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.
0 x
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: 7152
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 19

Re: landscape viewport orientation on Windows

Post by Kojack » Sat Aug 30, 2014 5:38 pm

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

User avatar
suny2000
Halfling
Posts: 51
Joined: Sun Sep 06, 2009 12:36 pm
x 2
Contact:

Re: landscape viewport orientation on Windows

Post by suny2000 » Sun Aug 31, 2014 9:05 am

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 :)
0 x
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: 7152
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 19

Re: landscape viewport orientation on Windows

Post by Kojack » Sun Aug 31, 2014 9:16 am

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

Post Reply