Browse Source

Fixed GCC build

Christophe Riccio 11 years ago
parent
commit
41c00872a1

+ 20 - 14
glm/detail/func_common.hpp

@@ -54,23 +54,26 @@ namespace glm
 	template <typename genType>
 	GLM_FUNC_DECL genType abs(genType x);
 
+	template <typename T, precision P, template <typename, precision> class vecType>
+	GLM_FUNC_DECL vecType<T, P> abs(vecType<T, P> const & x);
+
 	/// Returns 1.0 if x > 0, 0.0 if x == 0, or -1.0 if x < 0. 
 	/// 
 	/// @tparam genType Floating-point or signed integer; scalar or vector types.
 	/// 
 	/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/sign.xml">GLSL sign man page</a>
 	/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
-	template <typename genType>
-	GLM_FUNC_DECL genType sign(genType x);
-	
+	template <typename T, precision P, template <typename, precision> class vecType>
+	GLM_FUNC_DECL vecType<T, P> sign(vecType<T, P> const & x);
+
 	/// Returns a value equal to the nearest integer that is less then or equal to x. 
 	/// 
 	/// @tparam genType Floating-point scalar or vector types.
 	/// 
 	/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/floor.xml">GLSL floor man page</a>
 	/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
-	template <typename genType>
-	GLM_FUNC_DECL genType floor(genType x);
+	template <typename T, precision P, template <typename, precision> class vecType>
+	GLM_FUNC_DECL vecType<T, P> floor(vecType<T, P> const & x);
 
 	/// Returns a value equal to the nearest integer to x
 	/// whose absolute value is not larger than the absolute value of x.
@@ -79,8 +82,8 @@ namespace glm
 	/// 
 	/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/trunc.xml">GLSL trunc man page</a>
 	/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
-	template <typename genType>
-	GLM_FUNC_DECL genType trunc(genType x);
+	template <typename T, precision P, template <typename, precision> class vecType>
+	GLM_FUNC_DECL vecType<T, P> trunc(vecType<T, P> const & x);
 
 	/// Returns a value equal to the nearest integer to x.
 	/// The fraction 0.5 will round in a direction chosen by the
@@ -92,9 +95,9 @@ namespace glm
 	/// 
 	/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/round.xml">GLSL round man page</a>
 	/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
-	template <typename genType>
-	GLM_FUNC_DECL genType round(genType x);
-	
+	template <typename T, precision P, template <typename, precision> class vecType>
+	GLM_FUNC_DECL vecType<T, P> round(vecType<T, P> const & x);
+
 	/// Returns a value equal to the nearest integer to x.
 	/// A fractional part of 0.5 will round toward the nearest even
 	/// integer. (Both 3.5 and 4.5 for x will return 4.0.)
@@ -104,8 +107,8 @@ namespace glm
 	/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/roundEven.xml">GLSL roundEven man page</a>
 	/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
 	/// @see <a href="http://developer.amd.com/documentation/articles/pages/New-Round-to-Even-Technique.aspx">New round to even technique</a>
-	template <typename genType>
-	GLM_FUNC_DECL genType roundEven(genType x);
+	template <typename T, precision P, template <typename, precision> class vecType>
+	GLM_FUNC_DECL vecType<T, P> roundEven(vecType<T, P> const & x);
 
 	/// Returns a value equal to the nearest integer
 	/// that is greater than or equal to x.
@@ -114,8 +117,8 @@ namespace glm
 	///
 	/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/ceil.xml">GLSL ceil man page</a>
 	/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
-	template <typename genType>
-	GLM_FUNC_DECL genType ceil(genType x);
+	template <typename T, precision P, template <typename, precision> class vecType>
+	GLM_FUNC_DECL vecType<T, P> ceil(vecType<T, P> const & x);
 
 	/// Return x - floor(x).
 	/// 
@@ -126,6 +129,9 @@ namespace glm
 	template <typename genType>
 	GLM_FUNC_DECL genType fract(genType x);
 
+	template <typename T, precision P, template <typename, precision> class vecType>
+	GLM_FUNC_DECL vecType<T, P> fract(vecType<T, P> const & x);
+
 	/// Modulus. Returns x - y * floor(x / y)
 	/// for each component in x using the floating point value y.
 	///

+ 0 - 2
glm/detail/func_common.inl

@@ -177,7 +177,6 @@ namespace detail
 
 	// floor
 	using ::std::floor;
