diff --git a/glm/gtc/type_ptr.hpp b/glm/gtc/type_ptr.hpp index 1a0d2620..cd137098 100644 --- a/glm/gtc/type_ptr.hpp +++ b/glm/gtc/type_ptr.hpp @@ -300,7 +300,7 @@ namespace glm inline detail::tvec2 make_vec2(T const * const ptr) { detail::tvec2 Result; - memcpy(&Result[0], ptr, sizeof(detail::tvec2)); + memcpy(value_ptr(Result), ptr, sizeof(detail::tvec2)); return Result; } @@ -310,7 +310,7 @@ namespace glm inline detail::tvec3 make_vec3(T const * const ptr) { detail::tvec3 Result; - memcpy(&Result[0], ptr, sizeof(detail::tvec3)); + memcpy(value_ptr(Result), ptr, sizeof(detail::tvec3)); return Result; } @@ -320,28 +320,115 @@ namespace glm inline detail::tvec4 make_vec4(T const * const ptr) { detail::tvec4 Result; - memcpy(&Result[0], ptr, sizeof(detail::tvec4)); + memcpy(value_ptr(Result), ptr, sizeof(detail::tvec4)); return Result; } //! Build a matrix from a pointer. //! From GLM_GTC_type_ptr extension. template - inline detail::tmat2 make_mat2(T const * const ptr) + inline detail::tmat2x2 make_mat2x2(T const * const ptr) { - detail::tmat2 Result; - memcpy(&Result[0], ptr, sizeof(detail::tmat2)); + detail::tmat2x2 Result; + memcpy(value_ptr(Result), ptr, sizeof(detail::tmat2x2)); + return Result; + } + + //! Build a matrix from a pointer. + //! From GLM_GTC_type_ptr extension. + template + inline detail::tmat2x3 make_mat2x3(T const * const ptr) + { + detail::tmat2x3 Result; + memcpy(value_ptr(Result), ptr, sizeof(detail::tmat2x3)); + return Result; + } + + //! Build a matrix from a pointer. + //! From GLM_GTC_type_ptr extension. + template + inline detail::tmat2x4 make_mat2x4(T const * const ptr) + { + detail::tmat2x4 Result; + memcpy(value_ptr(Result), ptr, sizeof(detail::tmat2x4)); + return Result; + } + + //! Build a matrix from a pointer. + //! From GLM_GTC_type_ptr extension. + template + inline detail::tmat3x2 make_mat3x2(T const * const ptr) + { + detail::tmat3x2 Result; + memcpy(value_ptr(Result), ptr, sizeof(detail::tmat3x2)); + return Result; + } + + //! Build a matrix from a pointer. + //! From GLM_GTC_type_ptr extension. + template + inline detail::tmat3x3 make_mat3x3(T const * const ptr) + { + detail::tmat3x3 Result; + memcpy(value_ptr(Result), ptr, sizeof(detail::tmat3x3)); return Result; } + //! Build a matrix from a pointer. + //! From GLM_GTC_type_ptr extension. + template + inline detail::tmat3x4 make_mat3x4(T const * const ptr) + { + detail::tmat3x4 Result; + memcpy(value_ptr(Result), ptr, sizeof(detail::tmat3x4)); + return Result; + } + + + //! Build a matrix from a pointer. + //! From GLM_GTC_type_ptr extension. + template + inline detail::tmat4x2 make_mat4x2(T const * const ptr) + { + detail::tmat4x2 Result; + memcpy(value_ptr(Result), ptr, sizeof(detail::tmat4x2)); + return Result; + } + + //! Build a matrix from a pointer. + //! From GLM_GTC_type_ptr extension. + template + inline detail::tmat4x3 make_mat4x3(T const * const ptr) + { + detail::tmat4x3 Result; + memcpy(value_ptr(Result), ptr, sizeof(detail::tmat4x3)); + return Result; + } + + //! Build a matrix from a pointer. + //! From GLM_GTC_type_ptr extension. + template + inline detail::tmat4x4 make_mat4x4(T const * const ptr) + { + detail::tmat4x4 Result; + memcpy(value_ptr(Result), ptr, sizeof(detail::tmat4x4)); + return Result; + } + + //! Build a matrix from a pointer. + //! From GLM_GTC_type_ptr extension. + template + inline detail::tmat2x2 make_mat2(T const * const ptr) + { + return make_mat2x2(Result); + } + //! Build a matrix from a pointer. //! From GLM_GTC_type_ptr extension. template inline detail::tmat3 make_mat3(T const * const ptr) { - detail::tmat3 Result; - memcpy(&Result[0], ptr, sizeof(detail::tmat3)); - return Result; + return make_mat3x3(Result); } //! Build a matrix from a pointer. @@ -349,11 +436,9 @@ namespace glm template inline detail::tmat4 make_mat4(T const * const ptr) { - detail::tmat4 Result; - memcpy(&Result[0], ptr, sizeof(detail::tmat4)); - return Result; + return make_mat4x4(Result); } - + ///@} }//namespace type_ptr