Perspective Projection acting Orthographic?[SOLVED]

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Perspective Projection acting Orthographic?[SOLVED]

Postby blueshackstudios on Wed Jun 25, 2014 9:57 pm

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.
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 5
Joined: Mon May 12, 2014 2:15 pm

Return to Programming Discussion

Who is online

Users browsing this forum: No registered users and 1 guest