Fix projection::perspective.
This commit is contained in:
parent
9116917607
commit
5cf091656d
1 changed files with 5 additions and 1 deletions
|
@ -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<T:Copy + Float + Zero + One + FuzzyEq<T> + Add<T,T> + Sub<T,T> + Mul<T,T> + Div<T,T> + Neg<T>>(fovy: T, aspectRatio: T, near: T, far: T) -> Mat4<T> {
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue