Ortho + Aspect Ratios
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:
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.
Code:
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.
stinware.com where games are friends.
http://onesadcookie.com/svn/repos/Astro/Source/main.cpp
search for "aspect"
it's not the prettiest code ever, but it works...
search for "aspect"
it's not the prettiest code ever, but it works...
Hey thanks.
I actually got it working with something similar I was trying. I just had the operations reversed. Your code gave me inspiration.
I actually got it working with something similar I was trying. I just had the operations reversed. Your code gave me inspiration.
stinware.com where games are friends.
Possibly Related Threads...
Thread: | Author | Replies: | Views: | Last Post | |
Draw to texture using FBOs - aspect ratio issues | Madrayken | 2 | 6,375 |
Jul 15, 2010 11:47 AM Last Post: Madrayken |
|
3D in Ortho | bmantzey | 5 | 5,704 |
Nov 20, 2008 02:34 AM Last Post: DoG |
|
2D to 3D and back (Ortho and Perspective) | Phate | 5 | 7,433 |
Nov 30, 2003 10:56 AM Last Post: AnotherJake |
|
Ortho problems | Kattmat | 6 | 4,937 |
Oct 12, 2003 12:15 PM Last Post: Kattmat |
|
ratios... | Muffinking | 3 | 3,494 |
Jun 15, 2003 10:32 PM Last Post: henryj |