I'm having trouble with z buffering, in my application it seems that the z values of fragments coming out of the vertex shader are the wrong way around, and this is effectively causing the scene to draw the 'wrong' way around, with fragments further away drawing over the top of fragments closer.

Below is my vertex shader:

Code :
attribute vec4 vPosition;
attribute vec4 vColor;
attribute vec4 vTexture;
uniform mat4 u_modelMatrix;
uniform mat4 u_projectionMatrix;
uniform mat4 u_textureMatrix;
varying vec2 a_texCord;
varying vec4 aColor;
void main()
{
   vec4 transformCord = u_textureMatrix * vTexture;"
   gl_Position = u_projectionMatrix * u_modelMatrix * vPosition;
   aColor = vColor;
   a_texCord = transformCord.xy;
}

I simply added the line: gl_Position.z = -gl_Position.z; and this inverts the z values and causes the scene to draw properly. This however, is only fixing the symptom, and as DepthFunc is set to LEQUAL i guess the problem can only be in the projection/modelview matrix? Anyone have any ideas on how to flip the z axis in either of these to produce the same result as flipping it here? The maths is a little confusing and nothing i try in either the projection or model view matrix solve the issue. Is this the only place to really fix the problem?