projection_test.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. //Copyright (c) 2008-2016 Emil Dotchevski and Reverge Studios, Inc.
  2. //Distributed under the Boost Software License, Version 1.0. (See accompanying
  3. //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  4. #include <boost/qvm/mat_operations.hpp>
  5. #include "test_qvm_matrix.hpp"
  6. #include "gold.hpp"
  7. namespace
  8. {
  9. template <class T>
  10. void
  11. test_perspective_lh( T fov_y, T aspect_ratio, T z_near, T z_far )
  12. {
  13. using namespace boost::qvm;
  14. test_qvm::matrix<M1,4,4> const m=perspective_lh(fov_y,aspect_ratio,z_near,z_far);
  15. test_qvm::matrix_perspective_lh(m.b,fov_y,aspect_ratio,z_near,z_far);
  16. BOOST_QVM_TEST_CLOSE(m.a,m.b,0.000001f);
  17. }
  18. template <class T>
  19. void
  20. test_perspective_rh( T fov_y, T aspect_ratio, T z_near, T z_far )
  21. {
  22. using namespace boost::qvm;
  23. test_qvm::matrix<M1,4,4> const m=perspective_rh(fov_y,aspect_ratio,z_near,z_far);
  24. test_qvm::matrix_perspective_rh(m.b,fov_y,aspect_ratio,z_near,z_far);
  25. BOOST_QVM_TEST_CLOSE(m.a,m.b,0.000001f);
  26. }
  27. }
  28. int
  29. main()
  30. {
  31. test_perspective_lh(0.5f,1.3f,0.1f,2000.0f);
  32. test_perspective_rh(0.5f,1.3f,0.1f,2000.0f);
  33. return boost::report_errors();
  34. }