-
 	template <typename T, precision P, template <typename, precision> class vecType>
 	GLM_FUNC_QUALIFIER vecType<T, P> floor(vecType<T, P> const & x)
 	{
@@ -273,7 +272,6 @@ namespace detail
 
 	// ceil
 	using ::std::ceil;
-
 	template <typename T, precision P, template <typename, precision> class vecType>
 	GLM_FUNC_QUALIFIER vecType<T, P> ceil(vecType<T, P> const & x)
 	{

+ 1 - 2
glm/detail/setup.hpp

@@ -517,10 +517,9 @@
 	((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC43)))
 
 #define GLM_HAS_TEMPLATE_ALIASES ( \
-	(GLM_LANG & GLM_LANG_CXX11_FLAG) || \
 	((GLM_LANG & GLM_LANG_CXX0X_FLAG) && ((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC12))) || \
-	((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC47)) || \
 	__has_feature(cxx_alias_templates))
+	//((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC47)) || \
 
 #define GLM_HAS_RANGE_FOR ( \
 	(GLM_LANG & GLM_LANG_CXX11_FLAG) || \

+ 7 - 7
glm/detail/type_vec4.inl

@@ -69,7 +69,7 @@ namespace glm
 #		endif
 	{}
 
-#if (GLM_HAS_UNRESTRICTED_UNIONS || GLM_HAS_ANONYMOUS_UNION) && (GLM_ARCH & GLM_ARCH_SSE2)
+#if GLM_HAS_ANONYMOUS_UNION && (GLM_ARCH & GLM_ARCH_SSE2)
 	template <>
 	GLM_FUNC_QUALIFIER tvec4<float, lowp>::tvec4()
 #		ifndef GLM_FORCE_NO_CTOR_INIT 
@@ -90,7 +90,7 @@ namespace glm
 		: x(v.x), y(v.y), z(v.z), w(v.w)
 	{}
 
-#if (GLM_HAS_UNRESTRICTED_UNIONS || GLM_HAS_ANONYMOUS_UNION) && (GLM_ARCH & GLM_ARCH_SSE2)
+#if GLM_HAS_ANONYMOUS_UNION && (GLM_ARCH & GLM_ARCH_SSE2)
 	template <>
 	GLM_FUNC_QUALIFIER tvec4<float, lowp>::tvec4(tvec4<float, lowp> const & v)
 		: data(v.data)
@@ -120,7 +120,7 @@ namespace glm
 		: x(s), y(s), z(s), w(s)
 	{}
 
-#if (GLM_HAS_UNRESTRICTED_UNIONS || GLM_HAS_ANONYMOUS_UNION) && (GLM_ARCH & GLM_ARCH_SSE2)
+#if GLM_HAS_ANONYMOUS_UNION && (GLM_ARCH & GLM_ARCH_SSE2)
 	template <>
 	GLM_FUNC_QUALIFIER tvec4<float, lowp>::tvec4(float const & s) :
 		data(_mm_set1_ps(s))
@@ -137,7 +137,7 @@ namespace glm
 		: x(a), y(b), z(c),	w(d)
 	{}
 
-#if (GLM_HAS_UNRESTRICTED_UNIONS || GLM_HAS_ANONYMOUS_UNION) && (GLM_ARCH & GLM_ARCH_SSE2)
+#if GLM_HAS_ANONYMOUS_UNION && (GLM_ARCH & GLM_ARCH_SSE2)
 	template <>
 	GLM_FUNC_QUALIFIER tvec4<float, lowp>::tvec4(float const & a, float const & b, float const & c, float const & d) :
 		data(_mm_set_ps(d, c, b, a))
@@ -294,7 +294,7 @@ namespace glm
 		return *this;
 	}
 
-#if (GLM_HAS_UNRESTRICTED_UNIONS || GLM_HAS_ANONYMOUS_UNION) && (GLM_ARCH & GLM_ARCH_SSE2)
+#if GLM_HAS_ANONYMOUS_UNION && (GLM_ARCH & GLM_ARCH_SSE2)
 	template <>
 	GLM_FUNC_QUALIFIER tvec4<float, lowp> & tvec4<float, lowp>::operator= (tvec4<float, lowp> const & v)
 	{
@@ -332,7 +332,7 @@ namespace glm
 		return *this;
 	}
 
-#if (GLM_HAS_UNRESTRICTED_UNIONS || GLM_HAS_ANONYMOUS_UNION) && (GLM_ARCH & GLM_ARCH_SSE2)
+#if GLM_HAS_ANONYMOUS_UNION && (GLM_ARCH & GLM_ARCH_SSE2)
 	template <>
 	template <typename U>
 	GLM_FUNC_QUALIFIER tvec4<float, lowp> & tvec4<float, lowp>::operator+=(U s)
@@ -377,7 +377,7 @@ namespace glm
 		return *this;
 	}
 
