PDA

View Full Version : Perspective vs. Ortho



stout
08-25-2003, 10:02 AM
I am trying to render a square with a beveled edge so that the light source will give a raised 3D look. I have this working at the moment, but my problem is when I try translate the square to the upper left or lower right of the window, the "perspective" kicks in and makes the face of the square move to the upper left or lower right depending on the location. This effect reflects the real world very nicely, but I don't want this. I want the square to have a "top down" look no matter where I place the square. In other words, the beveled edges should all have the same uniform spacing all around the square. Below is my attempt to show the square using text. Notice that the inner part of the square is what I call the "face".



--------
|\ /|
| ----- |
| | | |
| | | |
| | | |
| | | |
| ----- |
|/ \|
--------

From what I have read, I think I am supposed to use glOrtho to render things without perspective, but I don't know how to translate the gluPerspective method into glOrtho.

Here is the code for the reshape method when the window gets resized...

gl.glViewport(0, 0, width, height);
gl.glMatrixMode(GL_PROJECTION);
gl.glLoadIdentity();
glu.gluPerspective(45.0f, width / height, 0.1f, 100.0f);
gl.glMatrixMode(GL_MODELVIEW);
gl.glLoadIdentity();

Any thoughts?

[This message has been edited by stout (edited 08-25-2003).]

mikael_aronsson
08-25-2003, 11:42 AM
Hi !

have a look at the FAQ on thsi website: http://www.opengl.org/developers/faqs/technical/transformations.htm#tran0085

9.085, it shows how to convert the fov to left.right.top.bottom values for glFrustum, you can use the same thing for glOrtho.

Mikael

stout
08-25-2003, 11:05 PM
Originally posted by mikael_aronsson:
Hi !

have a look at the FAQ on thsi website: http://www.opengl.org/developers/faqs/technical/transformations.htm#tran0085

9.085, it shows how to convert the fov to left.right.top.bottom values for glFrustum, you can use the same thing for glOrtho.

Mikael

Thanks for your reply! I tried your suggestion, and I get identical results using glFrustum. However, when I try to use glOrtho with the same parameters, I don't get what I expect. Any ideas why?

Thanks!