PDA

View Full Version : Ortho + Aspect Ratios


jSTIN
2005.04.06, 12:54 AM
How can I get an ortho view with the correct aspect ratio of my window? I need to be able to display an object in perspective and orthographic views. I tried variations of this:


double aspect = width / height; // from window dimensions
...
glOrtho(-2.5 / aspect, 2.5 / aspect, -2.5, 2.5, 0, 100);


I tried varying what got divided or multiplied by the aspect ratio, but nothing works correctly. I'm thinking glOrtho isn't the way to go.

OneSadCookie
2005.04.06, 01:29 AM
http://onesadcookie.com/svn/repos/Astro/Source/main.cpp

search for "aspect"

it's not the prettiest code ever, but it works...

jSTIN
2005.04.06, 01:21 PM
Hey thanks.

I actually got it working with something similar I was trying. I just had the operations reversed. Your code gave me inspiration.