I am not using GLU for perspective calculation because I need to do my frustum culling with the exact matrix that we use to render. But I am doing something wrong as it is slightly squishing my perspective from top to bottom.
public void perspective(float fovx, float aspect, float zNear, float zFar)
{
float sine, cotangent, deltaZ;
float radians = fovx / 2 * (float)Math.PI / 180;
deltaZ = zNear - zFar;
sine = (float)Math.sin(radians);
if ((deltaZ == 0) || (sine == 0) || (aspect == 0)) {
return;
}
cotangent = (float)Math.cos(radians) / sine;
setZero();
matrix.m00 = cotangent / aspect;
matrix.m11 = cotangent;
matrix.m22 = (zFar + zNear) / deltaZ;
matrix.m23 = -1;
matrix.m32 = 2 * zNear * zFar / deltaZ;
}
Any transformation wizards out there that could point out my mistake?