From 24e2477fdf3e7193137f25f97cbc4829602d6ad1 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Fri, 8 Apr 2011 22:09:15 +0100 Subject: [PATCH] Create a vector from a pointer --- glm/gtc/type_ptr.hpp | 60 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/glm/gtc/type_ptr.hpp b/glm/gtc/type_ptr.hpp index 5aeea5af..1a0d2620 100644 --- a/glm/gtc/type_ptr.hpp +++ b/glm/gtc/type_ptr.hpp @@ -294,6 +294,66 @@ namespace glm return &(mat[0].x); } + //! Build a vector from a pointer. + //! From GLM_GTC_type_ptr extension. + template + inline detail::tvec2 make_vec2(T const * const ptr) + { + detail::tvec2 Result; + memcpy(&Result[0], ptr, sizeof(detail::tvec2)); + return Result; + } + + //! Build a vector from a pointer. + //! From GLM_GTC_type_ptr extension. + template + inline detail::tvec3 make_vec3(T const * const ptr) + { + detail::tvec3 Result; + memcpy(&Result[0], ptr, sizeof(detail::tvec3)); + return Result; + } + + //! Build a vector from a pointer. + //! From GLM_GTC_type_ptr extension. + template + inline detail::tvec4 make_vec4(T const * const ptr) + { + detail::tvec4 Result; + memcpy(&Result[0], 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) + { + detail::tmat2 Result; + memcpy(&Result[0], ptr, sizeof(detail::tmat2)); + return 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; + } + + //! Build a matrix from a pointer. + //! From GLM_GTC_type_ptr extension. + template + inline detail::tmat4 make_mat4(T const * const ptr) + { + detail::tmat4 Result; + memcpy(&Result[0], ptr, sizeof(detail::tmat4)); + return Result; + } + ///@} }//namespace type_ptr