Jump to content
  • Advertisement
Sign in to follow this  
keym

Aspect ratio for tall windows

This topic is 2010 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement

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

Yes, I was casting them to floats from the very beginning so that's not the issue. Thanks though.

Share this post


Link to post
Share on other sites

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

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!