-#if (GLM_HAS_UNRESTRICTED_UNIONS || GLM_HAS_ANONYMOUS_UNION) && (GLM_ARCH & GLM_ARCH_SSE2)
+#if GLM_HAS_ANONYMOUS_UNION && (GLM_ARCH & GLM_ARCH_SSE2)
 	template <>
 	template <typename U>
 	GLM_FUNC_QUALIFIER tvec4<float, lowp> & tvec4<float, lowp>::operator+=(tvec1<U, lowp> const & s)

+ 1 - 1
glm/gtc/random.inl

@@ -313,7 +313,7 @@ namespace detail
 	template <typename T, precision P, template <typename, precision> class vecType>
 	GLM_FUNC_QUALIFIER vecType<T, P> gaussRand(vecType<T, P> const & Mean, vecType<T, P> const & Deviation)
 	{
-		return detail::functor2<T, T, P, vecType>::call(gaussRand, Mean, Deviation);
+		return detail::functor2<T, P, vecType>::call(gaussRand, Mean, Deviation);
 	}
 
 	template <typename T>

+ 1 - 1
glm/gtx/fast_trigonometry.inl

@@ -85,7 +85,7 @@ namespace glm
 	template <typename T, precision P, template <typename, precision> class vecType>
 	GLM_FUNC_QUALIFIER vecType<T, P> fastAtan(vecType<T, P> const & y, vecType<T, P> const & x)
 	{
-		return detail::functor2<T, T, P, vecType>::call(fastAtan, y, x);
+		return detail::functor2<T, P, vecType>::call(fastAtan, y, x);
 	}
 
 	template <typename T> 

+ 2 - 2
glm/gtx/multiple.inl

@@ -123,7 +123,7 @@ namespace detail
 	template <typename T, precision P, template <typename, precision> class vecType>
 	GLM_FUNC_QUALIFIER vecType<T, P> higherMultiple(vecType<T, P> const & Source, vecType<T, P> const & Multiple)
 	{
-		return detail::functor2<T, T, P, vecType>::call(higherMultiple, Source, Multiple);
+		return detail::functor2<T, P, vecType>::call(higherMultiple, Source, Multiple);
 	}
 
 	//////////////////////
@@ -138,6 +138,6 @@ namespace detail
 	template <typename T, precision P, template <typename, precision> class vecType>
 	GLM_FUNC_QUALIFIER vecType<T, P> lowerMultiple(vecType<T, P> const & Source, vecType<T, P> const & Multiple)
 	{
-		return detail::functor2<T, T, P, vecType>::call(lowerMultiple, Source, Multiple);
+		return detail::functor2<T, P, vecType>::call(lowerMultiple, Source, Multiple);
 	}
 }//namespace glm

+ 3 - 3
glm/gtx/simd_vec4.inl

@@ -11,7 +11,7 @@ namespace glm{
 namespace detail{
 
 template <int Value>
-struct mask
+struct shuffle_mask
 {
 	enum{value = Value};
 };
@@ -166,7 +166,7 @@ GLM_FUNC_QUALIFIER fvec4SIMD fvec4SIMD::swizzle() const
 {
 	__m128 Data = _mm_shuffle_ps(
 		this->Data, this->Data, 
-		mask<(W << 6) | (Z << 4) | (Y << 2) | (X << 0)>::value);
+		shuffle_mask<(W << 6) | (Z << 4) | (Y << 2) | (X << 0)>::value);
 	return fvec4SIMD(Data);
 }
 
@@ -175,7 +175,7 @@ GLM_FUNC_QUALIFIER fvec4SIMD& fvec4SIMD::swizzle()
 {
 	this->Data = _mm_shuffle_ps(
 		this->Data, this->Data, 
-		mask<(W << 6) | (Z << 4) | (Y << 2) | (X << 0)>::value);
+		shuffle_mask<(W << 6) | (Z << 4) | (Y << 2) | (X << 0)>::value);
 	return *this;
 }
 

+ 3 - 1
test/gtc/gtc_bitfield.cpp

@@ -10,7 +10,9 @@
 #include <glm/gtc/bitfield.hpp>
 #include <glm/gtc/type_precision.hpp>
 #include <glm/vector_relational.hpp>
-//#include <glm/vec2.hpp>
+#if GLM_ARCH != GLM_ARCH_PURE
+#	include <glm/detail/intrinsic_integer.hpp>
+#endif
 #include <ctime>
 #include <cstdio>
 #include <vector>

+ 4 - 3
test/gtc/gtc_integer.cpp

@@ -10,8 +10,9 @@
 #include <glm/gtc/integer.hpp>
 #include <glm/gtc/type_precision.hpp>
 #include <glm/gtc/vec1.hpp>
-#include <ctime>
 #include <vector>
