Page 1 of 1

Perspective Projection acting Orthographic?[SOLVED]

Posted: Wed Jun 25, 2014 8:57 pm
by blueshackstudios
Hey all, I'm having an issue with my perspective projection matrix. It works, and things display properly except there is no perspective! It ends up being basically an Orthographic projection...

Any help would be appreciated!

Code: Select all

Matrix4 Matrix4::Perspective(real angle, real imageAspectRatio, real n, real f)
{
	real top = n * tan(Math::ToRadians(angle/2));
	real bottom = -top;
	real right = top*imageAspectRatio;
	real left = -right;

	return Matrix4(
		(2*n)/(right-left), 0.0, 0.0, 0.0,
		0.0, (2*n)/(top-bottom), 0.0, 0.0,
		(right+left)/(right-left), (top+bottom)/(top-bottom), (-(f+n)/(f-n)), -1,
		0.0, 0.0, (-2*f*n)/(f-n), 0.0
		);
}
I'm using OpenGL with a right-handed setup. Also, all my matrices are transposed when passed to GL.

EDIT: Sorry guys, It actually ended up working fine, but another matrix was being multiplied into it on accident. Whoops.