Updated component modes management

This commit is contained in:
Christophe Riccio 2011-01-19 15:01:17 +00:00
parent c7f863e0b4
commit 7c177c0ea3
7 changed files with 124 additions and 137 deletions

View File

@ -49,11 +49,11 @@ namespace glm
//////////////////////////////////////
// Data
# if defined(GLM_USE_ONLY_XYZW)
# if(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW)
value_type x;
# else//GLM_USE_ONLY_XYZW
# else//(GLM_COMPONENT == GLM_COMPONENT_GLSL_NAMES)
union {value_type x, r, s;};
# endif//GLM_USE_ONLY_XYZW
# endif//GLM_COMPONENT
//////////////////////////////////////
// Accesses

View File

@ -47,21 +47,19 @@ namespace glm
//////////////////////////////////////
// Data
# if defined(GLM_USE_ONLY_XYZW)
# if(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW)
value_type x, y;
# else//GLM_USE_ONLY_XYZW
# ifdef GLM_USE_ANONYMOUS_UNION
# elif(GLM_COMPONENT == GLM_COMPONENT_MS_EXT)
union
{
struct{value_type x, y;};
struct{value_type r, g;};
struct{value_type s, t;};
};
# else//GLM_USE_ANONYMOUS_UNION
# else//(GLM_COMPONENT == GLM_COMPONENT_GLSL_NAMES)
union {value_type x, r, s;};
union {value_type y, g, t;};
# endif//GLM_USE_ANONYMOUS_UNION
# endif//GLM_USE_ONLY_XYZW
# endif//GLM_COMPONENT
//////////////////////////////////////
// Accesses

View File

@ -46,22 +46,20 @@ namespace glm
//////////////////////////////////////
// Data
# if defined(GLM_USE_ONLY_XYZW)
# if(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW)
value_type x, y, z;
# else//GLM_USE_ONLY_XYZW
# ifdef GLM_USE_ANONYMOUS_UNION
# elif(GLM_COMPONENT == GLM_COMPONENT_MS_EXT)
union
{
struct{value_type x, y, z;};
struct{value_type r, g, b;};
struct{value_type s, t, p;};
};
# else//GLM_USE_ANONYMOUS_UNION
# else//(GLM_COMPONENT == GLM_COMPONENT_GLSL_NAMES)
union {value_type x, r, s;};
union {value_type y, g, t;};
union {value_type z, b, p;};
# endif//GLM_USE_ANONYMOUS_UNION
# endif//GLM_USE_ONLY_XYZW
# endif//GLM_COMPONENT
//////////////////////////////////////
// Accesses

View File

@ -47,23 +47,21 @@ namespace glm
//////////////////////////////////////
// Data
# if defined(GLM_USE_ONLY_XYZW)
# if(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW)
value_type x, y, z, w;
# else//GLM_USE_ONLY_XYZW
# ifdef GLM_USE_ANONYMOUS_UNION
# elif(GLM_COMPONENT == GLM_COMPONENT_MS_EXT)
union
{
struct{value_type x, y, z, w;};
struct{value_type r, g, b, a;};
struct{value_type s, t, p, q;};
};
# else//GLM_USE_ANONYMOUS_UNION
# else//(GLM_COMPONENT == GLM_COMPONENT_GLSL_NAMES)
union {value_type x, r, s;};
union {value_type y, g, t;};
union {value_type z, b, p;};
union {value_type w, a, q;};
# endif//GLM_USE_ANONYMOUS_UNION
# endif//GLM_USE_ONLY_XYZW
# endif//GLM_COMPONENT
//////////////////////////////////////
// Accesses

View File

@ -51,11 +51,9 @@
#include <limits>
#include "./setup.hpp"
#if(defined(GLM_MESSAGE) && (GLM_MESSAGE == GLM_ENABLE))
# ifndef GLM_MESSAGE_CORE_INCLUDED_DISPLAYED
# define GLM_MESSAGE_CORE_INCLUDED_DISPLAYED
# pragma message("GLM: Core library included")
# endif//GLM_MESSAGE_CORE_INCLUDED_DISPLAYED
#if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_CORE_INCLUDED_DISPLAYED))
# define GLM_MESSAGE_CORE_INCLUDED_DISPLAYED
# pragma message("GLM: Core library included")
#endif//GLM_MESSAGE
//! GLM namespace, it contains all GLSL based features.

