From 5cf091656d8f9c1b50d32b1db336dda19c6ba020 Mon Sep 17 00:00:00 2001 From: Mikko Perttunen Date: Sun, 7 Apr 2013 12:55:03 +0300 Subject: [PATCH] Fix projection::perspective. --- src/projection.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/projection.rs b/src/projection.rs index f05ef67..d79b1f7 100644 --- a/src/projection.rs +++ b/src/projection.rs @@ -8,12 +8,16 @@ use mat::{Mat4, BaseMat4}; /** * Create a perspective projection matrix * + * Note: the fovy parameter should be specified in degrees. + * * This is the equivalent of the gluPerspective function, the algorithm of which * can be found [here](http://www.opengl.org/wiki/GluPerspective_code). */ #[inline(always)] pub fn perspective + Add + Sub + Mul + Div + Neg>(fovy: T, aspectRatio: T, near: T, far: T) -> Mat4 { - let ymax = near * tan(radians(fovy)); + let _2: T = num::cast(2); + + let ymax = near * tan(radians(fovy / _2)); let xmax = ymax * aspectRatio; frustum(-xmax, xmax, -ymax, ymax, near, far)