- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List

# _detail.hpp

    00001
    00002 // OpenGL Mathematics Copyright (c) 2005 - 2011 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(GLM_COMPILER & GLM_COMPILER_VC)
    00022         typedef signed __int64                                          sint64;
    00023         typedef unsigned __int64                                        uint64;
    00024 #elif(GLM_COMPILER & GLM_COMPILER_GCC)
    00025         __extension__ typedef signed long long          sint64;
    00026         __extension__ typedef unsigned long long        uint64;
    00027 //#     if GLM_MODEL == GLM_MODEL_64
    00028 //              typedef signed long                                                     highp_int_t;
    00029 //              typedef unsigned long                                           highp_uint_t;
    00030 //#   elif GLM_MODEL == GLM_MODEL_32
    00031 //              __extension__ typedef signed long long          highp_int_t;
    00032 //              __extension__ typedef unsigned long long        highp_uint_t;
    00033 //#     endif//GLM_MODEL
    00034 #elif(GLM_COMPILER & GLM_COMPILER_BC)
    00035         typedef Int64                                                           sint64;
    00036         typedef Uint64                                                          uint64;
    00037 #else//unknown compiler
    00038         typedef signed long                                                     sint64;
    00039         typedef unsigned long                                           uint64;
    00040 #endif//GLM_COMPILER
    00041
    00042         template<bool C>
    00043         struct If
    00044         {
    00045                 template<typename F, typename T>
    00046                 static inline T apply(F functor, const T& val)
    00047                 {
    00048                         return functor(val);
    00049                 }
    00050         };
    00051
    00052         template<>
    00053         struct If<false>
    00054         {
    00055                 template<typename F, typename T>
    00056                 static inline T apply(F, const T& val)
    00057                 {
    00058                         return val;
    00059                 }
    00060         };
    00061
    00062         //template <typename T>
    00063         //struct traits
    00064         //{
    00065         //      static const bool is_signed = false;
    00066         //      static const bool is_float = false;
    00067         //      static const bool is_vector = false;
    00068         //      static const bool is_matrix = false;
    00069         //      static const bool is_genType = false;
    00070         //      static const bool is_genIType = false;
    00071         //      static const bool is_genUType = false;
    00072         //};
    00073
    00074         //template <>
    00075         //struct traits<half>
    00076         //{
    00077         //      static const bool is_float = true;
    00078         //      static const bool is_genType = true;
    00079         //};
    00080
    00081         //template <>
    00082         //struct traits<float>
    00083         //{
    00084         //      static const bool is_float = true;
    00085         //      static const bool is_genType = true;
    00086         //};
    00087
    00088         //template <>
    00089         //struct traits<double>
    00090         //{
    00091         //      static const bool is_float = true;
    00092         //      static const bool is_genType = true;
    00093         //};
    00094
    00095         //template <typename genType>
    00096         //struct desc
    00097         //{
    00098         //      typedef genType                                                 type;
    00099         //      typedef genType *                                               pointer;
    00100         //      typedef genType const*                                  const_pointer;
    00101         //      typedef genType const *const                    const_pointer_const;
    00102         //      typedef genType *const                                  pointer_const;
    00103         //      typedef genType &                                               reference;
    00104         //      typedef genType const&                                  const_reference;
    00105         //      typedef genType const&                                  param_type;
    00106
    00107         //      typedef typename genType::value_type    value_type;
    00108         //      typedef typename genType::size_type             size_type;
    00109         //      static const typename size_type                 value_size;
    00110         //};
    00111
    00112         //template <typename genType>
    00113         //const typename desc<genType>::size_type desc<genType>::value_size = genType::value_size();
    00114
    00115         union uif32
    00116         {
    00117                 uif32() :
    00118                         i(0)
    00119                 {}
    00120
    00121                 uif32(float f) :
    00122                         f(f)
    00123                 {}
    00124
    00125                 uif32(unsigned int i) :
    00126                         i(i)
    00127                 {}
    00128
    00129                 float f;
    00130                 unsigned int i;
    00131         };
    00132
    00133         union uif64
    00134         {
    00135                 uif64() :
    00136                         i(0)
    00137                 {}
    00138
    00139                 uif64(double f) :
    00140                         f(f)
    00141                 {}
    00142
    00143                 uif64(uint64 i) :
    00144                         i(i)
    00145                 {}
    00146
    00147                 double f;
    00148                 uint64 i;
    00149         };
    00150
    00151         typedef uif32 uif;
    00152
    00154         // int
    00155
    00156         template <typename T>
    00157         struct is_int
    00158         {
    00159                 enum is_int_enum
    00160                 {
    00161                         _YES = 0,
    00162                         _NO = 1
    00163                 };
    00164         };
    00165
    00166 #define GLM_DETAIL_IS_INT(T)    \
    00167         template <>                                     \
    00168         struct is_int<T>                        \
    00169         {                                                       \
    00170                 enum is_int_enum                \
    00171                 {                                               \
    00172                         _YES = 1,                       \
    00173                         _NO = 0                         \
    00174                 };                                              \
    00175         }
    00176
    00178         // uint
    00179
    00180         template <typename T>
    00181         struct is_uint
    00182         {
    00183                 enum is_uint_enum
    00184                 {
    00185                         _YES = 0,
    00186                         _NO = 1
    00187                 };
    00188         };
    00189
    00190 #define GLM_DETAIL_IS_UINT(T)   \
    00191         template <>                                     \
    00192         struct is_uint<T>                       \
    00193         {                                                       \
    00194                 enum is_uint_enum               \
    00195                 {                                               \
    00196                         _YES = 1,                       \
    00197                         _NO = 0                         \
    00198                 };                                              \
    00199         }
    00200
    00201         //GLM_DETAIL_IS_UINT(unsigned long long)
    00202
    00204         // float
    00205
    00206         template <typename T>
    00207         struct is_float
    00208         {
    00209                 enum is_float_enum
    00210                 {
    00211                         _YES = 0,
    00212                         _NO = 1
    00213                 };
    00214         };
    00215
    00216 #define GLM_DETAIL_IS_FLOAT(T)  \
    00217         template <>                                     \
    00218         struct is_float<T>                      \
    00219         {                                                       \
    00220                 enum is_float_enum              \
    00221                 {                                               \
    00222                         _YES = 1,                       \
    00223                         _NO = 0                         \
    00224                 };                                              \
    00225         }
    00226
    00228         // bool
    00229
    00230         template <typename T>
    00231         struct is_bool
    00232         {
    00233                 enum is_bool_enum
    00234                 {
    00235                         _YES = 0,
    00236                         _NO = 1
    00237                 };
    00238         };
    00239
    00240         template <>
    00241         struct is_bool<bool>
    00242         {
    00243                 enum is_bool_enum
    00244                 {
    00245                         _YES = 1,
    00246                         _NO = 0
    00247                 };
    00248         };
    00249
    00251         // vector
    00252
    00253         template <typename T>
    00254         struct is_vector
    00255         {
    00256                 enum is_vector_enum
    00257                 {
    00258                         _YES = 0,
    00259                         _NO = 1
    00260                 };
    00261         };
    00262
    00263 #       define GLM_DETAIL_IS_VECTOR(TYPE) \
    00264                 template <typename T> \
    00265                 struct is_vector<TYPE<T> > \
    00266                 { \
    00267                         enum is_vector_enum \
    00268                         { \
    00269                                 _YES = 1, \
    00270                                 _NO = 0 \
    00271                         }; \
    00272                 }
    00273
    00275         // matrix
    00276
    00277         template <typename T>
    00278         struct is_matrix
    00279         {
    00280                 enum is_matrix_enum
    00281                 {
    00282                         _YES = 0,
    00283                         _NO = 1
    00284                 };
    00285         };
    00286
    00287 #define GLM_DETAIL_IS_MATRIX(T) \
    00288         template <>                                     \
    00289         struct is_matrix                        \
    00290         {                                                       \
    00291                 enum is_matrix_enum             \
    00292                 {                                               \
    00293                         _YES = 1,                       \
    00294                         _NO = 0                         \
    00295                 };                                              \
    00296         }
    00297
    00299         // type
    00300
    00301         template <typename T>
    00302         struct type
    00303         {
    00304                 enum type_enum
    00305                 {
    00306                         is_float = is_float<T>::_YES,
    00307                         is_int = is_int<T>::_YES,
    00308                         is_uint = is_uint<T>::_YES,
    00309                         is_bool = is_bool<T>::_YES
    00310                 };
    00311         };
    00312
    00314         // type
    00315
    00316         typedef signed char                                                     int8;
    00317         typedef signed short                                            int16;
    00318         typedef signed int                                                      int32;
    00319         typedef detail::sint64                                          int64;
    00320
    00321         typedef unsigned char                                           uint8;
    00322         typedef unsigned short                                          uint16;
    00323         typedef unsigned int                                            uint32;
    00324         typedef detail::uint64                                          uint64;
    00325
    00326         typedef detail::thalf                                           float16;
    00327         typedef float                                                           float32;
    00328         typedef double                                                          float64;
    00329
    00330 }//namespace detail
    00331 }//namespace glm
    00332
    00333 #if((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2005))
    00334 #       define GLM_DEPRECATED __declspec(deprecated)
    00335 #       define GLM_ALIGN(x) __declspec(align(x))
    00336 #       define GLM_ALIGNED_STRUCT(x) __declspec(align(x)) struct
    00337 #       define GLM_RESTRICT __declspec(restrict)
    00338 #       define GLM_RESTRICT_VAR __restrict
    00339 #elif((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC31))
    00340 #       define GLM_DEPRECATED __attribute__((__deprecated__))
    00341 #       define GLM_ALIGN(x) __attribute__((aligned(x)))
    00342 #       define GLM_ALIGNED_STRUCT(x) struct __attribute__((aligned(x)))
    00343 #       if(GLM_COMPILER >= GLM_COMPILER_GCC33)
    00344 #               define GLM_RESTRICT __restrict__
    00345 #               define GLM_RESTRICT_VAR __restrict__
    00346 #       else
    00347 #               define GLM_RESTRICT
    00348 #               define GLM_RESTRICT_VAR
    00349 #       endif
    00350 #       define GLM_RESTRICT __restrict__
    00351 #       define GLM_RESTRICT_VAR __restrict__
    00352 #else
    00353 #       define GLM_DEPRECATED
    00354 #       define GLM_ALIGN
    00355 #       define GLM_ALIGNED_STRUCT(x)
    00356 #       define GLM_RESTRICT
    00357 #       define GLM_RESTRICT_VAR
    00358 #endif//GLM_COMPILER
    00359
    00360 #endif//glm_core_detail