From 37e380ca9bbe5a2517ce0ada369ac8bf12a2c8a3 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 23 Jan 2013 01:49:42 +0100 Subject: [PATCH] Fixed packDouble2x32 on XCode 4.5, issue #37 --- glm/core/func_packing.inl | 34 ++++++++++++++++++++++++++++++++-- readme.txt | 1 + 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/glm/core/func_packing.inl b/glm/core/func_packing.inl index 27197151..6cdecf64 100644 --- a/glm/core/func_packing.inl +++ b/glm/core/func_packing.inl @@ -136,12 +136,42 @@ namespace glm GLM_FUNC_QUALIFIER double packDouble2x32(detail::tvec2 const & v) { - return *(double*)&v; + struct uint32_pair + { + detail::uint32 x; + detail::uint32 y; + }; + + union helper + { + uint32_pair input; + double output; + } Helper; + + Helper.input.x = v.x; + Helper.input.y = v.y; + + return Helper.output; + //return *(double*)&v; } GLM_FUNC_QUALIFIER detail::tvec2 unpackDouble2x32(double const & v) { - return *(detail::tvec2*)&v; + struct uint32_pair + { + detail::uint32 x; + detail::uint32 y; + }; + + union helper + { + double input; + uint32_pair output; + } Helper; + + Helper.input = v; + + return detail::tvec2(Helper.output.x, Helper.output.y); } GLM_FUNC_QUALIFIER uint packHalf2x16(detail::tvec2 const & v) diff --git a/readme.txt b/readme.txt index b6783c04..268aa352 100644 --- a/readme.txt +++ b/readme.txt @@ -44,6 +44,7 @@ GLM 0.9.4.2: 2013-01-XX - Fixed isnan and isinf for CUDA compiler - Fixed GLM_FORCE_RADIANS on glm::perspective - Fixed GCC warnings +- Fixed packDouble2x32 on XCode ================================================================================ GLM 0.9.4.1: 2012-12-22