Sign in to follow this  
keym

Aspect ratio for tall windows

Recommended Posts

keym    229

Hello,

I'm having troubles with maintaining aspect ratio while my window is taller than wider. How do I readjust that in my perspective matrix? I calculate aspect ratio simply dividing width / height and it works great when window is wider than taller but the other way around my image is stretched. Any solutions to this? I make my perspective matrix using D3DXMatrixPerspectiveFovRH.

Edited by keym

Share this post


Link to post
Share on other sites
Jason Z    6436

Are you certain that the width and height are being interpreted as floating point numbers before doing the division?  If not, then try casting the values to float individually prior to the division.  It could be that you are accidentally using integer division, which will give you step changes in situations like this.

Share this post


Link to post
Share on other sites
Jason Z    6436

There is no inherent limitation to a particular aspect ratio for the function you are using to calculate the perspective matrix.  Can you post a screen shot of what you are seeing that looks incorrect?  That might help clarify what is the issue.

Share this post


Link to post
Share on other sites
keym    229

Ok, it seems that the problem was related to my part of code responsible for resizing texture that I use for drawing. When I fixed it, it now works as I want (clipping on sides when the window is taller than wider). I don't even have to alter aspect value and perspective matrix in any way. Funny how often you resolve problems after posting ><

 

Anyways, thanks for looking ya'll.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this