The near plane clips at exactly the value I set just fine but instead of clipping at 1000 the far plane clips at 1.
Here is the code for the projection matrix:
public static Matrix4f perspective(Matrix4f dest, float fov, float aspectRatio, float near, float far) {
if (dest == null)
dest = new Matrix4f();
float tanHalfFOV = (float) Math.tan(fov / 2);
float range = near - far;
dest.m00 = 1.0f / (tanHalfFOV * aspectRatio);
dest.m10 = 0;
dest.m20 = 0;
dest.m30 = 0;
dest.m01 = 0;
dest.m11 = 1.0f / tanHalfFOV;
dest.m21 = 0;
dest.m31 = 0;
dest.m02 = 0;
dest.m12 = 0;
dest.m22 = (-near - far) / range;
dest.m32 = 2 * far * near / range;
dest.m03 = 0;
dest.m13 = 0;
dest.m23 = 1;
dest.m33 = 0;
return dest;
}
The near plane is 0.1 and the far plane is supposed to be 1000.