Browse Source

Fixed compile problems with glm::max( vec, int ) #232

Christophe Riccio 11 years ago
parent
commit
e419448539
2 changed files with 62 additions and 4 deletions
  1. 4 4
      glm/detail/_vectorize.hpp
  2. 58 0
      test/core/core_func_common.cpp

+ 4 - 4
glm/detail/_vectorize.hpp

@@ -86,7 +86,7 @@
 	GLM_FUNC_QUALIFIER detail::tvec1<T, P> func				\
 	(														\
 		detail::tvec1<T, P> const & x,						\
-		T const & y											\
+		typename detail::tvec1<T, P>::value_type const & y	\
 	)														\
 	{														\
 		return detail::tvec1<T, P>(							\
@@ -98,7 +98,7 @@
 	GLM_FUNC_QUALIFIER detail::tvec2<T, P> func				\
 	(														\
 		detail::tvec2<T, P> const & x,						\
-		T const & y	\
+		typename detail::tvec2<T, P>::value_type const & y	\
 	)														\
 	{														\
 		return detail::tvec2<T, P>(							\
@@ -111,7 +111,7 @@
 	GLM_FUNC_QUALIFIER detail::tvec3<T, P> func				\
 	(														\
 		detail::tvec3<T, P> const & x,						\
-		T const & y	\
+		typename detail::tvec3<T, P>::value_type const & y	\
 	)														\
 	{														\
 		return detail::tvec3<T, P>(							\
@@ -125,7 +125,7 @@
 	GLM_FUNC_QUALIFIER detail::tvec4<T, P> func				\
 	(														\
 		detail::tvec4<T, P> const & x,						\
-		T const & y	\
+		typename detail::tvec4<T, P>::value_type const & y	\
 	)														\
 	{														\
 		return detail::tvec4<T, P>(							\

+ 58 - 0
test/core/core_func_common.cpp

@@ -12,6 +12,7 @@
 //#include <boost/thread/thread.hpp>
 #include <glm/gtc/constants.hpp>
 #include <glm/gtc/epsilon.hpp>
+#include <glm/gtx/vec1.hpp>
 #include <cstdio>
 #include <cmath>
 
@@ -149,6 +150,61 @@ int test_floatBitsToUint()
 	return Error;
 }
 
+int test_min()
+{
+	int Error = 0;
+
+	glm::vec1 A0 = glm::min(glm::vec1(1), glm::vec1(1));
+
+	glm::vec2 B0 = glm::min(glm::vec2(1), glm::vec2(1));
+	glm::vec2 B1 = glm::min(glm::vec2(1), 1.0f);
+	bool B2 = glm::all(glm::equal(B0, B1));
+	Error += B2 ? 0 : 1;
+
+	glm::vec3 C0 = glm::min(glm::vec3(1), glm::vec3(1));
+	glm::vec3 C1 = glm::min(glm::vec3(1), 1.0f);
+	bool C2 = glm::all(glm::equal(C0, C1));
+	Error += C2 ? 0 : 1;
+
+	glm::vec4 D0 = glm::min(glm::vec4(1), glm::vec4(1));
+	glm::vec4 D1 = glm::min(glm::vec4(1), 1.0f);
+	bool D2 = glm::all(glm::equal(D0, D1));
+	Error += D2 ? 0 : 1;
+
+	return Error;
+}
+
+int test_max()
+{
+	int Error = 0;
+
+	glm::vec1 A0 = glm::max(glm::vec1(1), glm::vec1(1));
+
+	glm::vec2 B0 = glm::max(glm::vec2(1), glm::vec2(1));
+	glm::vec2 B1 = glm::max(glm::vec2(1), 1.0f);
+	bool B2 = glm::all(glm::equal(B0, B1));
+	Error += B2 ? 0 : 1;
+
+	glm::vec3 C0 = glm::max(glm::vec3(1), glm::vec3(1));
+	glm::vec3 C1 = glm::max(glm::vec3(1), 1.0f);
+	bool C2 = glm::all(glm::equal(C0, C1));
+	Error += C2 ? 0 : 1;
+
+	glm::vec4 D0 = glm::max(glm::vec4(1), glm::vec4(1));
+	glm::vec4 D1 = glm::max(glm::vec4(1), 1.0f);
+	bool D2 = glm::all(glm::equal(D0, D1));
+	Error += D2 ? 0 : 1;
+
+	return Error;
+}
+
+int test_clamp()
+{
+	int Error = 0;
+
+	return Error;
+}
+
 namespace test_mix
 {
 	template <typename T, typename B>
@@ -633,6 +689,8 @@ int main()
 	Error += test_floatBitsToInt();
 	Error += test_floatBitsToUint();
 	Error += test_step::run();
+	Error += test_max();
+	Error += test_min();
 	Error += test_mix::run();
 	Error += test_round();
 	Error += test_roundEven();