View File

@ -25,22 +25,6 @@
#define GLM_DISABLE 0x00000000
#define GLM_ENABLE 0x00000001
///////////////////////////////////////////////////////////////////////////////////////////////////
// Message
//#define GLM_MESSAGE_QUIET 0x00000000
//
//#define GLM_MESSAGE_WARNING 0x00000001
//#define GLM_MESSAGE_NOTIFICATION 0x00000002
//#define GLM_MESSAGE_CORE 0x00000004
//#define GLM_MESSAGE_EXTS 0x00000008
//#define GLM_MESSAGE_SETUP 0x00000010
//
//#define GLM_MESSAGE_ALL GLM_MESSAGE_WARNING | GLM_MESSAGE_NOTIFICATION | GLM_MESSAGE_CORE | GLM_MESSAGE_EXTS | GLM_MESSAGE_SETUP
//! By default:
// #define GLM_MESSAGE GLM_DISABLE
///////////////////////////////////////////////////////////////////////////////////////////////////
// Precision
@ -191,7 +175,7 @@
#else
# define GLM_COMPILER GLM_COMPILER_UNKNOWNED
#endif//__GNUC__
#endif
#endif//GLM_COMPILER
@ -200,21 +184,19 @@
#endif//GLM_COMPILER
// Report compiler detection
#if(defined(GLM_MESSAGE) && (GLM_MESSAGE == GLM_ENABLE))
# ifndef GLM_MESSAGE_COMPILER_DISPLAYED
#if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_COMPILER_DISPLAYED))
# define GLM_MESSAGE_COMPILER_DISPLAYED
# if(defined(GLM_COMPILER) && GLM_COMPILER & GLM_COMPILER_VC)
# pragma message("GLM: Visual C++ compiler detected")
# elif(defined(GLM_COMPILER) && GLM_COMPILER & GLM_COMPILER_GCC)
# pragma message("GLM: GCC compiler detected")
# elif(defined(GLM_COMPILER) && GLM_COMPILER & GLM_COMPILER_BC)
# pragma message("GLM: Borland compiler detected but not supported")
# elif(defined(GLM_COMPILER) && GLM_COMPILER & GLM_COMPILER_CODEWARRIOR)
# pragma message("GLM: Codewarrior compiler detected but not supported")
# else
# pragma message("GLM: Compiler not detected")
# endif
# endif//GLM_MESSAGE_COMPILER_DISPLAYED
# if(defined(GLM_COMPILER) && GLM_COMPILER & GLM_COMPILER_VC)
# pragma message("GLM: Visual C++ compiler detected")
# elif(defined(GLM_COMPILER) && GLM_COMPILER & GLM_COMPILER_GCC)
# pragma message("GLM: GCC compiler detected")
# elif(defined(GLM_COMPILER) && GLM_COMPILER & GLM_COMPILER_BC)
# pragma message("GLM: Borland compiler detected but not supported")
# elif(defined(GLM_COMPILER) && GLM_COMPILER & GLM_COMPILER_CODEWARRIOR)
# pragma message("GLM: Codewarrior compiler detected but not supported")
# else
# pragma message("GLM: Compiler not detected")
# endif
#endif//GLM_MESSAGE
/////////////////
@ -240,61 +222,38 @@
#error "GLM_MODEL undefined, your compiler may not be supported by GLM. Add #define GLM_MODEL 0 to ignore this message."
#endif//GLM_MODEL
#if(defined(GLM_MESSAGE) && (GLM_MESSAGE == GLM_ENABLE)))
# ifndef GLM_MESSAGE_MODEL_DISPLAYED
#if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_MODEL_DISPLAYED))
# define GLM_MESSAGE_MODEL_DISPLAYED
# if(GLM_MODEL == GLM_MODEL_64)
# pragma message("GLM: 64 bits model")
# elif(GLM_MODEL == GLM_MODEL_32)
# pragma message("GLM: 32 bits model")
# endif//GLM_MODEL
# endif//GLM_MESSAGE_MODEL_DISPLAYED
# if(GLM_MODEL == GLM_MODEL_64)
# pragma message("GLM: 64 bits model")
# elif(GLM_MODEL == GLM_MODEL_32)
# pragma message("GLM: 32 bits model")
# endif//GLM_MODEL
#endif//GLM_MESSAGE
/////////////////
// C++ Version //
#define GLM_LANG_CPP98 1
#define GLM_LANG_CPP0X 2
#define GLM_LANG_CXX98 1
#define GLM_LANG_CXX0X 2
#if((GLM_COMPILER & GLM_COMPILER_GCC) && defined(__GXX_EXPERIMENTAL_CXX0X__)) // -std=c++0x or -std=gnu++0x
# define GLM_LANG GLM_LANG_CPP0X
#elif GLM_COMPILER & GLM_COMPILER_VC2010
# define GLM_LANG GLM_LANG_CPP0X
# 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
# define GLM_LANG GLM_LANG_CPP98
# define GLM_LANG GLM_LANG_CXX98
#endif
#if(defined(GLM_MESSAGE) && (GLM_MESSAGE == GLM_ENABLE)))
# ifndef GLM_MESSAGE_LANG_DISPLAYED
#if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_LANG_DISPLAYED))
# define GLM_MESSAGE_LANG_DISPLAYED
# if(GLM_LANG == GLM_LANG_CPP98)
# pragma message("GLM: C++98")
# elif(GLM_LANG == GLM_LANG_CPP0X)
# pragma message("GLM: C++0x")
# endif//GLM_MODEL
# endif//GLM_MESSAGE_MODEL_DISPLAYED
# if(GLM_LANG == GLM_LANG_CXX98)
# pragma message("GLM: C++98")
# elif(GLM_LANG == GLM_LANG_CXX0X)
# pragma message("GLM: C++0x")
# endif//GLM_MODEL
#endif//GLM_MESSAGE
///////////////////////////////////////////////////////////////////////////////////////////////////
// Compiler instruction set
//#define GLM_INSTRUCTION_SET_NULL 0x00000000 //
#define GLM_INSTRUCTION_SET_PURE 0x00000001 // x86intrin.h
//#define GLM_INSTRUCTION_SET_MMX 0x00000002 // mmintrin.h (MMX)
//#define GLM_INSTRUCTION_SET_3DNOW 0x00000004 // mm3dnow.h (3DNOW!)
//#define GLM_INSTRUCTION_SET_SSE 0x00000008 // xmmintrin.h (SSE + MMX)
#define GLM_INSTRUCTION_SET_SSE2 0x00000010 // emmintrin.h (SSE2 + SSE)
#define GLM_INSTRUCTION_SET_SSE3 0x00000020 | GLM_INSTRUCTION_SET_SSE2 // pmmintrin.h (SSE3 + SSE2 + SSE1)
//#define GLM_INSTRUCTION_SET_SSSE3 0x00000040 // tmmintrin.h (SSSE3 + SSE3 + SSE2 + SSE1)
//#define GLM_INSTRUCTION_SET_POPCNT 0x00000080 // popcntintrin.h
//#define GLM_INSTRUCTION_SET_SSE4A 0x00000100 // ammintrin.h (SSE4A + POPCNT + SSE3 + SSE2 + SSE)
//#define GLM_INSTRUCTION_SET_SSE4_1 0x00000200 // smmintrin.h (SSE4_1 + SSSE3 + SSE3 + SSE2 + SSE)
//#define GLM_INSTRUCTION_SET_SSE4_2 0x00000400 // nmmintrin.h (SSE4_2 + SSE4_1 + SSSE3 + SSE3 + SSE2 + SSE)
//#define GLM_INSTRUCTION_SET_AES 0x00000800 // wmmintrin.h (AES + PCLMUL + SSE2 + SSE1)
//#define GLM_INSTRUCTION_SET_PCLMUL 0x00001000 // wmmintrin.h (AES + PCLMUL + SSE2 + SSE1)
#define GLM_INSTRUCTION_SET_AVX 0x00002000 | GLM_INSTRUCTION_SET_SSE3 // immintrin.h (AES + PCLMUL + SSE4_2 + SSE4_1 + SSSE3 + SSE3 + SSE2 + SSE)
/////////////////
// Platform
@ -303,9 +262,13 @@
#define GLM_SUPPORT_SSE3 2
#define GLM_SUPPORT_AVX 3
#if(GLM_COMPILER & GLM_COMPILER_VC)
#if((GLM_COMPILER & GLM_COMPILER_VC) && defined(_M_IX86))
# if(GLM_COMPILER >= GLM_COMPILER_VC2010)
# define GLM_SUPPORT GLM_SUPPORT_SSE3 //GLM_SUPPORT_AVX (Require SP1)
# if(_M_IX86_FP == 3) //AVX
# define GLM_SUPPORT GLM_SUPPORT_AVX //GLM_SUPPORT_AVX (Require SP1)
# else
# define GLM_SUPPORT GLM_SUPPORT_SSE3
# endif
# elif(GLM_COMPILER >= GLM_COMPILER_VC2008)
# define GLM_SUPPORT GLM_SUPPORT_SSE3
# elif(GLM_COMPILER >= GLM_COMPILER_VC2005)
@ -325,32 +288,36 @@
# define GLM_SUPPORT GLM_SUPPORT_PURE
#endif
#define GLM_PLATFORM_PURE 0
#define GLM_PLATFORM_SSE2 1
#define GLM_PLATFORM_SSE3 2
#define GLM_PLATFORM_AVX 3
#define GLM_ARCH_PURE 0
#define GLM_ARCH_SSE2 1
#define GLM_ARCH_SSE3 2
#define GLM_ARCH_AVX 3
#ifdef GLM_INSTRUCTION_SET
# if((GLM_INSTRUCTION_SET & GLM_INSTRUCTION_SET_AVX) && GLM_SUPPORT >= GLM_SUPPORT_AVX)
# include <immintrin.h>
# define GLM_PLATFORM GLM_PLATFORM_AVX
# elif((GLM_INSTRUCTION_SET & GLM_INSTRUCTION_SET_SSE3) && GLM_SUPPORT >= GLM_SUPPORT_SSE3)
# include <pmmintrin.h>
# define GLM_PLATFORM GLM_PLATFORM_SSE3
# elif((GLM_INSTRUCTION_SET & GLM_INSTRUCTION_SET_SSE2) && GLM_SUPPORT >= GLM_SUPPORT_SSE2)
# include <emmintrin.h>
# define GLM_PLATFORM GLM_PLATFORM_SSE2
# else
# define GLM_PLATFORM GLM_PLATFORM_PURE
# endif
#if(GLM_SUPPORT == GLM_SUPPORT_AVX)
# include <immintrin.h>
# define GLM_ARCH GLM_ARCH_AVX
#elif(GLM_SUPPORT == GLM_SUPPORT_SSE3)
# include <pmmintrin.h>
# define GLM_ARCH GLM_ARCH_SSE3
#elif((GLM_SUPPORT == GLM_SUPPORT_SSE2) || (GLM_MODEL == GLM_MODEL_64))
# include <emmintrin.h>
# define GLM_ARCH GLM_ARCH_SSE2
#else
# if(GLM_MODEL == GLM_MODEL_64)
# include <emmintrin.h>
# define GLM_PLATFORM GLM_PLATFORM_SSE2
# else
# define GLM_PLATFORM GLM_PLATFORM_PURE
# endif
#endif
# define GLM_ARCH GLM_ARCH_PURE
#endif//GLM_SUPPORT
#if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_ARCH_DISPLAYED))
# define GLM_MESSAGE_ARCH_DISPLAYED
# if(GLM_ARCH == GLM_ARCH_PURE)
# pragma message("GLM: Platform independent")
# elif(GLM_ARCH == GLM_ARCH_SSE2)
# pragma message("GLM: SSE2 build platform")
# elif(GLM_ARCH == GLM_ARCH_SSE3)
# pragma message("GLM: SSE3 build platform")
# elif(GLM_ARCH == GLM_ARCH_AVX)
# pragma message("GLM: AVX build platform")
# endif//GLM_ARCH
#endif//GLM_MESSAGE
/*
#if(GLM_INSTRUCTION_SET != GLM_INSTRUCTION_SET_NULL)
@ -407,39 +374,66 @@
//! By default:
// #define GLM_SWIZZLE GLM_SWIZZLE_NONE
#if(defined(GLM_MESSAGE) && (GLM_MESSAGE & (GLM_MESSAGE_SETUP | GLM_MESSAGE_NOTIFICATION)))
#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)
# pragma message("GLM message: No swizzling operator used")
# pragma message("GLM: No swizzling operator enabled")
# elif(defined(GLM_SWIZZLE) && GLM_SWIZZLE == GLM_SWIZZLE_FULL)
# pragma message("GLM message: Full swizzling operator support enabled")
# pragma message("GLM: Full swizzling operator enabled")
# elif(defined(GLM_SWIZZLE) && GLM_SWIZZLE & GLM_SWIZZLE_FULL)
# pragma message("GLM message: Partial swizzling operator support enabled")
# pragma message("GLM: Partial swizzling operator enabled")
# endif//GLM_SWIZZLE
#endif//GLM_MESSAGE
///////////////////////////////////////////////////////////////////////////////////////////////////
// Use options
// Components
// To disable multiple vector component names access.
// GLM_USE_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.
// To use anonymous union to provide multiple component names access for class valType. Visual C++ only.
// GLM_USE_ANONYMOUS_UNION
//! By default:
// #define GLM_COMPONENT GLM_COMPONENT_GLSL_NAMES
#if(defined(GLM_USE_ANONYMOUS_UNION) && !(GLM_COMPILER & GLM_COMPILER_VC))
#error "GLM_USE_ANONYMOUS_UNION is defined to use anonymous union implementation of vector types. Anonymous unions can't be used with GCC."
#ifndef GLM_COMPONENT
# 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
#endif
#if((GLM_COMPONENT == GLM_COMPONENT_MS_EXT) && !(GLM_COMPILER & GLM_COMPILER_VC))
# error "GLM_COMPONENT value is GLM_COMPONENT_MS_EXT but this is not allowed with the current compiler."
#endif//GLM_USE_ANONYMOUS_UNION
#if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_COMPONENT_DISPLAYED))
# define GLM_MESSAGE_COMPONENT_DISPLAYED
# if(GLM_COMPONENT == GLM_COMPONENT_GLSL_NAMES)
# pragma message("GLM: GLSL multiple vector component names")
# elif(GLM_COMPONENT == GLM_COMPONENT_ONLY_XYZW)
# pragma message("GLM: x,y,z,w vector component names only")
# elif(GLM_COMPONENT == GLM_COMPONENT_MS_EXT)
# pragma message("GLM: Multiple vector component names through Visual C++ language extensions")
# else
# error "GLM_COMPONENT value unknowned"
# endif//GLM_MESSAGE_COMPONENT_DISPLAYED
#endif//GLM_MESSAGE
///////////////////////////////////////////////////////////////////////////////////////////////////
// Static assert
#if(GLM_LANG == GLM_LANG_CPP0X)
#if(GLM_LANG == GLM_LANG_CXX0X)
# define GLM_STATIC_ASSERT(x, message) static_assert(x, message)
#elif(defined(BOOST_STATIC_ASSERT))
# define GLM_STATIC_ASSERT(x, message) BOOST_STATIC_ASSERT(x)
#else
# define GLM_STATIC_ASSERT(x, message) typedef char __CASSERT__##__LINE__[(x) ? 1 : -1]
#endif//GLM_DEPENDENCE
#endif//GLM_LANG
///////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -7,6 +7,7 @@
// File : test/core/type_mat4x4.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#define GLM_MESSAGES
#include <glm/glm.hpp>
#include <cstdio>