Increase the distance to the plane of an OpenGL clip

I am trying to make C ++ OpenGL a representation of our solar system as a way to teach myself OpenGL, so please keep your answers simple. The problem is that the planets are very far away, so everything else goes beyond clipping when viewing from any planet. How to move crop of a C ++ plane of OpenGL 3.1, say, 2000000000 ? I would prefer a simple code snippet if possible. I looked at SO and the forum posts about it, but they are either so old that nothing is applicable (using outdated APIs or just dead links), or so complex that I can’t understand what they are saying.

+4
source share
1 answer

Cut-off planes are determined by the perspective projection matrix.

If you are using glFrustum , change the last argument passed to it to 2,000,000,000.0.

If you use your own matrix, set the 10th element of your matrix array:

(2000000000.0+nearClippingPlane)/(nearClippingPlane-2000000000.0)

(formula (far+near)/(near-far) )

and from 14 to:

(-4000000000.0*nearClippingPlane)/(2000000000.0-nearClippingPlane)

(formula (-2.0*near*far)/(far-near) )

2,000,000,000 is very important, so a Z-fight can happen if you add details such as mountains.

+2
source

All Articles