فهرست منبع

Completed implementation of building a GLM type from a pointer

Christophe Riccio 14 سال پیش
والد
کامیت
bb99fbb289
1فایلهای تغییر یافته به همراه98 افزوده شده و 13 حذف شده
  1. 98 13
      glm/gtc/type_ptr.hpp

+ 98 - 13
glm/gtc/type_ptr.hpp

@@ -300,7 +300,7 @@ namespace glm
 		inline detail::tvec2<T> make_vec2(T const * const ptr)
 		inline detail::tvec2<T> make_vec2(T const * const ptr)
 		{
 		{
 			detail::tvec2<T> Result;
 			detail::tvec2<T> Result;
-			memcpy(&Result[0], ptr, sizeof(detail::tvec2<T>));
+			memcpy(value_ptr(Result), ptr, sizeof(detail::tvec2<T>));
 			return Result;
 			return Result;
 		}
 		}
 
 
@@ -310,7 +310,7 @@ namespace glm
 		inline detail::tvec3<T> make_vec3(T const * const ptr)
 		inline detail::tvec3<T> make_vec3(T const * const ptr)
 		{
 		{
 			detail::tvec3<T> Result;
 			detail::tvec3<T> Result;
-			memcpy(&Result[0], ptr, sizeof(detail::tvec3<T>));
+			memcpy(value_ptr(Result), ptr, sizeof(detail::tvec3<T>));
 			return Result;
 			return Result;
 		}
 		}
 
 
@@ -320,40 +320,125 @@ namespace glm
 		inline detail::tvec4<T> make_vec4(T const * const ptr)
 		inline detail::tvec4<T> make_vec4(T const * const ptr)
 		{
 		{
 			detail::tvec4<T> Result;
 			detail::tvec4<T> Result;
-			memcpy(&Result[0], ptr, sizeof(detail::tvec4<T>));
+			memcpy(value_ptr(Result), ptr, sizeof(detail::tvec4<T>));
 			return Result;
 			return Result;
 		}
 		}
 
 
 		//! Build a matrix from a pointer.
 		//! Build a matrix from a pointer.
 		//! From GLM_GTC_type_ptr extension.
 		//! From GLM_GTC_type_ptr extension.
 		template<typename T>
 		template<typename T>
-		inline detail::tmat2<T> make_mat2(T const * const ptr)
+		inline detail::tmat2x2<T> make_mat2x2(T const * const ptr)
 		{
 		{
-			detail::tmat2<T> Result;
-			memcpy(&Result[0], ptr, sizeof(detail::tmat2<T>));
+			detail::tmat2x2<T> Result;
+			memcpy(value_ptr(Result), ptr, sizeof(detail::tmat2x2<T>));
+			return Result;
+		}
+        
+		//! Build a matrix from a pointer.
+		//! From GLM_GTC_type_ptr extension.
+		template<typename T>
+		inline detail::tmat2x3<T> make_mat2x3(T const * const ptr)
+		{
+			detail::tmat2x3<T> Result;
+			memcpy(value_ptr(Result), ptr, sizeof(detail::tmat2x3<T>));
+			return Result;
+		}
+        
+		//! Build a matrix from a pointer.
+		//! From GLM_GTC_type_ptr extension.
+		template<typename T>
+		inline detail::tmat2x4<T> make_mat2x4(T const * const ptr)
+		{
+			detail::tmat2x4<T> Result;
+			memcpy(value_ptr(Result), ptr, sizeof(detail::tmat2x4<T>));
+			return Result;
+		}
+        
+		//! Build a matrix from a pointer.
+		//! From GLM_GTC_type_ptr extension.
+		template<typename T>
+		inline detail::tmat3x2<T> make_mat3x2(T const * const ptr)
+		{
+			detail::tmat3x2<T> Result;
+			memcpy(value_ptr(Result), ptr, sizeof(detail::tmat3x2<T>));
+			return Result;
+		}
+        
+		//! Build a matrix from a pointer.
+		//! From GLM_GTC_type_ptr extension.
+		template<typename T>
+		inline detail::tmat3x3<T> make_mat3x3(T const * const ptr)
+		{
+			detail::tmat3x3<T> Result;
+			memcpy(value_ptr(Result), ptr, sizeof(detail::tmat3x3<T>));
 			return Result;
 			return Result;
 		}
 		}
 
 
 		//! Build a matrix from a pointer.
 		//! Build a matrix from a pointer.
 		//! From GLM_GTC_type_ptr extension.
 		//! From GLM_GTC_type_ptr extension.
 		template<typename T>
 		template<typename T>
-		inline detail::tmat3<T> make_mat3(T const * const ptr)
+		inline detail::tmat3x4<T> make_mat3x4(T const * const ptr)
 		{
 		{
-			detail::tmat3<T> Result;
-			memcpy(&Result[0], ptr, sizeof(detail::tmat3<T>));
+			detail::tmat3x4<T> Result;
+			memcpy(value_ptr(Result), ptr, sizeof(detail::tmat3x4<T>));
 			return Result;
 			return Result;
 		}
 		}
+
+        
+		//! Build a matrix from a pointer.
+		//! From GLM_GTC_type_ptr extension.
+		template<typename T>
+		inline detail::tmat4x2<T> make_mat4x2(T const * const ptr)
+		{
+			detail::tmat4x2<T> Result;
+			memcpy(value_ptr(Result), ptr, sizeof(detail::tmat4x2<T>));
+			return Result;
+		}
+        
+		//! Build a matrix from a pointer.
+		//! From GLM_GTC_type_ptr extension.
+		template<typename T>
+		inline detail::tmat4x3<T> make_mat4x3(T const * const ptr)
+		{
+			detail::tmat4x3<T> Result;
+			memcpy(value_ptr(Result), ptr, sizeof(detail::tmat4x3<T>));
+			return Result;
+		}
+        
+		//! Build a matrix from a pointer.
+		//! From GLM_GTC_type_ptr extension.
+		template<typename T>
+		inline detail::tmat4x4<T> make_mat4x4(T const * const ptr)
+		{
+			detail::tmat4x4<T> Result;
+			memcpy(value_ptr(Result), ptr, sizeof(detail::tmat4x4<T>));
+			return Result;
+		}
+        
+		//! Build a matrix from a pointer.
+		//! From GLM_GTC_type_ptr extension.
+		template<typename T>
+		inline detail::tmat2x2<T> make_mat2(T const * const ptr)
+		{
+			return make_mat2x2(Result);
+		}
+        
+		//! Build a matrix from a pointer.
+		//! From GLM_GTC_type_ptr extension.
+		template<typename T>
+		inline detail::tmat3<T> make_mat3(T const * const ptr)
+		{
+			return make_mat3x3(Result);
+		}
 		
 		
 		//! Build a matrix from a pointer.
 		//! Build a matrix from a pointer.
 		//! From GLM_GTC_type_ptr extension.
 		//! From GLM_GTC_type_ptr extension.
 		template<typename T>
 		template<typename T>
 		inline detail::tmat4<T> make_mat4(T const * const ptr)
 		inline detail::tmat4<T> make_mat4(T const * const ptr)
 		{
 		{
-			detail::tmat4<T> Result;
-			memcpy(&Result[0], ptr, sizeof(detail::tmat4<T>));
-			return Result;
+			return make_mat4x4(Result);
 		}
 		}
-
+        
 		///@}
 		///@}
 
 
 	}//namespace type_ptr
 	}//namespace type_ptr