At which stage OpenGL goes left-handed?

Viewed 76

I know that OpenGL operate in right-handed mode in user space (in fact it don't care about in which system we work) and only goes left-handed after every user stage is completed. learnopengl says (emphasize mine)

Note that in normalized device coordinates OpenGL actually uses a left-handed system (the projection matrix switches the handedness).

However, I can't see how this statement could be true. With this simple example: let's say ModelViewProjection = Identity, the projection matrix does nothing so the final vertex is still right-handed.

If we test it, we can see that a an object rendered at a z = -0.5 will be hidden by another object at a z = -0.1, which should mean that that clip space is still right-handed, right?

1 Answers

The normalized device space and clip space are left handed. The clipping rule is -w <= x, y, z <= w. That the model and view coordinate systems are usually right-handed is just common convection. But "OpenGL" is neither left- nor right-handed (except legacy OpenGL matrix functions produce right-handed matrices). Even OpenGL does not change the system. The usual orthographic or perspective projection matrix generated with glm::ortho or glm::perspective (or glOrtho, glFrustum) inverts the z-axis. That is, it turns a right-handed system into a left-handed system and a left-handed system into a right-handed system. Using the identity matrix for the projection matrix does not invert the z-axis and does not change the system.
However, whether an object is occluded by another object depends on the Depth Test and the depth function.

Related