Browse Source

Fixed GTX_type_trait linking

Christophe Riccio 9 years ago
parent
commit
23ab8137f9
3 changed files with 140 additions and 170 deletions
  1. 13 13
      glm/gtx/io.inl
  2. 126 89
      glm/gtx/type_trait.hpp
  3. 1 68
      test/gtx/gtx_type_trait.cpp

+ 13 - 13
glm/gtx/io.inl

@@ -36,8 +36,8 @@
 #include "../gtx/type_trait.hpp"    // glm::type<>
 #include "../gtx/type_trait.hpp"    // glm::type<>
 
 
 namespace glm{
 namespace glm{
-  namespace io
-  {
+namespace io
+{
     template <typename CTy>
     template <typename CTy>
     /* explicit */ GLM_FUNC_QUALIFIER
     /* explicit */ GLM_FUNC_QUALIFIER
     format_punct<CTy>::format_punct(size_t a)
     format_punct<CTy>::format_punct(size_t a)
@@ -198,7 +198,7 @@ namespace glm{
         {
         {
           io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os));
           io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os));
 
 
-          length_t const& components(type<V>::components);
+          length_t const& components(type<V, T, P>::components);
           
           
           if(fmt.formatted)
           if(fmt.formatted)
             {
             {
@@ -210,7 +210,7 @@ namespace glm{
                  << std::setfill(fmt.space)
                  << std::setfill(fmt.space)
                  << fmt.delim_left;
                  << fmt.delim_left;
 
 
-              for (unsigned i(0); i < components; ++i) {
+              for (length_t i(0); i < components; ++i) {
                 os << std::setw(fmt.width) << a[i];
                 os << std::setw(fmt.width) << a[i];
 
 
                 if (components-1 != i) { os << fmt.separator; }
                 if (components-1 != i) { os << fmt.separator; }
@@ -220,7 +220,7 @@ namespace glm{
             }
             }
           else
           else
             {
             {
-              for (unsigned i(0); i < components; ++i) {
+              for (length_t i(0); i < components; ++i) {
                 os << a[i];
                 os << a[i];
 
 
                 if (components-1 != i) { os << fmt.space; }
                 if (components-1 != i) { os << fmt.space; }
@@ -275,8 +275,8 @@ namespace glm{
         {
         {
           io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os));
           io::format_punct<CTy> const & fmt(io::get_facet<io::format_punct<CTy> >(os));
 
 
-          length_t const& cols(type<M>::cols);
-          length_t const& rows(type<M>::rows);
+          length_t const& cols(type<M, T, P>::cols);
+          length_t const& rows(type<M, T, P>::rows);
           
           
           if(fmt.formatted) {
           if(fmt.formatted) {
             os << fmt.newline
             os << fmt.newline
@@ -285,7 +285,7 @@ namespace glm{
             switch (fmt.order) {
             switch (fmt.order) {
             case io::column_major:
             case io::column_major:
               {
               {
-                for (unsigned i(0); i < rows; ++i) {
+                for (length_t i(0); i < rows; ++i) {
                   if (0 != i) { os << fmt.space; }
                   if (0 != i) { os << fmt.space; }
 
 
                   os << row(a, i);
                   os << row(a, i);
@@ -297,7 +297,7 @@ namespace glm{
 
 
             case io::row_major:
             case io::row_major:
               {
               {
-                for (unsigned i(0); i < cols; ++i) {
+                for (length_t i(0); i < cols; ++i) {
                   if (0 != i) { os << fmt.space; }
                   if (0 != i) { os << fmt.space; }
                   
                   
                   os << column(a, i);
                   os << column(a, i);
@@ -313,7 +313,7 @@ namespace glm{
             switch (fmt.order) {
             switch (fmt.order) {
             case io::column_major:
             case io::column_major:
               {
               {
-                for (unsigned i(0); i < cols; ++i) {
+                for (length_t i(0); i < cols; ++i) {
                   os << column(a, i);
                   os << column(a, i);
 
 
                   if (cols-1 != i) { os << fmt.space; }
                   if (cols-1 != i) { os << fmt.space; }
@@ -323,7 +323,7 @@ namespace glm{
 
 
             case io::row_major:
             case io::row_major:
               {
               {
-                for (unsigned i(0); i < rows; ++i) {
+                for (length_t i(0); i < rows; ++i) {
                   os << row(a, i);
                   os << row(a, i);
 
 
                   if (rows-1 != i) { os << fmt.space; }
                   if (rows-1 != i) { os << fmt.space; }
@@ -416,7 +416,7 @@ namespace glm{
           switch (fmt.order) {
           switch (fmt.order) {
           case io::column_major:
           case io::column_major:
             {
             {
-              for (unsigned i(0); i < rows; ++i) {
+              for (length_t i(0); i < rows; ++i) {
                 if (0 != i) { os << fmt.space; }
                 if (0 != i) { os << fmt.space; }
 
 
                 os << row(ml, i)
                 os << row(ml, i)
@@ -432,7 +432,7 @@ namespace glm{
 
 
           case io::row_major:
           case io::row_major:
             {
             {
-              for (unsigned i(0); i < cols; ++i) {
+              for (length_t i(0); i < cols; ++i) {
                 if (0 != i) { os << fmt.space; }
                 if (0 != i) { os << fmt.space; }
 
 
                 os << column(ml, i)
                 os << column(ml, i)

+ 126 - 89
glm/gtx/type_trait.hpp

@@ -42,8 +42,20 @@
 #pragma once
 #pragma once
 
 
 // Dependency:
 // Dependency:
-#include "../detail/precision.hpp"
-#include "../detail/setup.hpp"
+#include "../detail/type_vec2.hpp"
+#include "../detail/type_vec3.hpp"
+#include "../detail/type_vec4.hpp"
+#include "../detail/type_mat2x2.hpp"
+#include "../detail/type_mat2x3.hpp"
+#include "../detail/type_mat2x4.hpp"
+#include "../detail/type_mat3x2.hpp"
+#include "../detail/type_mat3x3.hpp"
+#include "../detail/type_mat3x4.hpp"
+#include "../detail/type_mat4x2.hpp"
+#include "../detail/type_mat4x3.hpp"
+#include "../detail/type_mat4x4.hpp"
+#include "../gtc/quaternion.hpp"
+#include "../gtx/dual_quaternion.hpp"
 
 
 #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
 #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
 #	pragma message("GLM: GLM_GTX_type_trait extension included")
 #	pragma message("GLM: GLM_GTX_type_trait extension included")
@@ -54,188 +66,213 @@ namespace glm
 	/// @addtogroup gtx_type_trait
 	/// @addtogroup gtx_type_trait
 	/// @{
 	/// @{
 
 
-	template <typename T, precision P> struct tvec1;
-	template <typename T, precision P> struct tvec2;
-	template <typename T, precision P> struct tvec3;
-	template <typename T, precision P> struct tvec4;
-
-	template <typename T, precision P> struct tmat2x2;
-	template <typename T, precision P> struct tmat2x3;
-	template <typename T, precision P> struct tmat2x4;
-	template <typename T, precision P> struct tmat3x2;
-	template <typename T, precision P> struct tmat3x3;
-	template <typename T, precision P> struct tmat3x4;
-	template <typename T, precision P> struct tmat4x2;
-	template <typename T, precision P> struct tmat4x3;
-	template <typename T, precision P> struct tmat4x4;
-
-	template <typename T, precision P> struct tquat;
-	template <typename T, precision P> struct tdualquat;
-
-	template <template <typename, precision> class genType>
+	template <template <typename, precision> class genType, typename T, precision P>
 	struct type
 	struct type
 	{
 	{
 		static bool const is_vec = false;
 		static bool const is_vec = false;
 		static bool const is_mat = false;
 		static bool const is_mat = false;
 		static bool const is_quat = false;
 		static bool const is_quat = false;
-		static GLM_RELAXED_CONSTEXPR length_t components = 0;
-		static GLM_RELAXED_CONSTEXPR length_t cols = 0;
-		static GLM_RELAXED_CONSTEXPR length_t rows = 0;
+		static length_t const components = 0;
+		static length_t const cols = 0;
+		static length_t const rows = 0;
 	};
 	};
 
 
-	template <>
-	struct type<tvec1>
+	template <typename T, precision P>
+	struct type<tvec1, T, P>
 	{
 	{
 		static bool const is_vec = true;
 		static bool const is_vec = true;
 		static bool const is_mat = false;
 		static bool const is_mat = false;
 		static bool const is_quat = false;
 		static bool const is_quat = false;
-		static GLM_RELAXED_CONSTEXPR length_t components = 1;
-		static GLM_RELAXED_CONSTEXPR length_t cols = 1;
-		static GLM_RELAXED_CONSTEXPR length_t rows = 1;
+		enum
+		{
+			components = 1
+		};
 	};
 	};
 
 
-	template <>
-	struct type<tvec2>
+	template <typename T, precision P>
+	struct type<tvec2, T, P>
 	{
 	{
 		static bool const is_vec = true;
 		static bool const is_vec = true;
 		static bool const is_mat = false;
 		static bool const is_mat = false;
 		static bool const is_quat = false;
 		static bool const is_quat = false;
-		static GLM_RELAXED_CONSTEXPR length_t components = 2;
+		enum
+		{
+			components = 2
+		};
 	};
 	};
 
 
-	template <>
-	struct type<tvec3>
+	template <typename T, precision P>
+	struct type<tvec3, T, P>
 	{
 	{
 		static bool const is_vec = true;
 		static bool const is_vec = true;
 		static bool const is_mat = false;
 		static bool const is_mat = false;
 		static bool const is_quat = false;
 		static bool const is_quat = false;
-		static GLM_RELAXED_CONSTEXPR length_t components = 3;
+		enum
+		{
+			components = 3
+		};
 	};
 	};
 
 
-	template <>
-	struct type<tvec4>
+	template <typename T, precision P>
+	struct type<tvec4, T, P>
 	{
 	{
 		static bool const is_vec = true;
 		static bool const is_vec = true;
 		static bool const is_mat = false;
 		static bool const is_mat = false;
 		static bool const is_quat = false;
 		static bool const is_quat = false;
-		static GLM_RELAXED_CONSTEXPR length_t components = 4;
+		enum
+		{
+			components = 4
+		};
 	};
 	};
 
 
-	template <>
-	struct type<tmat2x2>
+	template <typename T, precision P>
+	struct type<tmat2x2, T, P>
 	{
 	{
 		static bool const is_vec = false;
 		static bool const is_vec = false;
 		static bool const is_mat = true;
 		static bool const is_mat = true;
 		static bool const is_quat = false;
 		static bool const is_quat = false;
-		static GLM_RELAXED_CONSTEXPR length_t components = 2;
-		static GLM_RELAXED_CONSTEXPR length_t cols = 2;
-		static GLM_RELAXED_CONSTEXPR length_t rows = 2;
+		enum
+		{
+			components = 2,
+			cols = 2,
+			rows = 2
+		};
 	};
 	};
 
 
-	template <>
-	struct type<tmat2x3>
+	template <typename T, precision P>
+	struct type<tmat2x3, T, P>
 	{
 	{
 		static bool const is_vec = false;
 		static bool const is_vec = false;
 		static bool const is_mat = true;
 		static bool const is_mat = true;
 		static bool const is_quat = false;
 		static bool const is_quat = false;
-		static GLM_RELAXED_CONSTEXPR length_t components = 2;
-		static GLM_RELAXED_CONSTEXPR length_t cols = 2;
-		static GLM_RELAXED_CONSTEXPR length_t rows = 3;
+		enum
+		{
+			components = 2,
+			cols = 2,
+			rows = 3
+		};
 	};
 	};
 
 
-	template <>
-	struct type<tmat2x4>
+	template <typename T, precision P>
+	struct type<tmat2x4, T, P>
 	{
 	{
 		static bool const is_vec = false;
 		static bool const is_vec = false;
 		static bool const is_mat = true;
 		static bool const is_mat = true;
 		static bool const is_quat = false;
 		static bool const is_quat = false;
-		static GLM_RELAXED_CONSTEXPR length_t components = 2;
-		static GLM_RELAXED_CONSTEXPR length_t cols = 2;
-		static GLM_RELAXED_CONSTEXPR length_t rows = 4;
+		enum
+		{
+			components = 2,
+			cols = 2,
+			rows = 4
+		};
 	};
 	};
 
 
-	template <>
-	struct type<tmat3x2>
+	template <typename T, precision P>
+	struct type<tmat3x2, T, P>
 	{
 	{
 		static bool const is_vec = false;
 		static bool const is_vec = false;
 		static bool const is_mat = true;
 		static bool const is_mat = true;
 		static bool const is_quat = false;
 		static bool const is_quat = false;
-		static GLM_RELAXED_CONSTEXPR length_t components = 3;
-		static GLM_RELAXED_CONSTEXPR length_t cols = 3;
-		static GLM_RELAXED_CONSTEXPR length_t rows = 2;
+		enum
+		{
+			components = 3,
+			cols = 3,
+			rows = 2
+		};
 	};
 	};
 
 
-	template <>
-	struct type<tmat3x3>
+	template <typename T, precision P>
+	struct type<tmat3x3, T, P>
 	{
 	{
 		static bool const is_vec = false;
 		static bool const is_vec = false;
 		static bool const is_mat = true;
 		static bool const is_mat = true;
 		static bool const is_quat = false;
 		static bool const is_quat = false;
-		static GLM_RELAXED_CONSTEXPR length_t components = 3;
-		static GLM_RELAXED_CONSTEXPR length_t cols = 3;
-		static GLM_RELAXED_CONSTEXPR length_t rows = 3;
+		enum
+		{
+			components = 3,
+			cols = 3,
+			rows = 3
+		};
 	};
 	};
 
 
-	template <>
-	struct type<tmat3x4>
+	template <typename T, precision P>
+	struct type<tmat3x4, T, P>
 	{
 	{
 		static bool const is_vec = false;
 		static bool const is_vec = false;
 		static bool const is_mat = true;
 		static bool const is_mat = true;
 		static bool const is_quat = false;
 		static bool const is_quat = false;
-		static GLM_RELAXED_CONSTEXPR length_t components = 3;
-		static GLM_RELAXED_CONSTEXPR length_t cols = 3;
-		static GLM_RELAXED_CONSTEXPR length_t rows = 4;
+		enum
+		{
+			components = 3,
+			cols = 3,
+			rows = 4
+		};
 	};
 	};
 
 
-	template <>
-	struct type<tmat4x2>
+	template <typename T, precision P>
+	struct type<tmat4x2, T, P>
 	{
 	{
 		static bool const is_vec = false;
 		static bool const is_vec = false;
 		static bool const is_mat = true;
 		static bool const is_mat = true;
 		static bool const is_quat = false;
 		static bool const is_quat = false;
-		static GLM_RELAXED_CONSTEXPR length_t components = 4;
-		static GLM_RELAXED_CONSTEXPR length_t cols = 4;
-		static GLM_RELAXED_CONSTEXPR length_t rows = 2;
+		enum
+		{
+			components = 4,
+			cols = 4,
+			rows = 2
+		};
 	};
 	};
 
 
-	template <>
-	struct type<tmat4x3>
+	template <typename T, precision P>
+	struct type<tmat4x3, T, P>
 	{
 	{
 		static bool const is_vec = false;
 		static bool const is_vec = false;
 		static bool const is_mat = true;
 		static bool const is_mat = true;
 		static bool const is_quat = false;
 		static bool const is_quat = false;
-		static GLM_RELAXED_CONSTEXPR length_t components = 4;
-		static GLM_RELAXED_CONSTEXPR length_t cols = 4;
-		static GLM_RELAXED_CONSTEXPR length_t rows = 3;
+		enum
+		{
+			components = 4,
+			cols = 4,
+			rows = 3
+		};
 	};
 	};
 
 
-	template <>
-	struct type<tmat4x4>
+	template <typename T, precision P>
+	struct type<tmat4x4, T, P>
 	{
 	{
 		static bool const is_vec = false;
 		static bool const is_vec = false;
 		static bool const is_mat = true;
 		static bool const is_mat = true;
 		static bool const is_quat = false;
 		static bool const is_quat = false;
-		static GLM_RELAXED_CONSTEXPR length_t components = 4;
-		static GLM_RELAXED_CONSTEXPR length_t cols = 4;
-		static GLM_RELAXED_CONSTEXPR length_t rows = 4;
+		enum
+		{
+			components = 4,
+			cols = 4,
+			rows = 4
+		};
 	};
 	};
 
 
-	template <>
-	struct type<tquat>
+	template <typename T, precision P>
+	struct type<tquat, T, P>
 	{
 	{
 		static bool const is_vec = false;
 		static bool const is_vec = false;
 		static bool const is_mat = false;
 		static bool const is_mat = false;
 		static bool const is_quat = true;
 		static bool const is_quat = true;
-		static GLM_RELAXED_CONSTEXPR length_t components = 4;
+		enum
+		{
+			components = 4
+		};
 	};
 	};
 
 
-	template <>
-	struct type<tdualquat>
+	template <typename T, precision P>
+	struct type<tdualquat, T, P>
 	{
 	{
 		static bool const is_vec = false;
 		static bool const is_vec = false;
 		static bool const is_mat = false;
 		static bool const is_mat = false;
 		static bool const is_quat = true;
 		static bool const is_quat = true;
-		static GLM_RELAXED_CONSTEXPR length_t components = 8;
+		enum
+		{
+			components = 8
+		};
 	};
 	};
 
 
 	/// @}
 	/// @}

+ 1 - 68
test/gtx/gtx_type_trait.cpp

@@ -1,78 +1,11 @@
 #include <glm/vec4.hpp>
 #include <glm/vec4.hpp>
 #include <glm/gtx/type_trait.hpp>
 #include <glm/gtx/type_trait.hpp>
 
 
-template <typename genType>
-struct type_gni
-{
-	static bool const is_vec = true;
-	static bool const is_mat = false;
-	static bool const is_quat = false;
-};
-/*
-template <template <class, glm::precision> class vecType, typename T, glm::precision P>
-struct type_gni<vecType, T, P>
-{
-	static bool const is_vec = true;
-	static bool const is_mat = false;
-	static bool const is_quat = false;
-};
-*/
-/*
-namespace detail
-{
-	template <template <typename, glm::precision> class vec_type>
-	struct compute_vec_type
-	{
-		static bool const is_vec = false;
-		static GLM_RELAXED_CONSTEXPR glm::length_t components = 0;
-	};
-
-	template <>
-	struct compute_vec_type<glm::tvec1>
-	{
-		static bool const is_vec = false;
-		//static GLM_RELAXED_CONSTEXPR glm::length_t components = 1;
-	};
-
-	template <>
-	struct compute_vec_type<glm::tvec2>
-	{
-		static bool const is_vec = false;
-		//static GLM_RELAXED_CONSTEXPR glm::length_t components = 2;
-	};
-
-	template <>
-	struct compute_vec_type<glm::tvec3>
-	{
-		static bool const is_vec = false;
-		//static GLM_RELAXED_CONSTEXPR glm::length_t components = 3;
-	};
-
-	template <>
-	struct compute_vec_type<glm::tvec4>
-	{
-		static bool const is_vec = false;
-		//static GLM_RELAXED_CONSTEXPR glm::length_t components = 4;
-	};
-}//namespace detail
-
-template <class gen_type>
-struct vec_type
-{
-	static bool const is_vec = detail::compute_vec_type<typename gen_type::vec_type>::is_vec;
-	//static GLM_RELAXED_CONSTEXPR glm::length_t const components = detail::compute_vec_type<typename gen_type::vec_type>::components;
-};
-*/
-
 int main()
 int main()
 {
 {
 	int Error = 0;
 	int Error = 0;
 
 
-	//typedef  vec_type;
-	//bool const is_vec = detail::compute_vec_type<>::is_vec;
-
-	//Error += vec_type<glm::vec4>::is_vec ? 0 : 1;
-	//Error += vec_type<glm::vec4>::components == 4 ? 0 : 1;
+	
 
 
 	return Error;
 	return Error;
 }
 }