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(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
00053
00054
00055
00056
00057
00058
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 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
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
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
00192
00194
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
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
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
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
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
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 }
00321 }
00322
00323 #endif//glm_core_detail