Page 1 of 1

window's display ratio incorrect when resizing !

Posted: Wed Apr 05, 2006 8:26 am
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.

Posted: Wed Apr 05, 2006 8:39 am
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:

Posted: Wed Apr 05, 2006 8:48 am
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.

Posted: Wed Apr 05, 2006 10:45 am
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.

resize constraints

Posted: Sat Apr 08, 2006 8:42 am
by drac_gd
codeguru has alot of good code
here is on on resizing

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

Aspect Ratio

Posted: Sat Apr 08, 2006 11:21 am
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

Re: window's display ratio incorrect when resizing !

Posted: Mon Apr 10, 2006 3:53 pm
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]