tests: fix compilation errors

This commit is contained in:
Philippe Renon 2020-10-12 15:29:20 +02:00
parent f6de5146b0
commit 6eba88fa2d
4 changed files with 14 additions and 13 deletions

View File

@ -2,7 +2,7 @@
extern crate nalgebra as na;
use na::{Isometry3, Perspective3, Point3, Vector3};
use na::{Isometry3, OpenGL, Perspective3, Point3, Vector3};
fn main() {
// Our object is translated along the x axis.
@ -15,7 +15,7 @@ fn main() {
let view = Isometry3::look_at_rh(&eye, &target, &Vector3::y());
// A perspective projection.
let projection = Perspective3::new(16.0 / 9.0, 3.14 / 2.0, 1.0, 1000.0);
let projection = Perspective3::<OpenGL>::new(16.0 / 9.0, 3.14 / 2.0, 1.0, 1000.0);
// The combination of the model with the view is still an isometry.
let model_view = view * model;

View File

@ -2,10 +2,10 @@
extern crate nalgebra as na;
use na::{Perspective3, Point2, Point3, Unit};
use na::{OpenGL, Perspective3, Point2, Point3, Unit};
fn main() {
let projection = Perspective3::new(800.0 / 600.0, 3.14 / 2.0, 1.0, 1000.0);
let projection = Perspective3::<OpenGL>::new(800.0 / 600.0, 3.14 / 2.0, 1.0, 1000.0);
let screen_point = Point2::new(10.0f32, 20.0);
// Compute two points in clip-space.

View File

@ -3,8 +3,7 @@ extern crate nalgebra_glm as glm;
use glm::Mat4;
use glm::Vec4;
use na::Orthographic3;
use na::Perspective3;
use na::{OpenGL, Orthographic3, Perspective3};
#[test]
pub fn orthographic_glm_nalgebra_same() {
@ -18,7 +17,8 @@ pub fn orthographic_glm_nalgebra_same() {
#[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).into_inner();
Perspective3::<OpenGL>::new(16.0f32 / 9.0f32, 3.14f32 / 2.0f32, 0.1f32, 100.0f32)
.into_inner();
let gl_mat: Mat4 = glm::perspective(16.0f32 / 9.0f32, 3.14f32 / 2.0f32, 0.1f32, 100.0f32);
assert_eq!(na_mat, gl_mat);
@ -44,7 +44,8 @@ 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).into_inner();
Perspective3::<OpenGL>::new(16.0f32 / 9.0f32, 3.14f32 / 2.0f32, 0.1f32, 100.0f32)
.into_inner();
let gl_mat: Mat4 = glm::perspective(16.0f32 / 9.0f32, 3.14f32 / 2.0f32, 0.1f32, 100.0f32);
let na_pt = na_mat * point;

View File

@ -1,8 +1,8 @@
use na::{Orthographic3, Perspective3, Point3};
use na::{OpenGL, Orthographic3, Perspective3, Point3};
#[test]
fn perspective_inverse() {
let proj = Perspective3::new(800.0 / 600.0, 3.14 / 2.0, 1.0, 1000.0);
let proj = Perspective3::<OpenGL>::new(800.0 / 600.0, 3.14 / 2.0, 1.0, 1000.0);
let inv = proj.inverse();
let id = inv * proj.into_inner();
@ -23,7 +23,7 @@ fn orthographic_inverse() {
#[test]
fn perspective_matrix_point_transformation() {
// https://github.com/rustsim/nalgebra/issues/640
let proj = Perspective3::new(4.0 / 3.0, 90.0, 0.1, 100.0);
let proj = Perspective3::<OpenGL>::new(4.0 / 3.0, 90.0, 0.1, 100.0);
let perspective_inv = proj.as_matrix().try_inverse().unwrap();
let some_point = Point3::new(1.0, 2.0, 0.0);
@ -35,11 +35,11 @@ fn perspective_matrix_point_transformation() {
#[cfg(feature = "arbitrary")]
mod quickcheck_tests {
use na::{Orthographic3, Perspective3, Point3};
use na::{OpenGL, Orthographic3, Perspective3, Point3};
quickcheck! {
fn perspective_project_unproject(pt: Point3<f64>) -> bool {
let proj = Perspective3::new(800.0 / 600.0, 3.14 / 2.0, 1.0, 1000.0);
let proj = Perspective3::<OpenGL, f64>::new(800.0 / 600.0, 3.14 / 2.0, 1.0, 1000.0);
let projected = proj.project_point(&pt);
let unprojected = proj.unproject_point(&projected);