opengl中z坐标的值是多少

What is the value of z-coordinate in opengl

我刚开始使用lwjgl 3学习现代opengl。我对opengl的坐标系感到困惑。

我知道当您指定 window 的宽度和高度时,坐标会映射到该宽度,height.For 例如,如果屏幕宽度为 600,则坐标 [1,0] 将是映射到[600,0].

我想知道z坐标的距离值是多少?

z坐标对应深度。它的值通常是表示片段在近平面和远平面之间的距离的分数,如下所示:The camera and its near and far planes。 Clipped 表示片段不可见。

z/depth 值主要用于深度测试,这是一个剔除位于其他对象后面的对象(特别是它们必须被它们遮挡)的过程。最好在这里描述(来自learnopengl.com):

OpenGL stores all its depth information in a z-buffer, also known as a depth buffer. GLFW automatically creates such a buffer for you (just like it has a color-buffer that stores the colors of the output image). The depth is stored within each fragment (as the fragment's z value) and whenever the fragment wants to output its color, OpenGL compares its depth values with the z-buffer and if the current fragment is behind the other fragment it is discarded, otherwise overwritten. This process is called depth testing and is done automatically by OpenGL.

即使您使用的是 LWJGL,我也强烈建议您查看 learnopengl.com,因为您可以在那里找到的大部分内容也适用于它。