+#include <ctime>
+#include <cstdio>
 
 namespace isPowerOfTwo
 {
@@ -254,8 +255,8 @@ namespace ceilPowerOfTwo
 
 		std::clock_t Timestramp2 = std::clock();
 
-		printf("ceilPowerOfTwo_loop: %d clocks\n", Timestramp1 - Timestramp0);
-		printf("glm::ceilPowerOfTwo: %d clocks\n", Timestramp2 - Timestramp1);
+		std::printf("ceilPowerOfTwo_loop: %d clocks\n", static_cast<unsigned int>(Timestramp1 - Timestramp0));
+		std::printf("glm::ceilPowerOfTwo: %d clocks\n", static_cast<unsigned int>(Timestramp2 - Timestramp1));
 
 		return Error;
 	}

+ 38 - 0
test/gtx/gtx_multiple.cpp

@@ -9,6 +9,42 @@
 
 #include <glm/gtx/multiple.hpp>
 
+int test_higher_uint()
+{
+	int Error(0);
+
+	Error += glm::all(glm::equal(glm::higherMultiple(glm::uvec4(0), glm::uvec4(4)), glm::uvec4(0))) ? 0 : 1;
+	Error += glm::all(glm::equal(glm::higherMultiple(glm::uvec4(1), glm::uvec4(4)), glm::uvec4(4))) ? 0 : 1;
+	Error += glm::all(glm::equal(glm::higherMultiple(glm::uvec4(2), glm::uvec4(4)), glm::uvec4(4))) ? 0 : 1;
+	Error += glm::all(glm::equal(glm::higherMultiple(glm::uvec4(3), glm::uvec4(4)), glm::uvec4(4))) ? 0 : 1;
+	Error += glm::all(glm::equal(glm::higherMultiple(glm::uvec4(4), glm::uvec4(4)), glm::uvec4(4))) ? 0 : 1;
+	Error += glm::all(glm::equal(glm::higherMultiple(glm::uvec4(5), glm::uvec4(4)), glm::uvec4(8))) ? 0 : 1;
+	Error += glm::all(glm::equal(glm::higherMultiple(glm::uvec4(6), glm::uvec4(4)), glm::uvec4(8))) ? 0 : 1;
+	Error += glm::all(glm::equal(glm::higherMultiple(glm::uvec4(7), glm::uvec4(4)), glm::uvec4(8))) ? 0 : 1;
+	Error += glm::all(glm::equal(glm::higherMultiple(glm::uvec4(8), glm::uvec4(4)), glm::uvec4(8))) ? 0 : 1;
+	Error += glm::all(glm::equal(glm::higherMultiple(glm::uvec4(9), glm::uvec4(4)), glm::uvec4(12))) ? 0 : 1;
+
+	return Error;
+}
+
+int test_Lower_uint()
+{
+	int Error(0);
+
+	Error += glm::all(glm::equal(glm::lowerMultiple(glm::uvec4(0), glm::uvec4(4)), glm::uvec4(0))) ? 0 : 1;
+	Error += glm::all(glm::equal(glm::lowerMultiple(glm::uvec4(1), glm::uvec4(4)), glm::uvec4(0))) ? 0 : 1;
+	Error += glm::all(glm::equal(glm::lowerMultiple(glm::uvec4(2), glm::uvec4(4)), glm::uvec4(0))) ? 0 : 1;
+	Error += glm::all(glm::equal(glm::lowerMultiple(glm::uvec4(3), glm::uvec4(4)), glm::uvec4(0))) ? 0 : 1;
+	Error += glm::all(glm::equal(glm::lowerMultiple(glm::uvec4(4), glm::uvec4(4)), glm::uvec4(4))) ? 0 : 1;
+	Error += glm::all(glm::equal(glm::lowerMultiple(glm::uvec4(5), glm::uvec4(4)), glm::uvec4(4))) ? 0 : 1;
+	Error += glm::all(glm::equal(glm::lowerMultiple(glm::uvec4(6), glm::uvec4(4)), glm::uvec4(4))) ? 0 : 1;
+	Error += glm::all(glm::equal(glm::lowerMultiple(glm::uvec4(7), glm::uvec4(4)), glm::uvec4(4))) ? 0 : 1;
+	Error += glm::all(glm::equal(glm::lowerMultiple(glm::uvec4(8), glm::uvec4(4)), glm::uvec4(8))) ? 0 : 1;
+	Error += glm::all(glm::equal(glm::lowerMultiple(glm::uvec4(9), glm::uvec4(4)), glm::uvec4(8))) ? 0 : 1;
+
+	return Error;
+}
+
 int test_higher_int()
 {
 	int Error(0);
@@ -108,6 +144,8 @@ int main()
 
 	Error += test_higher_int();
 	Error += test_Lower_int();
+	Error += test_higher_uint();
+	Error += test_Lower_uint();
 	Error += test_higher_double();
 	Error += test_Lower_double();