window's display ratio incorrect when resizing !

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
michael520
Posts: 230
Joined: Mon Oct 10, 2005 2:24 am

window's display ratio incorrect when resizing !

Post by michael520 »

I don't know if any experienced man have encounter this problem. But it's really a big one!

When resizing the window, the graphics will be resizing,too!! looks fater or taller.
hybrid

Post by hybrid »

If any of the experienced users would know he would have posted it to your other thread on the same topic! And they already did :!: So why don't you stop cross posting? If you realized that posting in offtopic has not been the best idea you should've asked the mods to move your thread instead of starting a new one. Or do you think that all those who already answered you will add their posts in here again?
So please contact the forum mods and ask to remove this thread and move the other one (maybe all three you posted in offtopic) to this forum or maybe the beginner's one.
Doh :roll:
michael520
Posts: 230
Joined: Mon Oct 10, 2005 2:24 am

Post by michael520 »

So sad to hear these words. :cry:

I post it here because I think it's not an offtopic. I would delete the one in offtopic later.
hybrid

Post by hybrid »

Yes, it's definitely not offtopic. But it's better to move the thread than starting a new one. This is possible for Moderators only, though.
drac_gd

resize constraints

Post by drac_gd »

codeguru has alot of good code
here is on on resizing

http://www.codeguru.com/cpp/w-d/dislog/ ... php/c4983/
new guy

Aspect Ratio

Post by new guy »

If you set the aspect ratio for your camera with setAspectRatio, use height/width insetad of width/height. I'm not sure why anybody would calculate aspect ratio like that, but it's probably a feature ;-)

Michael
Rv
Posts: 10
Joined: Fri Mar 31, 2006 9:38 am

Re: window's display ratio incorrect when resizing !

Post by Rv »

michael520 wrote:I don't know if any experienced man have encounter this problem. But it's really a big one!

When resizing the window, the graphics will be resizing,too!! looks fater or taller.
Here's how I did it:

Code: Select all

void CSceneManager::UpdateViewportAspect(UINT sx, UINT sy)
{
	if ( m_pCamera )
	{
		//. When the viewport is 440 pixels tall, we want a FOV of 70 degrees
		const float kfBaseFOVdeg = 70.0f;
		const float kfBaseHeight = 440.0f;
		const float kfBaseFOV	 = irr::core::PI * 360.0f / kfBaseFOVdeg;

		float fBaseRatio = fabs( tan( kfBaseFOV ) / kfBaseHeight );

		float aspect = (float)sx / sy;
		float fov = atan( fBaseRatio * sy ) * 2.0f;

		m_pCamera->setAspectRatio( aspect );
		m_pCamera->setFOV( fov );

	}
}
Hope this helps :D

Oops, nearly forgot, for this to work, you'll need the projection matrix fix, described here:

http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=12426


[edit: matrix fix]
Harvey Gilpin, code monkey
Post Reply