View Full Version : World, camera, object coordinates in the glOrtho function

giorgik

08-27-2017, 05:43 AM

I have a great confusion, when I have to use the glOrtho function, I do not know which system of coordinates it uses for its parameters, namely: left, right, bottom, up, close, do they are compared to what coordinate system? Would it be possible to have a figure that shows me clearly and unambiguously?

Dark Photon

08-27-2017, 01:02 PM

Eye space. If you get a decent OpenGL book, it'll describe this pretty clearly:

* OpenGL Projection Matrix (http://www.songho.ca/opengl/gl_projectionmatrix.html) (Ahn)

giorgik

08-27-2017, 03:58 PM

Eye space. If you get a decent OpenGL book, it'll describe this pretty clearly:

* OpenGL Projection Matrix (http://www.songho.ca/opengl/gl_projectionmatrix.html) (Ahn)

Ok, but near and far in the glOrtho: these values are negative if the plane is to be behind the viewer. Is the viewer the camera or the object ?

Dark Photon

08-28-2017, 07:11 AM

Ok, but near and far in the glOrtho: these values are negative if the plane is to be behind the viewer.

Correct. So near/far are actually the negation of eye-space Z axis values.

Is the viewer the camera or the object ?

The camera.

To your original question, the glOrtho parameter values are specified in eye-space. In eye-space, the camera (the viewer) is at the origin looking down the -Z axis with +X right and +Y up.

So as for the glOrtho parameters...:

left and right are eye-space X axis values

bottom and top are eye-space Y axis values

near and far are eye-space Z axis values, but negated!

So for instance, glOrtho with a near argument of 1.0 equates to the Z = -1.0 plane in eye-space, which is in front of the eye (the origin).

giorgik

08-28-2017, 11:24 AM

Correct. So near/far are actually the negation of eye-space Z axis values.

The camera.

To your original question, the glOrtho parameter values are specified in eye-space. In eye-space, the camera (the viewer) is at the origin looking down the -Z axis with +X right and +Y up.

So as for the glOrtho parameters...:

left and right are eye-space X axis values

bottom and top are eye-space Y axis values

near and far are eye-space Z axis values, but negated!

So for instance, glOrtho with a near argument of 1.0 equates to the Z = -1.0 plane in eye-space, which is in front of the eye (the origin).

Oh, it's finally clear now. So close values and positive results in GlOrtho are actually negative on z axis.

Thank you, Dark Photon

Powered by vBulletin® Version 4.2.3 Copyright © 2018 vBulletin Solutions, Inc. All rights reserved.