I have this gluPerspective code :
I want to use glOrtho version of this code. But I couldn’t come up with the correct one. How can I convert this to glOrtho in a healthy way?
Thanks in advance.
There is no “correct” one.
A perspective projection results in objects appearing smaller as they get farther from the viewpoint. An orthographic projection maintains a constant scaling regardless of distance.
Your perspective projection has a scale factor of 0.24 at the near plane (z=-10) and 6e-5 (0.00006) at the far plane (z=-40000). More generally, the scale factor for any given Z will be 2.4/(-z). This represents the amount by which the normalised device coordinates will change for a 1-unit change in eye coordinates.
You can construct an orthographic projection for any given scale factor. If you choose a value of Z, you can create an orthographic projection which has the same scale factor as your perspective projection for that specific value of Z. Objects at that distance will appear the same size in either projection. Nearer objects will appear larger with the perspective projection, while farther objects will appear smaller.