PDA

View Full Version : what is the range of clipping space in OpenGL?



Sobeit
11-30-2012, 08:12 PM
I'm a beginner in opengl, and I enounter a problem concering about clipping space.
I read from opengl 4.0 reference that Values specified by glClearDepth are clamped to the range 0 1.
but the normilized device coordinate(NDC) has the rang [-1, 1] right?
My question: is the value of glClearDepth applied to NDC? if it is, then how could I clip the vertex with z value between [-1, 0]?

Alfonse Reinheart
11-30-2012, 10:44 PM
glViewport and glDepthRange define the extents of window-space, the space that comes after NDC space. The glClearDepth value is in window-space, not NDC space.

glDepthRange in particular defines the Z mapping from the [-1, 1] range to the user-defined depth range.

Sobeit
11-30-2012, 11:08 PM
as you mentioned window-space is a 3d coord, right? I thought it was mapped from ndc and was a 2d coord.

Alfonse Reinheart
12-01-2012, 09:21 AM
It is mapped from NDC space; NDC space is 3D as well. OpenGL never uses purely 2D coordinates for rendering. That's where the depth comes from.