Ortho + Aspect Ratios

Member
Posts: 50
Joined: 2002.12
Post: #1
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:

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.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
http://onesadcookie.com/svn/repos/Astro/Source/main.cpp

search for "aspect"

it's not the prettiest code ever, but it works...
Quote this message in a reply
Member
Posts: 50
Joined: 2002.12
Post: #3
Hey thanks.

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.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Draw to texture using FBOs - aspect ratio issues Madrayken 2 4,054 Jul 15, 2010 11:47 AM
Last Post: Madrayken
  3D in Ortho bmantzey 5 3,760 Nov 20, 2008 02:34 AM
Last Post: DoG
  2D to 3D and back (Ortho and Perspective) Phate 5 5,255 Nov 30, 2003 10:56 AM
Last Post: AnotherJake
  Ortho problems Kattmat 6 3,281 Oct 12, 2003 12:15 PM
Last Post: Kattmat
  ratios... Muffinking 3 2,377 Jun 15, 2003 10:32 PM
Last Post: henryj