- Main Page
- Namespaces
- Files

- File List

# _detail.hpp

    00001
    00002 // OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
    00004 // Created : 2008-07-24
    00005 // Updated : 2008-08-31
    00006 // Licence : This source is under MIT License
    00007 // File    : glm/core/_detail.hpp
    00009
    00010 #ifndef glm_core_detail
    00011 #define glm_core_detail
    00012
    00013 #include "../setup.hpp"
    00014 #include <cassert>
    00015
    00016 namespace glm{
    00017 namespace detail{
    00018
    00019         class thalf;
    00020
    00021 #if(defined(GLM_COMPILER) && (GLM_COMPILER & GLM_COMPILER_VC))
    00022         typedef signed __int64                                          sint64;
    00023         typedef unsigned __int64                                        uint64;
    00024 #elif(defined(GLM_COMPILER) && (GLM_COMPILER & GLM_COMPILER_GCC))
    00025         __extension__ typedef signed long long          sint64;
    00026         __extension__ typedef unsigned long long        uint64;
    00027 #else//unknown compiler
    00028         typedef signed long                                                     sint64;
    00029         typedef unsigned long                                           uint64;
    00030 #endif//GLM_COMPILER
    00031
    00032         template<bool C>
    00033         struct If
    00034         {
    00035                 template<typename F, typename T>
    00036                 static inline T apply(F functor, const T& val)
    00037                 {
    00038                         return functor(val);
    00039                 }
    00040         };
    00041
    00042         template<>
    00043         struct If<false>
    00044         {
    00045                 template<typename F, typename T>
    00046                 static inline T apply(F, const T& val)
    00047                 {
    00048                         return val;
    00049                 }
    00050         };
    00051
    00052         //template <typename T>
    00053         //struct traits
    00054         //{
    00055         //      static const bool is_signed = false;
    00056         //      static const bool is_float = false;
    00057         //      static const bool is_vector = false;
    00058         //      static const bool is_matrix = false;
    00059         //      static const bool is_genType = false;
    00060         //      static const bool is_genIType = false;
    00061         //      static const bool is_genUType = false;
    00062         //};
    00063
    00064         //template <>
    00065         //struct traits<half>
    00066         //{
    00067         //      static const bool is_float = true;
    00068         //      static const bool is_genType = true;
    00069         //};
    00070
    00071         //template <>
    00072         //struct traits<float>
    00073         //{
    00074         //      static const bool is_float = true;
    00075         //      static const bool is_genType = true;
    00076         //};
    00077
    00078         //template <>
    00079         //struct traits<double>
    00080         //{
    00081         //      static const bool is_float = true;
    00082         //      static const bool is_genType = true;
    00083         //};
    00084
    00085         //template <typename genType>
    00086         //struct desc
    00087         //{
    00088         //      typedef genType                                                 type;
    00089         //      typedef genType *                                               pointer;
    00090         //      typedef genType const*                                  const_pointer;
    00091         //      typedef genType const *const                    const_pointer_const;
    00092         //      typedef genType *const                                  pointer_const;
    00093         //      typedef genType &                                               reference;
    00094         //      typedef genType const&                                  const_reference;
    00095         //      typedef genType const&                                  param_type;
    00096
    00097         //      typedef typename genType::value_type    value_type;
    00098         //      typedef typename genType::size_type             size_type;
    00099         //      static const typename size_type                 value_size;
    00100         //};
    00101
    00102         //template <typename genType>
    00103         //const typename desc<genType>::size_type desc<genType>::value_size = genType::value_size();
    00104
    00105         union uif32
    00106         {
    00107                 uif32() :
    00108                         i(0)
    00109                 {}
    00110
    00111                 uif32(float f) :
    00112                         f(f)
    00113                 {}
    00114
    00115                 uif32(unsigned int i) :
    00116                         i(i)
    00117                 {}
    00118
    00119                 float f;
    00120                 unsigned int i;
    00121         };
    00122
    00123         union uif64
    00124         {
    00125                 uif64() :
    00126                         i(0)
    00127                 {}
    00128
    00129                 uif64(double f) :
    00130                         f(f)
    00131                 {}
    00132
    00133                 uif64(uint64 i) :
    00134                         i(i)
    00135                 {}
    00136
    00137                 double f;
    00138                 uint64 i;
    00139         };
    00140
    00141         typedef uif32 uif;
    00142
    00144         // int
    00145
    00146         template <typename T>
    00147         struct is_int
    00148         {
    00149                 enum is_int_enum
    00150                 {
    00151                         _YES = 0,
    00152                         _NO = 1
    00153                 };
    00154         };
    00155
    00156 #define GLM_DETAIL_IS_INT(T)    \
    00157         template <>                                     \
    00158         struct is_int<T>                        \
    00159         {                                                       \
    00160                 enum is_int_enum                \
    00161                 {                                               \
    00162                         _YES = 1,                       \
    00163                         _NO = 0                         \
    00164                 };                                              \
    00165         }
    00166
    00168         // uint
    00169
    00170         template <typename T>
    00171         struct is_uint
    00172         {
    00173                 enum is_uint_enum
    00174                 {
    00175                         _YES = 0,
    00176                         _NO = 1
    00177                 };
    00178         };
    00179
    00180 #define GLM_DETAIL_IS_UINT(T)   \
    00181         template <>                                     \
    00182         struct is_uint<T>                       \
    00183         {                                                       \
    00184                 enum is_uint_enum               \
    00185                 {                                               \
    00186                         _YES = 1,                       \
    00187                         _NO = 0                         \
    00188                 };                                              \
    00189         }
    00190
    00191         //GLM_DETAIL_IS_UINT(unsigned long long)
    00192
    00194         // float
    00195
    00196         template <typename T>
    00197         struct is_float
    00198         {
    00199                 enum is_float_enum
    00200                 {
    00201                         _YES = 0,
    00202                         _NO = 1
    00203                 };
    00204         };
    00205
    00206 #define GLM_DETAIL_IS_FLOAT(T)  \
    00207         template <>                                     \
    00208         struct is_float<T>                      \
    00209         {                                                       \
    00210                 enum is_float_enum              \
    00211                 {                                               \
    00212                         _YES = 1,                       \
    00213                         _NO = 0                         \
    00214                 };                                              \
    00215         }
    00216
    00218         // bool
    00219
    00220         template <typename T>
    00221         struct is_bool
    00222         {
    00223                 enum is_bool_enum
    00224                 {
    00225                         _YES = 0,
    00226                         _NO = 1
    00227                 };
    00228         };
    00229
    00230         template <>
    00231         struct is_bool<bool>
    00232         {
    00233                 enum is_bool_enum
    00234                 {
    00235                         _YES = 1,
    00236                         _NO = 0
    00237                 };
    00238         };
    00239
    00241         // vector
    00242
    00243         template <typename T>
    00244         struct is_vector
    00245         {
    00246                 enum is_vector_enum
    00247                 {
    00248                         _YES = 0,
    00249                         _NO = 1
    00250                 };
    00251         };
    00252
    00253 #define GLM_DETAIL_IS_VECTOR(T) \
    00254         template <>                                     \
    00255         struct is_vector                        \
    00256         {                                                       \
    00257                 enum is_vector_enum             \
    00258                 {                                               \
    00259                         _YES = 1,                       \
    00260                         _NO = 0                         \
    00261                 };                                              \
    00262         }
    00263
    00265         // matrix
    00266
    00267         template <typename T>
    00268         struct is_matrix
    00269         {
    00270                 enum is_matrix_enum
    00271                 {
    00272                         _YES = 0,
    00273                         _NO = 1
    00274                 };
    00275         };
    00276
    00277 #define GLM_DETAIL_IS_MATRIX(T) \
    00278         template <>                                     \
    00279         struct is_matrix                        \
    00280         {                                                       \
    00281                 enum is_matrix_enum             \
    00282                 {                                               \
    00283                         _YES = 1,                       \
    00284                         _NO = 0                         \
    00285                 };                                              \
    00286         }
    00287
    00289         // type
    00290
    00291         template <typename T>
    00292         struct type
    00293         {
    00294                 enum type_enum
    00295                 {
    00296                         is_float = is_float<T>::_YES,
    00297                         is_int = is_int<T>::_YES,
    00298                         is_uint = is_uint<T>::_YES,
    00299                         is_bool = is_bool<T>::_YES
    00300                 };
    00301         };
    00302
    00304         // type
    00305
    00306         typedef signed char                                                     int8;
    00307         typedef signed short                                            int16;
    00308         typedef signed int                                                      int32;
    00309         typedef detail::sint64                                          int64;
    00310
    00311         typedef unsigned char                                           uint8;
    00312         typedef unsigned short                                          uint16;
    00313         typedef unsigned int                                            uint32;
    00314         typedef detail::uint64                                          uint64;
    00315
    00316         typedef detail::thalf                                           float16;
    00317         typedef float                                                           float32;
    00318         typedef double                                                          float64;
    00319
    00320 }//namespace detail
    00321 }//namespace glm
    00322
    00323 #endif//glm_core_detail