Some details that complement the general answers:
The idea is to project the point (x, y, z) onto the screen in order to have (xs, ys, d). The following figure shows this for the y coordinate.

We know from school that
tan (alpha) = ys / d = y / z
This means that the projection is calculated as
ys = d * y / z = y / w
w = z / d
This is enough to apply projection. However, in OpenGL, you want (xs, ys, zs) to be the normalized coordinates of the device in [-1,1] and yes, it has something to do with clipping.
The extremum values ββfor (xs, ys, zs) represent a single cube, and everything outside it will be truncated. Thus, the projection matrix usually takes into account the limits of the cutoff (Frustum), to make one transformation, which, with the separation of perspective, simultaneously applies the projection and converts the projected coordinates along with z into the normalized coordinates of the device.
a.lasram
source share