From 088c7d118837f8064b3a15ff851dea0a96ece2f9 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 26 Jan 2011 12:05:11 +0000 Subject: [PATCH 1/7] Updated 'force' API --- glm/setup.hpp | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/glm/setup.hpp b/glm/setup.hpp index bc8c6b01..9e51c0bf 100644 --- a/glm/setup.hpp +++ b/glm/setup.hpp @@ -2,7 +2,7 @@ // OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net) /////////////////////////////////////////////////////////////////////////////////////////////////// // Created : 2006-11-13 -// Updated : 2010-01-28 +// Updated : 2011-01-26 // Licence : This source is under MIT License // File : glm/setup.hpp /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -213,8 +213,11 @@ ///////////////// // C++ Version // +#define GLM_LANG_CXX 0 #define GLM_LANG_CXX98 1 #define GLM_LANG_CXX0X 2 +#define GLM_LANG_CXXMS 3 +#define GLM_LANG_CXXGNU 4 #if(defined(GLM_FORCE_CXX98)) # define GLM_LANG GLM_LANG_CXX98 @@ -222,8 +225,12 @@ # define GLM_LANG GLM_LANG_CXX0X #elif(GLM_COMPILER == GLM_COMPILER_VC2010) //_MSC_EXTENSIONS for MS language extensions # define GLM_LANG GLM_LANG_CXX0X -#else +#elif(((GLM_COMPILER & GLM_COMPILER_GCC) == GLM_COMPILER_GCC) && defined(__STRICT_ANSI__)) # define GLM_LANG GLM_LANG_CXX98 +#elif(((GLM_COMPILER & GLM_COMPILER_VC) == GLM_COMPILER_VC) && !defined(_MSC_EXTENSIONS)) +# define GLM_LANG GLM_LANG_CXX98 +#else +# define GLM_LANG GLM_LANG_CXX #endif #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_LANG_DISPLAYED)) @@ -303,19 +310,19 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// // Components +//#define GLM_FORCE_ONLY_XYZW #define GLM_COMPONENT_GLSL_NAMES 0 #define GLM_COMPONENT_ONLY_XYZW 1 // To disable multiple vector component names access. #define GLM_COMPONENT_MS_EXT 2 // To use anonymous union to provide multiple component names access for class valType. Visual C++ only. -//! By default: -// #define GLM_COMPONENT GLM_COMPONENT_GLSL_NAMES - -#ifndef GLM_COMPONENT +#ifndef GLM_FORCE_ONLY_XYZW # if((GLM_COMPILER & GLM_COMPILER_VC) && defined(_MSC_EXTENSIONS)) # define GLM_COMPONENT GLM_COMPONENT_MS_EXT # else # define GLM_COMPONENT GLM_COMPONENT_GLSL_NAMES # endif +#else +# define GLM_COMPONENT GLM_COMPONENT_ONLY_XYZW #endif #if((GLM_COMPONENT == GLM_COMPONENT_MS_EXT) && !(GLM_COMPILER & GLM_COMPILER_VC)) @@ -348,6 +355,21 @@ # define GLM_STATIC_ASSERT(x, message) #endif//GLM_LANG +/////////////////////////////////////////////////////////////////////////////////////////////////// +// inline + +#if(defined(GLM_FORCE_INLINE)) +# if((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2005)) +# define GLM_INLINE __forceinline +# elif((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_VC2005)) +# define GLM_INLINE __attribute__((always_inline)) +# else +# define GLM_INLINE inline +# endif//GLM_COMPILER +#else +# define GLM_INLINE inline +#endif//defined(GLM_FORCE_INLINE) + /////////////////////////////////////////////////////////////////////////////////////////////////// // Swizzle operators @@ -357,13 +379,6 @@ #define GLM_SWIZZLE_STQP 0x00000008 #define GLM_SWIZZLE_FULL (GLM_SWIZZLE_XYZW | GLM_SWIZZLE_RGBA | GLM_SWIZZLE_STQP) -//! By default: -// #define GLM_SWIZZLE GLM_SWIZZLE_NONE - -//#ifndef GLM_SWIZZLE -//# define GLM_SWIZZLE GLM_SWIZZLE_NONE -//#endif//GLM_SWIZZLE - #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_SWIZZLE_DISPLAYED)) # define GLM_MESSAGE_SWIZZLE_DISPLAYED # if !defined(GLM_SWIZZLE)|| (defined(GLM_SWIZZLE) && GLM_SWIZZLE == GLM_SWIZZLE_NONE) @@ -392,6 +407,4 @@ #define GLM_PRECISION_MEDIUMP_UINT 0x00120000 #define GLM_PRECISION_HIGHP_UINT 0x00130000 -/////////////////////////////////////////////////////////////////////////////////////////////////// - #endif//glm_setup From 1b6c73a82ef99c47de4b5f7b11b3878a6670465b Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Fri, 28 Jan 2011 11:59:02 +0000 Subject: [PATCH 2/7] Added packing implementations --- glm/core/func_packing.hpp | 18 +++++----- glm/core/func_packing.inl | 73 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 80 insertions(+), 11 deletions(-) diff --git a/glm/core/func_packing.hpp b/glm/core/func_packing.hpp index 3dea30ad..619b9391 100644 --- a/glm/core/func_packing.hpp +++ b/glm/core/func_packing.hpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// -// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net) /////////////////////////////////////////////////////////////////////////////////////////////////// // Created : 2010-03-17 // Updated : 2010-03-17 @@ -21,16 +21,16 @@ namespace glm //! Define packing functions from section 8.4 floating-point pack and unpack functions of GLSL 4.00.8 specification namespace packing { - uint packUnorm2x16(vec2 const & v); - uint packUnorm4x8(vec4 const & v); - uint packSnorm4x8(vec4 const & v); + detail::uint32 packUnorm2x16(detail::tvec2 const & v); + detail::uint32 packUnorm4x8(detail::tvec4 const & v); + detail::uint32 packSnorm4x8(detail::tvec4 const & v); - vec2 unpackUnorm2x16(uint const & p); - vec4 unpackUnorm4x8(uint const & p); - vec4 unpackSnorm4x8(uint const & p); + detail::tvec2 unpackUnorm2x16(detail::uint32 const & p); + detail::tvec4 unpackUnorm4x8(detail::uint32 const & p); + detail::tvec4 unpackSnorm4x8(detail::uint32 const & p); - double packDouble2x32(uvec2 const & v); - uvec2 unpackDouble2x32(double const & v); + double packDouble2x32(detail::tvec2 const & v); + detail::tvec2 unpackDouble2x32(double const & v); }//namespace packing }//namespace function diff --git a/glm/core/func_packing.inl b/glm/core/func_packing.inl index 83e174d3..96317284 100644 --- a/glm/core/func_packing.inl +++ b/glm/core/func_packing.inl @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// -// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net) +// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net) /////////////////////////////////////////////////////////////////////////////////////////////////// // Created : 2010-03-17 // Updated : 2010-03-17 @@ -16,8 +16,77 @@ namespace glm namespace core{ namespace function{ - namespace packing{ + namespace packing + { + inline detail::uint32 packUnorm2x16(detail::tvec2 const & v) + { + detail::uint16 A((detail::uint16)round(clamp(v.x, 0.0f, 1.0f) * 65535.0f)); + detail::uint16 B((detail::uint16)round(clamp(v.y, 0.0f, 1.0f) * 65535.0f)); + return detail::uint32((B << 16) | A); + } + inline detail::uint32 packUnorm4x8(detail::tvec4 const & v) + { + detail::uint8 A((detail::uint8)round(clamp(v.x, 0.0f, 1.0f) * 255.0f)); + detail::uint8 B((detail::uint8)round(clamp(v.y, 0.0f, 1.0f) * 255.0f)); + detail::uint8 C((detail::uint8)round(clamp(v.z, 0.0f, 1.0f) * 255.0f)); + detail::uint8 D((detail::uint8)round(clamp(v.w, 0.0f, 1.0f) * 255.0f)); + return detail::uint32((D << 24) | (C << 16) | (B << 8) | A); + } + + inline detail::uint32 packSnorm4x8(detail::tvec4 const & v) + { + detail::uint8 A((detail::uint8)round(clamp(v.x,-1.0f, 1.0f) * 255.0f)); + detail::uint8 B((detail::uint8)round(clamp(v.y,-1.0f, 1.0f) * 255.0f)); + detail::uint8 C((detail::uint8)round(clamp(v.z,-1.0f, 1.0f) * 255.0f)); + detail::uint8 D((detail::uint8)round(clamp(v.w,-1.0f, 1.0f) * 255.0f)); + return detail::uint32((D << 24) | (C << 16) | (B << 8) | A); + } + + inline detail::tvec2 unpackUnorm2x16(detail::uint32 const & p) + { + detail::uint16 A(detail::uint16(p >> 0)); + detail::uint16 B(detail::uint16(p >> 16)); + return detail::tvec2( + A * 1.0f / 65535.0f, + B * 1.0f / 65535.0f); + } + + inline detail::tvec4 unpackUnorm4x8(detail::uint32 const & p) + { + detail::uint8 A(detail::uint8(p >> 0)); + detail::uint8 B(detail::uint8(p >> 8)); + detail::uint8 C(detail::uint8(p >> 16)); + detail::uint8 D(detail::uint8(p >> 24)); + return detail::tvec4( + A * 1.0f / 255.0f, + B * 1.0f / 255.0f, + C * 1.0f / 255.0f, + D * 1.0f / 255.0f); + } + + inline detail::tvec4 unpackSnorm4x8(detail::uint32 const & p) + { + detail::uint8 A(detail::uint8(p >> 0)); + detail::uint8 B(detail::uint8(p >> 8)); + detail::uint8 C(detail::uint8(p >> 16)); + detail::uint8 D(detail::uint8(p >> 24)); + return clamp(detail::tvec4( + A * 1.0f / 127.0f, + B * 1.0f / 127.0f, + C * 1.0f / 127.0f, + D * 1.0f / 127.0f), -1.0f, 1.0f); + } + + inline double packDouble2x32(detail::tvec2 const & v) + { + return *(double*)&v; + } + + inline detail::tvec2 unpackDouble2x32(double const & v) + { + return *(detail::tvec2*)&v; + } }//namespace packing }//namespace function From e8b35cc58cb330708ec03ae37c50a71dfb0d5d98 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Fri, 28 Jan 2011 14:24:33 +0000 Subject: [PATCH 3/7] Updated swizzle operator API --- glm/core/_swizzle.hpp | 36 ++++++++++++++++++------------------ glm/setup.hpp | 19 +++++++++---------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/glm/core/_swizzle.hpp b/glm/core/_swizzle.hpp index ed7bcf9b..f0ba22ad 100644 --- a/glm/core/_swizzle.hpp +++ b/glm/core/_swizzle.hpp @@ -29,7 +29,7 @@ namespace glm }; }//namespace glm -#if defined(GLM_SWIZZLE) && (GLM_SWIZZLE & GLM_SWIZZLE_XYZW) +#if(defined(GLM_FORCE_SWIZZLE_XYZW) || defined(GLM_FORCE_SWIZZLE)) #define xx swizzle(glm::X, glm::X) #define yx swizzle(glm::Y, glm::X) @@ -48,9 +48,9 @@ namespace glm #define zw swizzle(glm::Z, glm::W) #define ww swizzle(glm::W, glm::W) -#endif// defined(GLM_SWIZZLE) && (GLM_SWIZZLE & GLM_SWIZZLE_XYZW) +#endif -#if defined(GLM_SWIZZLE) && (GLM_SWIZZLE & GLM_SWIZZLE_RGBA) +#if(defined(GLM_FORCE_SWIZZLE_RGBA) || defined(GLM_FORCE_SWIZZLE)) #define rr swizzle(glm::X, glm::X) #define gr swizzle(glm::Y, glm::X) @@ -69,9 +69,9 @@ namespace glm #define ba swizzle(glm::Z, glm::W) #define aa swizzle(glm::W, glm::W) -#endif// defined(GLM_SWIZZLE) && (GLM_SWIZZLE & GLM_SWIZZLE_RGBA) +#endif -#if defined(GLM_SWIZZLE) && (GLM_SWIZZLE & GLM_SWIZZLE_STPQ) +#if(defined(GLM_FORCE_SWIZZLE_STPQ) || defined(GLM_FORCE_SWIZZLE)) #define ss swizzle(glm::X, glm::X) #define ts swizzle(glm::Y, glm::X) @@ -90,9 +90,9 @@ namespace glm #define pq swizzle(glm::Z, glm::W) #define qq swizzle(glm::W, glm::W) -#endif// defined(GLM_SWIZZLE) && (GLM_SWIZZLE & GLM_SWIZZLE_STPQ) +#endif -#if defined(GLM_SWIZZLE) && (GLM_SWIZZLE & GLM_SWIZZLE_XYZW) +#if(defined(GLM_FORCE_SWIZZLE_XYZW) || defined(GLM_FORCE_SWIZZLE)) #define xxx swizzle(glm::X, glm::X, glm::X) #define yxx swizzle(glm::Y, glm::X, glm::X) @@ -159,9 +159,9 @@ namespace glm #define zww swizzle(glm::Z, glm::W, glm::W) #define www swizzle(glm::W, glm::W, glm::W) -#endif// defined(GLM_SWIZZLE) && (GLM_SWIZZLE & GLM_SWIZZLE_XYZW) +#endif -#if defined(GLM_SWIZZLE) && (GLM_SWIZZLE & GLM_SWIZZLE_RGBA) +#if(defined(GLM_FORCE_SWIZZLE_RGBA) || defined(GLM_FORCE_SWIZZLE)) #define rrr swizzle(glm::X, glm::X, glm::X) #define grr swizzle(glm::Y, glm::X, glm::X) @@ -228,9 +228,9 @@ namespace glm #define baa swizzle(glm::Z, glm::W, glm::W) #define aaa swizzle(glm::W, glm::W, glm::W) -#endif//defined(GLM_SWIZZLE) && (GLM_SWIZZLE & GLM_SWIZZLE_RGBA) +#endif -#if defined(GLM_SWIZZLE) && (GLM_SWIZZLE & GLM_SWIZZLE_STPQ) +#if(defined(GLM_FORCE_SWIZZLE_STPQ) || defined(GLM_FORCE_SWIZZLE)) #define sss swizzle(glm::X, glm::X, glm::X) #define tss swizzle(glm::Y, glm::X, glm::X) @@ -297,9 +297,9 @@ namespace glm #define pqq swizzle(glm::Z, glm::W, glm::W) #define qqq swizzle(glm::W, glm::W, glm::W) -#endif//defined(GLM_SWIZZLE) && (GLM_SWIZZLE & GLM_SWIZZLE_STPQ) +#endif -#if defined(GLM_SWIZZLE) && (GLM_SWIZZLE & GLM_SWIZZLE_XYZW) +#if(defined(GLM_FORCE_SWIZZLE_XYZW) || defined(GLM_FORCE_SWIZZLE)) #define xxxx swizzle(glm::X, glm::X, glm::X, glm::X) #define yxxx swizzle(glm::Y, glm::X, glm::X, glm::X) @@ -558,9 +558,9 @@ namespace glm #define zwww swizzle(glm::Z, glm::W, glm::W, glm::W) #define wwww swizzle(glm::W, glm::W, glm::W, glm::W) -#endif//defined(GLM_SWIZZLE) && (GLM_SWIZZLE & GLM_SWIZZLE_XYZW) +#endif -#if defined(GLM_SWIZZLE) && (GLM_SWIZZLE & GLM_SWIZZLE_RGBA) +#if(defined(GLM_FORCE_SWIZZLE_RGBA) || defined(GLM_FORCE_SWIZZLE)) #define rrrr swizzle(glm::X, glm::X, glm::X, glm::X) #define grrr swizzle(glm::Y, glm::X, glm::X, glm::X) @@ -819,9 +819,9 @@ namespace glm #define baaa swizzle(glm::Z, glm::W, glm::W, glm::W) #define aaaa swizzle(glm::W, glm::W, glm::W, glm::W) -#endif//defined(GLM_SWIZZLE) && (GLM_SWIZZLE & GLM_SWIZZLE_RGBA) +#endif -#if defined(GLM_SWIZZLE) && (GLM_SWIZZLE & GLM_SWIZZLE_STPQ) +#if(defined(GLM_FORCE_SWIZZLE_STPQ) || defined(GLM_FORCE_SWIZZLE)) #define ssss swizzle(glm::X, glm::X, glm::X, glm::X) #define tsss swizzle(glm::Y, glm::X, glm::X, glm::X) @@ -1080,6 +1080,6 @@ namespace glm #define pqqq swizzle(glm::Z, glm::W, glm::W, glm::W) #define qqqq swizzle(glm::W, glm::W, glm::W, glm::W) -#endif//defined(GLM_SWIZZLE) && (GLM_SWIZZLE & GLM_SWIZZLE_STPQ) +#endif #endif//glm_core_swizzle diff --git a/glm/setup.hpp b/glm/setup.hpp index 9e51c0bf..6bd2e591 100644 --- a/glm/setup.hpp +++ b/glm/setup.hpp @@ -373,21 +373,20 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// // Swizzle operators -#define GLM_SWIZZLE_NONE 0x00000000 -#define GLM_SWIZZLE_XYZW 0x00000002 -#define GLM_SWIZZLE_RGBA 0x00000004 -#define GLM_SWIZZLE_STQP 0x00000008 -#define GLM_SWIZZLE_FULL (GLM_SWIZZLE_XYZW | GLM_SWIZZLE_RGBA | GLM_SWIZZLE_STQP) +//#define GLM_FORCE_SWIZZLE_XYZW +//#define GLM_FORCE_SWIZZLE_RGBA +//#define GLM_FORCE_SWIZZLE_STQP +//#define GLM_FORCE_SWIZZLE #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_SWIZZLE_DISPLAYED)) # define GLM_MESSAGE_SWIZZLE_DISPLAYED -# if !defined(GLM_SWIZZLE)|| (defined(GLM_SWIZZLE) && GLM_SWIZZLE == GLM_SWIZZLE_NONE) -# pragma message("GLM: No swizzling operator enabled") -# elif(defined(GLM_SWIZZLE) && GLM_SWIZZLE == GLM_SWIZZLE_FULL) +# if(defined(GLM_FORCE_SWIZZLE)) # pragma message("GLM: Full swizzling operator enabled") -# elif(defined(GLM_SWIZZLE) && GLM_SWIZZLE & GLM_SWIZZLE_FULL) +# elif(!defined(GLM_FORCE_SWIZZLE_XYZW) && !defined(GLM_FORCE_SWIZZLE_RGBA) && !defined(GLM_FORCE_SWIZZLE_STQP) && !defined(GLM_FORCE_SWIZZLE)) +# pragma message("GLM: No swizzling operator enabled") +# else # pragma message("GLM: Partial swizzling operator enabled") -# endif//GLM_SWIZZLE +# endif #endif//GLM_MESSAGE /////////////////////////////////////////////////////////////////////////////////////////////////// From 2b515fd191ec51787f1157fd0c303f73c301a800 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Fri, 28 Jan 2011 14:26:37 +0000 Subject: [PATCH 4/7] Updated swizzle operator API --- glm/core/_swizzle.hpp | 18 +++++++++--------- glm/setup.hpp | 12 ++++++------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/glm/core/_swizzle.hpp b/glm/core/_swizzle.hpp index f0ba22ad..34dabfab 100644 --- a/glm/core/_swizzle.hpp +++ b/glm/core/_swizzle.hpp @@ -29,7 +29,7 @@ namespace glm }; }//namespace glm -#if(defined(GLM_FORCE_SWIZZLE_XYZW) || defined(GLM_FORCE_SWIZZLE)) +#if(defined(GLM_SWIZZLE_XYZW) || defined(GLM_SWIZZLE)) #define xx swizzle(glm::X, glm::X) #define yx swizzle(glm::Y, glm::X) @@ -50,7 +50,7 @@ namespace glm #endif -#if(defined(GLM_FORCE_SWIZZLE_RGBA) || defined(GLM_FORCE_SWIZZLE)) +#if(defined(GLM_SWIZZLE_RGBA) || defined(GLM_SWIZZLE)) #define rr swizzle(glm::X, glm::X) #define gr swizzle(glm::Y, glm::X) @@ -71,7 +71,7 @@ namespace glm #endif -#if(defined(GLM_FORCE_SWIZZLE_STPQ) || defined(GLM_FORCE_SWIZZLE)) +#if(defined(GLM_FORCE_SWIZZLE_STPQ) || defined(GLM_SWIZZLE)) #define ss swizzle(glm::X, glm::X) #define ts swizzle(glm::Y, glm::X) @@ -92,7 +92,7 @@ namespace glm #endif -#if(defined(GLM_FORCE_SWIZZLE_XYZW) || defined(GLM_FORCE_SWIZZLE)) +#if(defined(GLM_SWIZZLE_XYZW) || defined(GLM_SWIZZLE)) #define xxx swizzle(glm::X, glm::X, glm::X) #define yxx swizzle(glm::Y, glm::X, glm::X) @@ -161,7 +161,7 @@ namespace glm #endif -#if(defined(GLM_FORCE_SWIZZLE_RGBA) || defined(GLM_FORCE_SWIZZLE)) +#if(defined(GLM_SWIZZLE_RGBA) || defined(GLM_SWIZZLE)) #define rrr swizzle(glm::X, glm::X, glm::X) #define grr swizzle(glm::Y, glm::X, glm::X) @@ -230,7 +230,7 @@ namespace glm #endif -#if(defined(GLM_FORCE_SWIZZLE_STPQ) || defined(GLM_FORCE_SWIZZLE)) +#if(defined(GLM_FORCE_SWIZZLE_STPQ) || defined(GLM_SWIZZLE)) #define sss swizzle(glm::X, glm::X, glm::X) #define tss swizzle(glm::Y, glm::X, glm::X) @@ -299,7 +299,7 @@ namespace glm #endif -#if(defined(GLM_FORCE_SWIZZLE_XYZW) || defined(GLM_FORCE_SWIZZLE)) +#if(defined(GLM_SWIZZLE_XYZW) || defined(GLM_SWIZZLE)) #define xxxx swizzle(glm::X, glm::X, glm::X, glm::X) #define yxxx swizzle(glm::Y, glm::X, glm::X, glm::X) @@ -560,7 +560,7 @@ namespace glm #endif -#if(defined(GLM_FORCE_SWIZZLE_RGBA) || defined(GLM_FORCE_SWIZZLE)) +#if(defined(GLM_SWIZZLE_RGBA) || defined(GLM_SWIZZLE)) #define rrrr swizzle(glm::X, glm::X, glm::X, glm::X) #define grrr swizzle(glm::Y, glm::X, glm::X, glm::X) @@ -821,7 +821,7 @@ namespace glm #endif -#if(defined(GLM_FORCE_SWIZZLE_STPQ) || defined(GLM_FORCE_SWIZZLE)) +#if(defined(GLM_FORCE_SWIZZLE_STPQ) || defined(GLM_SWIZZLE)) #define ssss swizzle(glm::X, glm::X, glm::X, glm::X) #define tsss swizzle(glm::Y, glm::X, glm::X, glm::X) diff --git a/glm/setup.hpp b/glm/setup.hpp index 6bd2e591..37fc44ec 100644 --- a/glm/setup.hpp +++ b/glm/setup.hpp @@ -373,16 +373,16 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// // Swizzle operators -//#define GLM_FORCE_SWIZZLE_XYZW -//#define GLM_FORCE_SWIZZLE_RGBA -//#define GLM_FORCE_SWIZZLE_STQP -//#define GLM_FORCE_SWIZZLE +//#define GLM_SWIZZLE_XYZW +//#define GLM_SWIZZLE_RGBA +//#define GLM_SWIZZLE_STQP +//#define GLM_SWIZZLE #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_SWIZZLE_DISPLAYED)) # define GLM_MESSAGE_SWIZZLE_DISPLAYED -# if(defined(GLM_FORCE_SWIZZLE)) +# if(defined(GLM_SWIZZLE)) # pragma message("GLM: Full swizzling operator enabled") -# elif(!defined(GLM_FORCE_SWIZZLE_XYZW) && !defined(GLM_FORCE_SWIZZLE_RGBA) && !defined(GLM_FORCE_SWIZZLE_STQP) && !defined(GLM_FORCE_SWIZZLE)) +# elif(!defined(GLM_SWIZZLE_XYZW) && !defined(GLM_SWIZZLE_RGBA) && !defined(GLM_SWIZZLE_STQP) && !defined(GLM_SWIZZLE)) # pragma message("GLM: No swizzling operator enabled") # else # pragma message("GLM: Partial swizzling operator enabled") From 316b4befae5d4571339105853ea04e674a6e66a9 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Fri, 28 Jan 2011 14:30:04 +0000 Subject: [PATCH 5/7] Added user defines comments --- glm/setup.hpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/glm/setup.hpp b/glm/setup.hpp index 37fc44ec..950b58cc 100644 --- a/glm/setup.hpp +++ b/glm/setup.hpp @@ -22,6 +22,8 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// // Compiler +// User defines: GLM_FORCE_COMPILER_UNKNOWNED + #define GLM_COMPILER_UNKNOWNED 0x00000000 // Visual C++ defines @@ -213,6 +215,8 @@ ///////////////// // C++ Version // +// User defines: GLM_FORCE_CXX98 + #define GLM_LANG_CXX 0 #define GLM_LANG_CXX98 1 #define GLM_LANG_CXX0X 2 @@ -245,6 +249,8 @@ ///////////////// // Platform +// User defines: GLM_FORCE_PURE + #define GLM_ARCH_PURE 0x0000 //(0x0000) #define GLM_ARCH_SSE2 0x0001 //(0x0001) #define GLM_ARCH_SSE3 0x0003 //(0x0002 | GLM_ARCH_SSE2) @@ -358,6 +364,8 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// // inline +// User defines: GLM_FORCE_INLINE + #if(defined(GLM_FORCE_INLINE)) # if((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2005)) # define GLM_INLINE __forceinline @@ -373,10 +381,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// // Swizzle operators -//#define GLM_SWIZZLE_XYZW -//#define GLM_SWIZZLE_RGBA -//#define GLM_SWIZZLE_STQP -//#define GLM_SWIZZLE +// User defines: GLM_SWIZZLE_XYZW GLM_SWIZZLE_RGBA GLM_SWIZZLE_STQP GLM_SWIZZLE #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_SWIZZLE_DISPLAYED)) # define GLM_MESSAGE_SWIZZLE_DISPLAYED From a511553d8e95aceff779d842c115117e00ae3639 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Fri, 28 Jan 2011 17:06:57 +0000 Subject: [PATCH 6/7] Added missing SIMD implementations --- glm/gtx/simd_mat4.hpp | 7 +++++++ glm/gtx/simd_mat4.inl | 13 ++++++++++--- test/gtx/gtx-simd-mat4.cpp | 2 ++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/glm/gtx/simd_mat4.hpp b/glm/gtx/simd_mat4.hpp index b91c0e7c..99e11f1e 100644 --- a/glm/gtx/simd_mat4.hpp +++ b/glm/gtx/simd_mat4.hpp @@ -134,6 +134,13 @@ namespace glm { typedef detail::fmat4x4SIMD simd_mat4; + //! Multiply matrix x by matrix y component-wise, i.e., + //! result[i][j] is the scalar product of x[i][j] and y[i][j]. + //! (From GLM_GTX_simd_mat4 extension). + detail::fmat4x4SIMD simd_matrixCompMult( + detail::fmat4x4SIMD const & x, + detail::fmat4x4SIMD const & y); + //! Returns the transposed matrix of x //! (From GLM_GTX_simd_mat4 extension). detail::fmat4x4SIMD simd_transpose(detail::fmat4x4SIMD const & m); diff --git a/glm/gtx/simd_mat4.inl b/glm/gtx/simd_mat4.inl index 224055ec..d2e12901 100644 --- a/glm/gtx/simd_mat4.inl +++ b/glm/gtx/simd_mat4.inl @@ -237,13 +237,18 @@ namespace detail namespace gtx{ namespace simd_mat4 { - inline detail::fmat4x4SIMD matrixCompMult + inline detail::fmat4x4SIMD simd_matrixCompMult ( detail::fmat4x4SIMD const & x, detail::fmat4x4SIMD const & y ) { - //GLM_STATIC_ASSERT(0, "TODO"); + detail::fmat4x4SIMD result; + result[0] = x[0] * y[0]; + result[1] = x[1] * y[1]; + result[2] = x[2] * y[2]; + result[3] = x[3] * y[3]; + return result; } inline detail::fmat4x4SIMD simd_transpose(detail::fmat4x4SIMD const & m) @@ -255,7 +260,9 @@ namespace simd_mat4 inline float simd_determinant(detail::fmat4x4SIMD const & m) { - //GLM_STATIC_ASSERT(0, "TODO"); + float Result; + _mm_store_ss(&Result, detail::sse_det_ps(&m[0].Data)); + return Result; } inline detail::fmat4x4SIMD simd_inverse(detail::fmat4x4SIMD const & m) diff --git a/test/gtx/gtx-simd-mat4.cpp b/test/gtx/gtx-simd-mat4.cpp index f82e727b..6b5622d5 100644 --- a/test/gtx/gtx-simd-mat4.cpp +++ b/test/gtx/gtx-simd-mat4.cpp @@ -274,6 +274,8 @@ int main() Failed += test_compute_glm(); Failed += test_compute_gtx(); + float Det = glm::simd_determinant(glm::simd_mat4(1.0)); + glm::simd_mat4 B = glm::simd_matrixCompMult(glm::simd_mat4(1.0), glm::simd_mat4(1.0)); system("pause"); From 4721dbeb4aa1df328589d473fbd1ecf4da8a9834 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Fri, 28 Jan 2011 18:39:52 +0000 Subject: [PATCH 7/7] Added declarations --- glm/gtx/simd_vec4.hpp | 29 ++++++++++++++++++++++++++++- glm/gtx/simd_vec4.inl | 4 ++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/glm/gtx/simd_vec4.hpp b/glm/gtx/simd_vec4.hpp index f1c363a6..e75fa564 100644 --- a/glm/gtx/simd_vec4.hpp +++ b/glm/gtx/simd_vec4.hpp @@ -120,10 +120,37 @@ namespace glm { typedef detail::fvec4SIMD simd_vec4; - detail::fvec4SIMD cross( + detail::fvec4SIMD simd_length( + detail::fvec4SIMD const & v); + + detail::fvec4SIMD simd_cross( detail::fvec4SIMD const & a, detail::fvec4SIMD const & b); + detail::fvec4SIMD simd_distance( + detail::fvec4SIMD const & v); + + detail::fvec4SIMD simd_dot( + detail::fvec4SIMD const & a, + detail::fvec4SIMD const & b); + + detail::fvec4SIMD simd_normalize( + detail::fvec4SIMD const & v); + + detail::fvec4SIMD simd_faceforward( + detail::fvec4SIMD const & N, + detail::fvec4SIMD const & I, + detail::fvec4SIMD const & Nref); + + detail::fvec4SIMD simd_reflect( + detail::fvec4SIMD const & I, + detail::fvec4SIMD const & N); + + detail::fvec4SIMD simd_refract( + detail::fvec4SIMD const & I, + detail::fvec4SIMD const & N, + float const & eta); + }//namespace simd_vec4 }//namespace gtx }//namespace glm diff --git a/glm/gtx/simd_vec4.inl b/glm/gtx/simd_vec4.inl index a5244d33..88b9f1e7 100644 --- a/glm/gtx/simd_vec4.inl +++ b/glm/gtx/simd_vec4.inl @@ -267,7 +267,7 @@ namespace glm namespace simd_vec4 { # if(GLM_INSTRUCTION_SET & GLM_INSTRUCTION_SET_SSE) - inline detail::fvec4SIMD cross + inline detail::fvec4SIMD simd_cross ( detail::fvec4SIMD const & a, detail::fvec4SIMD const & b @@ -276,7 +276,7 @@ namespace glm return detail::sse_xpd_ps(a.Data, b.Data); } # else//(GLM_INSTRUCTION_SET & GLM_INSTRUCTION_SET_PURE) - inline detail::fvec4SIMD cross + inline detail::fvec4SIMD simd_cross ( detail::fvec4SIMD const & a, detail::fvec4SIMD const & b