00001
00002
00004
00005
00006
00007
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
00028
00029
00030
00031
00032
00033
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
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
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
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
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
00202
00204
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
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
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
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
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
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 }
00331 }
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