1 #include <glm/ext/matrix_relational.hpp>
2 #include <glm/ext/matrix_double2x2.hpp>
3 #include <glm/ext/matrix_double2x3.hpp>
4 #include <glm/ext/matrix_double2x4.hpp>
5 #include <glm/ext/matrix_double3x2.hpp>
6 #include <glm/ext/matrix_double3x3.hpp>
7 #include <glm/ext/matrix_double3x4.hpp>
8 #include <glm/ext/matrix_double4x2.hpp>
9 #include <glm/ext/matrix_double4x3.hpp>
10 #include <glm/ext/matrix_double4x4.hpp>
11 #include <glm/ext/vector_double2.hpp>
12 #include <glm/ext/vector_double3.hpp>
13 #include <glm/ext/vector_double4.hpp>
14 #include <glm/ext/matrix_float2x2.hpp>
15 #include <glm/ext/matrix_float2x3.hpp>
16 #include <glm/ext/matrix_float2x4.hpp>
17 #include <glm/ext/matrix_float3x2.hpp>
18 #include <glm/ext/matrix_float3x3.hpp>
19 #include <glm/ext/matrix_float3x4.hpp>
20 #include <glm/ext/matrix_float4x2.hpp>
21 #include <glm/ext/matrix_float4x3.hpp>
22 #include <glm/ext/matrix_float4x4.hpp>
23 #include <glm/ext/vector_float2.hpp>
24 #include <glm/ext/vector_float3.hpp>
25 #include <glm/ext/vector_float4.hpp>
26 #include <glm/ext/scalar_ulp.hpp>
27 
28 template <typename matType, typename vecType>
test_equal()29 static int test_equal()
30 {
31 	typedef typename matType::value_type valType;
32 
33 	valType const Epsilon = static_cast<valType>(0.001f);
34 	valType const One = static_cast<valType>(1);
35 	valType const Two = static_cast<valType>(2);
36 
37 	int Error = 0;
38 
39 	Error += glm::all(glm::equal(matType(One), matType(One), Epsilon)) ? 0 : 1;
40 	Error += glm::all(glm::equal(matType(One), matType(Two), vecType(Epsilon))) ? 1 : 0;
41 
42 	return Error;
43 }
44 
45 template <typename matType, typename vecType>
test_notEqual()46 static int test_notEqual()
47 {
48 	typedef typename matType::value_type valType;
49 
50 	valType const Epsilon = static_cast<valType>(0.001f);
51 	valType const One = static_cast<valType>(1);
52 	valType const Two = static_cast<valType>(2);
53 
54 	int Error = 0;
55 
56 	Error += !glm::any(glm::notEqual(matType(One), matType(One), Epsilon)) ? 0 : 1;
57 	Error += !glm::any(glm::notEqual(matType(One), matType(Two), vecType(Epsilon))) ? 1 : 0;
58 
59 	return Error;
60 }
61 
62 
63 template <typename T>
test_equal_ulps()64 static int test_equal_ulps()
65 {
66 	typedef glm::mat<4, 4, T, glm::defaultp> mat4;
67 
68 	T const One(1);
69 	mat4 const Ones(1);
70 
71 	int Error = 0;
72 
73 	T const ULP1Plus = glm::nextFloat(One);
74 	Error += glm::all(glm::equal(Ones, mat4(ULP1Plus), 1)) ? 0 : 1;
75 
76 	T const ULP2Plus = glm::nextFloat(ULP1Plus);
77 	Error += !glm::all(glm::equal(Ones, mat4(ULP2Plus), 1)) ? 0 : 1;
78 
79 	T const ULP1Minus = glm::prevFloat(One);
80 	Error += glm::all(glm::equal(Ones, mat4(ULP1Minus), 1)) ? 0 : 1;
81 
82 	T const ULP2Minus = glm::prevFloat(ULP1Minus);
83 	Error += !glm::all(glm::equal(Ones, mat4(ULP2Minus), 1)) ? 0 : 1;
84 
85 	return Error;
86 }
87 
88 template <typename T>
test_notEqual_ulps()89 static int test_notEqual_ulps()
90 {
91 	typedef glm::mat<4, 4, T, glm::defaultp> mat4;
92 
93 	T const One(1);
94 	mat4 const Ones(1);
95 
96 	int Error = 0;
97 
98 	T const ULP1Plus = glm::nextFloat(One);
99 	Error += !glm::all(glm::notEqual(Ones, mat4(ULP1Plus), 1)) ? 0 : 1;
100 
101 	T const ULP2Plus = glm::nextFloat(ULP1Plus);
102 	Error += glm::all(glm::notEqual(Ones, mat4(ULP2Plus), 1)) ? 0 : 1;
103 
104 	T const ULP1Minus = glm::prevFloat(One);
105 	Error += !glm::all(glm::notEqual(Ones, mat4(ULP1Minus), 1)) ? 0 : 1;
106 
107 	T const ULP2Minus = glm::prevFloat(ULP1Minus);
108 	Error += glm::all(glm::notEqual(Ones, mat4(ULP2Minus), 1)) ? 0 : 1;
109 
110 	return Error;
111 }
112 
main()113 int main()
114 {
115 	int Error = 0;
116 
117 	Error += test_equal_ulps<float>();
118 	Error += test_equal_ulps<double>();
119 	Error += test_notEqual_ulps<float>();
120 	Error += test_notEqual_ulps<double>();
121 
122 	Error += test_equal<glm::mat2x2, glm::vec2>();
123 	Error += test_equal<glm::mat2x3, glm::vec2>();
124 	Error += test_equal<glm::mat2x4, glm::vec2>();
125 	Error += test_equal<glm::mat3x2, glm::vec3>();
126 	Error += test_equal<glm::mat3x3, glm::vec3>();
127 	Error += test_equal<glm::mat3x4, glm::vec3>();
128 	Error += test_equal<glm::mat4x2, glm::vec4>();
129 	Error += test_equal<glm::mat4x3, glm::vec4>();
130 	Error += test_equal<glm::mat4x4, glm::vec4>();
131 
132 	Error += test_equal<glm::dmat2x2, glm::dvec2>();
133 	Error += test_equal<glm::dmat2x3, glm::dvec2>();
134 	Error += test_equal<glm::dmat2x4, glm::dvec2>();
135 	Error += test_equal<glm::dmat3x2, glm::dvec3>();
136 	Error += test_equal<glm::dmat3x3, glm::dvec3>();
137 	Error += test_equal<glm::dmat3x4, glm::dvec3>();
138 	Error += test_equal<glm::dmat4x2, glm::dvec4>();
139 	Error += test_equal<glm::dmat4x3, glm::dvec4>();
140 	Error += test_equal<glm::dmat4x4, glm::dvec4>();
141 
142 	Error += test_notEqual<glm::mat2x2, glm::vec2>();
143 	Error += test_notEqual<glm::mat2x3, glm::vec2>();
144 	Error += test_notEqual<glm::mat2x4, glm::vec2>();
145 	Error += test_notEqual<glm::mat3x2, glm::vec3>();
146 	Error += test_notEqual<glm::mat3x3, glm::vec3>();
147 	Error += test_notEqual<glm::mat3x4, glm::vec3>();
148 	Error += test_notEqual<glm::mat4x2, glm::vec4>();
149 	Error += test_notEqual<glm::mat4x3, glm::vec4>();
150 	Error += test_notEqual<glm::mat4x4, glm::vec4>();
151 
152 	Error += test_notEqual<glm::dmat2x2, glm::dvec2>();
153 	Error += test_notEqual<glm::dmat2x3, glm::dvec2>();
154 	Error += test_notEqual<glm::dmat2x4, glm::dvec2>();
155 	Error += test_notEqual<glm::dmat3x2, glm::dvec3>();
156 	Error += test_notEqual<glm::dmat3x3, glm::dvec3>();
157 	Error += test_notEqual<glm::dmat3x4, glm::dvec3>();
158 	Error += test_notEqual<glm::dmat4x2, glm::dvec4>();
159 	Error += test_notEqual<glm::dmat4x3, glm::dvec4>();
160 	Error += test_notEqual<glm::dmat4x4, glm::dvec4>();
161 
162 	return Error;
163 }
164