The value of gl_Position is that OpenGL calls "clip space". This is a homogeneous coordinate system . In particular, the XYZ extents of the clip space are [-W, + W]. Therefore, each vertex is in its own space of the clip.
I do not quite understand what you mean by "what rules." The gl_Position clip space is tied to the viewport in a uniform space. Therefore, they are attached to the region [-W, + W] for each vertex. It is difficult to imagine that in a projective homogeneous space, but mathematics is obtained, therefore it does not matter.
After that, the trimmed vertices are converted to the normalized device coordinate space (NDC). This means dividing the XYZ space of the clip by W. All these vertices are in the range [-1, 1].
From there, the viewport is converted. The glViewport parameters scale vertices from the [-1, 1] NDC space to the viewport area. This converts dots to window space; it is in the window space that they are rasterized.
XY window space is controlled by glViewport . Z values ββfor the window space are controlled using glDepthRange . The default depth range is a close value of 0 and a far value of 1 (WARNING: the perspective near / far matrix has nothing to do with the depth range. Do not confuse the two). Thus, it displays [-1, 1] Z in the NDC space in [near, far] in the window.
These are the "rules."
source share