Jump to content

  • Log In with Google      Sign In   
  • Create Account

Aspect ratio for tall windows


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 keym   Members   -  Reputation: 229

Like
0Likes
Like

Posted 08 April 2013 - 06:01 AM

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, 08 April 2013 - 06:02 AM.


Sponsor:

#2 Jason Z   Crossbones+   -  Reputation: 5062

Like
2Likes
Like

Posted 08 April 2013 - 08:15 PM

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.



#3 keym   Members   -  Reputation: 229

Like
0Likes
Like

Posted 13 April 2013 - 01:13 PM

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



#4 Jason Z   Crossbones+   -  Reputation: 5062

Like
0Likes
Like

Posted 13 April 2013 - 01:29 PM

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.



#5 keym   Members   -  Reputation: 229

Like
0Likes
Like

Posted 14 April 2013 - 08:16 AM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS