# OpenGL: strange thing with depth and text rendering

TL;DR I render a scene with M,V,P matrices as always. Than I render something (in this case - text) without any matrices and using separate shaders pair on coordinates with Z = -1. Somehow it's rendered closer to the camera than something on coordinates with Z = 0.9. I can't understand why.

Here is something I can't figure out.

Consider this vertex shader which is used for text rendering:

#version 330 core

layout(location = 0) in vec2 vertexPos;
layout(location = 1) in vec2 vertexUV;

out vec2 fragmentUV;

void main() {
fragmentUV = vertexUV;

gl_Position.x = vertexPos.x*2 - 1;
gl_Position.y = vertexPos.y*2 - 1;
gl_Position.z = -1.0;
gl_Position.w =  1.0;
}


When text is rendered with Z = -1 everything looks fine:

And if I change Z to 0.9 scene looks like this:

According to this tutorial perspective matrix modifies the scene so that all visible objects are in cube where -1 <= {X,Y,Z} <= 1. Also by default camera looks "down" towards Z axis.

So shouldn't it be conversely: larger Z - closer to the camera?

Full source code is on GitHub. Here is a code which renders text. And this code fills corresponding VBO.