- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List

_detail.hpp
Go to the documentation of this file.

    00001
    00002
    00003
    00004
    00005
    00006
    00007
    00008
    00009
    00010
    00011
    00012
    00013
    00014
    00015
    00016
    00017
    00018
    00019
    00020
    00021
    00022
    00023
    00024
    00025
    00026
    00027
    00028
    00029 #ifndef glm_core_detail
    00030 #define glm_core_detail
    00031
    00032 #include "setup.hpp"
    00033 #include <cassert>
    00034 #if(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
    00035 #include <cstdint>
    00036 #endif
    00037
    00038 namespace glm{
    00039 namespace detail
    00040 {
    00041         class half;
    00042
    00043 #if(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) // C99 detected, 64 bit types available
    00044         typedef int64_t                                                         sint64;
    00045         typedef uint64_t                                                        uint64;
    00046 #elif(GLM_COMPILER & GLM_COMPILER_VC)
    00047         typedef signed __int64                                          sint64;
    00048         typedef unsigned __int64                                        uint64;
    00049 #elif(GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_LLVM_GCC | GLM_COMPILER_CLANG))
    00050         __extension__ typedef signed long long          sint64;
    00051         __extension__ typedef unsigned long long        uint64;
    00052 #elif(GLM_COMPILER & GLM_COMPILER_BC)
    00053         typedef Int64                                                           sint64;
    00054         typedef Uint64                                                          uint64;
    00055 #else//unknown compiler
    00056         typedef signed long     long                                    sint64;
    00057         typedef unsigned long long                                      uint64;
    00058 #endif//GLM_COMPILER
    00059
    00060         template<bool C>
    00061         struct If
    00062         {
    00063                 template<typename F, typename T>
    00064                 static GLM_FUNC_QUALIFIER T apply(F functor, const T& val)
    00065                 {
    00066                         return functor(val);
    00067                 }
    00068         };
    00069
    00070         template<>
    00071         struct If<false>
    00072         {
    00073                 template<typename F, typename T>
    00074                 static GLM_FUNC_QUALIFIER T apply(F, const T& val)
    00075                 {
    00076                         return val;
    00077                 }
    00078         };
    00079
    00080         //template <typename T>
    00081         //struct traits
    00082         //{
    00083         //      static const bool is_signed = false;
    00084         //      static const bool is_float = false;
    00085         //      static const bool is_vector = false;
    00086         //      static const bool is_matrix = false;
    00087         //      static const bool is_genType = false;
    00088         //      static const bool is_genIType = false;
    00089         //      static const bool is_genUType = false;
    00090         //};
    00091
    00092         //template <>
    00093         //struct traits<half>
    00094         //{
    00095         //      static const bool is_float = true;
    00096         //      static const bool is_genType = true;
    00097         //};
    00098
    00099         //template <>
    00100         //struct traits<float>
    00101         //{
    00102         //      static const bool is_float = true;
    00103         //      static const bool is_genType = true;
    00104         //};
    00105
    00106         //template <>
    00107         //struct traits<double>
    00108         //{
    00109         //      static const bool is_float = true;
    00110         //      static const bool is_genType = true;
    00111         //};
    00112
    00113         //template <typename genType>
    00114         //struct desc
    00115         //{
    00116         //      typedef genType                                                 type;
    00117         //      typedef genType *                                               pointer;
    00118         //      typedef genType const*                                  const_pointer;
    00119         //      typedef genType const *const                    const_pointer_const;
    00120         //      typedef genType *const                                  pointer_const;
    00121         //      typedef genType &                                               reference;
    00122         //      typedef genType const&                                  const_reference;
    00123         //      typedef genType const&                                  param_type;
    00124
    00125         //      typedef typename genType::value_type    value_type;
    00126         //      typedef typename genType::size_type             size_type;
    00127         //      static const typename size_type                 value_size;
    00128         //};
    00129
    00130         //template <typename genType>
    00131         //const typename desc<genType>::size_type desc<genType>::value_size = genType::value_size();
    00132
    00133         union uif32
    00134         {
    00135                 GLM_FUNC_QUALIFIER uif32() :
    00136                         i(0)
    00137                 {}
    00138
    00139                 GLM_FUNC_QUALIFIER uif32(float f) :
    00140                         f(f)
    00141                 {}
    00142
    00143                 GLM_FUNC_QUALIFIER uif32(unsigned int i) :
    00144                         i(i)
    00145                 {}
    00146
    00147                 float f;
    00148                 unsigned int i;
    00149         };
    00150
    00151         union uif64
    00152         {
    00153                 GLM_FUNC_QUALIFIER uif64() :
    00154                         i(0)
    00155                 {}
    00156
    00157                 GLM_FUNC_QUALIFIER uif64(double f) :
    00158                         f(f)
    00159                 {}
    00160
    00161                 GLM_FUNC_QUALIFIER uif64(uint64 i) :
    00162                         i(i)
    00163                 {}
    00164
    00165                 double f;
    00166                 uint64 i;
    00167         };
    00168
    00169         typedef uif32 uif;
    00170
    00172         // int
    00173
    00174         template <typename T>
    00175         struct is_int
    00176         {
    00177                 enum is_int_enum
    00178                 {
    00179                         _YES = 0,
    00180                         _NO = 1
    00181                 };
    00182         };
    00183
    00184 #define GLM_DETAIL_IS_INT(T)    \
    00185         template <>                                     \
    00186         struct is_int<T>                        \
    00187         {                                                       \
    00188                 enum is_int_enum                \
    00189                 {                                               \
    00190                         _YES = 1,                       \
    00191                         _NO = 0                         \
    00192                 };                                              \
    00193         }
    00194
    00196         // uint
    00197
    00198         template <typename T>
    00199         struct is_uint
    00200         {
    00201                 enum is_uint_enum
    00202                 {
    00203                         _YES = 0,
    00204                         _NO = 1
    00205                 };
    00206         };
    00207
    00208 #define GLM_DETAIL_IS_UINT(T)   \
    00209         template <>                                     \
    00210         struct is_uint<T>                       \
    00211         {                                                       \
    00212                 enum is_uint_enum               \
    00213                 {                                               \
    00214                         _YES = 1,                       \
    00215                         _NO = 0                         \
    00216                 };                                              \
    00217         }
    00218
    00219         //GLM_DETAIL_IS_UINT(unsigned long long)
    00220
    00222         // float
    00223
    00224         template <typename T>
    00225         struct is_float
    00226         {
    00227                 enum is_float_enum
    00228                 {
    00229                         _YES = 0,
    00230                         _NO = 1
    00231                 };
    00232         };
    00233
    00234 #define GLM_DETAIL_IS_FLOAT(T)  \
    00235         template <>                                     \
    00236         struct is_float<T>                      \
    00237         {                                                       \
    00238                 enum is_float_enum              \
    00239                 {                                               \
    00240                         _YES = 1,                       \
    00241                         _NO = 0                         \
    00242                 };                                              \
    00243         }
    00244
    00245         GLM_DETAIL_IS_FLOAT(detail::half);
    00246         GLM_DETAIL_IS_FLOAT(float);
    00247         GLM_DETAIL_IS_FLOAT(double);
    00248         GLM_DETAIL_IS_FLOAT(long double);
    00249
    00251         // bool
    00252
    00253         template <typename T>
    00254         struct is_bool
    00255         {
    00256                 enum is_bool_enum
    00257                 {
    00258                         _YES = 0,
    00259                         _NO = 1
    00260                 };
    00261         };
    00262
    00263         template <>
    00264         struct is_bool<bool>
    00265         {
    00266                 enum is_bool_enum
    00267                 {
    00268                         _YES = 1,
    00269                         _NO = 0
    00270                 };
    00271         };
    00272
    00274         // vector
    00275
    00276         template <typename T>
    00277         struct is_vector
    00278         {
    00279                 enum is_vector_enum
    00280                 {
    00281                         _YES = 0,
    00282                         _NO = 1
    00283                 };
    00284         };
    00285
    00286 #       define GLM_DETAIL_IS_VECTOR(TYPE) \
    00287                 template <typename T> \
    00288                 struct is_vector<TYPE<T> > \
    00289                 { \
    00290                         enum is_vector_enum \
    00291                         { \
    00292                                 _YES = 1, \
    00293                                 _NO = 0 \
    00294                         }; \
    00295                 }
    00296
    00298         // matrix
    00299
    00300         template <typename T>
    00301         struct is_matrix
    00302         {
    00303                 enum is_matrix_enum
    00304                 {
    00305                         _YES = 0,
    00306                         _NO = 1
    00307                 };
    00308         };
    00309
    00310 #define GLM_DETAIL_IS_MATRIX(T) \
    00311         template <>                                     \
    00312         struct is_matrix                        \
    00313         {                                                       \
    00314                 enum is_matrix_enum             \
    00315                 {                                               \
    00316                         _YES = 1,                       \
    00317                         _NO = 0                         \
    00318                 };                                              \
    00319         }
    00320
    00322         // type
    00323
    00324         template <typename T>
    00325         struct type
    00326         {
    00327                 enum type_enum
    00328                 {
    00329                         is_float = is_float<T>::_YES,
    00330                         is_int = is_int<T>::_YES,
    00331                         is_uint = is_uint<T>::_YES,
    00332                         is_bool = is_bool<T>::_YES
    00333                 };
    00334         };
    00335
    00337         // type
    00338
    00339         typedef signed char                                                     int8;
    00340         typedef signed short                                            int16;
    00341         typedef signed int                                                      int32;
    00342         typedef detail::sint64                                          int64;
    00343
    00344         typedef unsigned char                                           uint8;
    00345         typedef unsigned short                                          uint16;
    00346         typedef unsigned int                                            uint32;
    00347         typedef detail::uint64                                          uint64;
    00348
    00349         typedef detail::half                                            float16;
    00350         typedef float                                                           float32;
    00351         typedef double                                                          float64;
    00352
    00354         // float_or_int_trait
    00355
    00356         struct float_or_int_value
    00357         {
    00358                 enum
    00359                 {
    00360                         GLM_ERROR,
    00361                         GLM_FLOAT,
    00362                         GLM_INT
    00363                 };
    00364         };
    00365
    00366         template <typename T>
    00367         struct float_or_int_trait
    00368         {
    00369                 enum{ID = float_or_int_value::GLM_ERROR};
    00370         };
    00371
    00372         template <>
    00373         struct float_or_int_trait<int8>
    00374         {
    00375                 enum{ID = float_or_int_value::GLM_INT};
    00376         };
    00377
    00378         template <>
    00379         struct float_or_int_trait<int16>
    00380         {
    00381                 enum{ID = float_or_int_value::GLM_INT};
    00382         };
    00383
    00384         template <>
    00385         struct float_or_int_trait<int32>
    00386         {
    00387                 enum{ID = float_or_int_value::GLM_INT};
    00388         };
    00389
    00390         template <>
    00391         struct float_or_int_trait<int64>
    00392         {
    00393                 enum{ID = float_or_int_value::GLM_INT};
    00394         };
    00395
    00396         template <>
    00397         struct float_or_int_trait<uint8>
    00398         {
    00399                 enum{ID = float_or_int_value::GLM_INT};
    00400         };
    00401
    00402         template <>
    00403         struct float_or_int_trait<uint16>
    00404         {
    00405                 enum{ID = float_or_int_value::GLM_INT};
    00406         };
    00407
    00408         template <>
    00409         struct float_or_int_trait<uint32>
    00410         {
    00411                 enum{ID = float_or_int_value::GLM_INT};
    00412         };
    00413
    00414         template <>
    00415         struct float_or_int_trait<uint64>
    00416         {
    00417                 enum{ID = float_or_int_value::GLM_INT};
    00418         };
    00419
    00420         template <>
    00421         struct float_or_int_trait<float16>
    00422         {
    00423                 enum{ID = float_or_int_value::GLM_FLOAT};
    00424         };
    00425
    00426         template <>
    00427         struct float_or_int_trait<float32>
    00428         {
    00429                 enum{ID = float_or_int_value::GLM_FLOAT};
    00430         };
    00431
    00432         template <>
    00433         struct float_or_int_trait<float64>
    00434         {
    00435                 enum{ID = float_or_int_value::GLM_FLOAT};
    00436         };
    00437
    00438 }//namespace detail
    00439 }//namespace glm
    00440
    00441 #if((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2005))
    00442 #       define GLM_DEPRECATED __declspec(deprecated)
    00443 #       define GLM_ALIGN(x) __declspec(align(x))
    00444 #       define GLM_ALIGNED_STRUCT(x) __declspec(align(x)) struct
    00445 #       define GLM_RESTRICT __declspec(restrict)
    00446 #       define GLM_RESTRICT_VAR __restrict
    00447 #elif((GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_LLVM_GCC)) && (GLM_COMPILER >= GLM_COMPILER_GCC31))
    00448 #       define GLM_DEPRECATED __attribute__((__deprecated__))
    00449 #       define GLM_ALIGN(x) __attribute__((aligned(x)))
    00450 #       define GLM_ALIGNED_STRUCT(x) struct __attribute__((aligned(x)))
    00451 #       if(GLM_COMPILER >= GLM_COMPILER_GCC33)
    00452 #               define GLM_RESTRICT __restrict__
    00453 #               define GLM_RESTRICT_VAR __restrict__
    00454 #       else
    00455 #               define GLM_RESTRICT
    00456 #               define GLM_RESTRICT_VAR
    00457 #       endif
    00458 #       define GLM_RESTRICT __restrict__
    00459 #       define GLM_RESTRICT_VAR __restrict__
    00460 #else
    00461 #       define GLM_DEPRECATED
    00462 #       define GLM_ALIGN
    00463 #       define GLM_ALIGNED_STRUCT(x)
    00464 #       define GLM_RESTRICT
    00465 #       define GLM_RESTRICT_VAR
    00466 #endif//GLM_COMPILER
    00467
    00468 #endif//glm_core_detail