2018-12-14 19:50:58 +08:00
|
|
|
extern crate nalgebra as na;
|
|
|
|
extern crate nalgebra_glm as glm;
|
|
|
|
|
|
|
|
use na::Perspective3;
|
|
|
|
use na::Orthographic3;
|
|
|
|
use glm::Mat4;
|
|
|
|
use glm::Vec4;
|
|
|
|
|
2018-12-14 20:03:13 +08:00
|
|
|
// Ensure that under default conditions the library doesn't break interface with old convention
|
2018-12-14 19:50:58 +08:00
|
|
|
#[test]
|
|
|
|
pub fn orthographic_glm_nalgebra_same()
|
|
|
|
{
|
|
|
|
let na_mat : Mat4 = Orthographic3::new(-100.0f32,100.0f32, -50.0f32, 50.0f32, 0.1f32, 100.0f32).unwrap();
|
|
|
|
let gl_mat : Mat4 = glm::ortho_rh_no(-100.0f32,100.0f32, -50.0f32, 50.0f32, 0.1f32, 100.0f32);
|
|
|
|
|
|
|
|
// ortho_rh_no is the same as the standard nalgebra orthographic matrix
|
|
|
|
//
|
|
|
|
// we cant use plain ortho here as the library could be configured to produce different values
|
|
|
|
|
|
|
|
assert_eq!(na_mat, gl_mat);
|
|
|
|
}
|
|
|
|
|
2018-12-14 20:03:13 +08:00
|
|
|
// Ensure that under default conditions the library doesn't break interface with old convention
|
2018-12-14 19:50:58 +08:00
|
|
|
#[test]
|
|
|
|
pub fn perspective_glm_nalgebra_same()
|
|
|
|
{
|
|
|
|
let na_mat : Mat4 = Perspective3::new(16.0f32/9.0f32, 3.14f32/2.0f32, 0.1f32, 100.0f32).unwrap();
|
|
|
|
let gl_mat : Mat4 = glm::perspective_rh_no(16.0f32/9.0f32, 3.14f32/2.0f32, 0.1f32, 100.0f32);
|
|
|
|
|
|
|
|
// perspective_rh_no is the same as the standard nalgebra perspective matrix
|
|
|
|
//
|
|
|
|
// we cant use plain perspective here as the library could be configured to produce different
|
|
|
|
// values
|
|
|
|
|
|
|
|
assert_eq!(na_mat, gl_mat);
|
|
|
|
}
|
|
|
|
|
2018-12-14 20:03:13 +08:00
|
|
|
// Ensure that under default conditions the library doesn't break interface with old convention
|
2018-12-14 19:50:58 +08:00
|
|
|
#[test]
|
|
|
|
pub fn orthographic_glm_nalgebra_project_same()
|
|
|
|
{
|
|
|
|
let point = Vec4::new(1.0,0.0,-20.0,1.0);
|
|
|
|
|
|
|
|
let na_mat : Mat4 = Orthographic3::new(-100.0f32,100.0f32, -50.0f32, 50.0f32, 0.1f32, 100.0f32).unwrap();
|
|
|
|
let gl_mat : Mat4 = glm::ortho_rh_no(-100.0f32,100.0f32, -50.0f32, 50.0f32, 0.1f32, 100.0f32);
|
|
|
|
|
|
|
|
// ortho_rh_no is the same as the standard nalgebra orthographic matrix
|
|
|
|
//
|
|
|
|
// we cant use plain ortho here as the library could be configured to produce different values
|
|
|
|
|
|
|
|
let na_pt = na_mat * point;
|
|
|
|
let gl_pt = gl_mat * point;
|
|
|
|
|
2018-12-14 20:03:13 +08:00
|
|
|
assert_eq!(na_mat, gl_mat);
|
2018-12-14 19:50:58 +08:00
|
|
|
assert_eq!(na_pt, gl_pt);
|
|
|
|
}
|
|
|
|
|
2018-12-14 20:03:13 +08:00
|
|
|
// Ensure that under default conditions the library doesn't break interface with old convention
|
2018-12-14 19:50:58 +08:00
|
|
|
#[test]
|
|
|
|
pub fn perspective_glm_nalgebra_project_same()
|
|
|
|
{
|
|
|
|
let point = Vec4::new(1.0,0.0,-20.0,1.0);
|
|
|
|
|
|
|
|
let na_mat : Mat4 = Perspective3::new(16.0f32/9.0f32, 3.14f32/2.0f32, 0.1f32, 100.0f32).unwrap();
|
|
|
|
let gl_mat : Mat4 = glm::perspective_rh_no(16.0f32/9.0f32, 3.14f32/2.0f32, 0.1f32, 100.0f32);
|
|
|
|
|
|
|
|
// perspective_rh_no is the same as the standard nalgebra perspective matrix
|
|
|
|
//
|
|
|
|
// we cant use plain perspective here as the library could be configured to produce different
|
|
|
|
// values
|
|
|
|
|
|
|
|
let na_pt = na_mat * point;
|
|
|
|
let gl_pt = gl_mat * point;
|
|
|
|
|
2018-12-14 20:03:13 +08:00
|
|
|
assert_eq!(na_mat, gl_mat);
|
2018-12-14 19:50:58 +08:00
|
|
|
assert_eq!(na_pt, gl_pt);
|
|
|
|
}
|