0.9.6
type_int.hpp
Go to the documentation of this file.
1 
29 #pragma once
30 
31 #include "setup.hpp"
32 #include <type_traits>
33 
34 #if GLM_HAS_EXTENDED_INTEGER_TYPE
35 # include <cstdint>
36 #endif
37 
38 namespace glm{
39 namespace detail
40 {
41 # if GLM_HAS_EXTENDED_INTEGER_TYPE
42  typedef std::int8_t int8;
43  typedef std::int16_t int16;
44  typedef std::int32_t int32;
45  typedef std::int64_t int64;
46 
47  typedef std::uint8_t uint8;
48  typedef std::uint16_t uint16;
49  typedef std::uint32_t uint32;
50  typedef std::uint64_t uint64;
51 # else
52 # if(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) // C99 detected, 64 bit types available
53  typedef int64_t sint64;
54  typedef uint64_t uint64;
55 # elif GLM_COMPILER & GLM_COMPILER_VC
56  typedef signed __int64 sint64;
57  typedef unsigned __int64 uint64;
58 # elif GLM_COMPILER & GLM_COMPILER_GCC
59  __extension__ typedef signed long long sint64;
60  __extension__ typedef unsigned long long uint64;
61 # else//unknown compiler
62  typedef signed long long sint64;
63  typedef unsigned long long uint64;
64 # endif//GLM_COMPILER
65 
66  typedef signed char int8;
67  typedef signed short int16;
68  typedef signed int int32;
69  typedef sint64 int64;
70 
71  typedef unsigned char uint8;
72  typedef unsigned short uint16;
73  typedef unsigned int uint32;
74  typedef uint64 uint64;
75 #endif//
76 
77  typedef signed int lowp_int_t;
78  typedef signed int mediump_int_t;
79  typedef signed int highp_int_t;
80 
81  typedef unsigned int lowp_uint_t;
82  typedef unsigned int mediump_uint_t;
83  typedef unsigned int highp_uint_t;
84 
85 # if GLM_HAS_MAKE_SIGNED
86  using std::make_signed;
87  using std::make_unsigned;
88 
89 # else//GLM_HAS_MAKE_SIGNED
90  template <typename genType>
91  struct make_signed
92  {};
93 
94  template <>
95  struct make_signed<char>
96  {
97  typedef char type;
98  };
99 
100  template <>
101  struct make_signed<short>
102  {
103  typedef short type;
104  };
105 
106  template <>
107  struct make_signed<int>
108  {
109  typedef int type;
110  };
111 
112  template <>
113  struct make_signed<long>
114  {
115  typedef long type;
116  };
117 
118  template <>
119  struct make_signed<long long>
120  {
121  typedef long long type;
122  };
123 
124  template <>
125  struct make_signed<unsigned char>
126  {
127  typedef char type;
128  };
129 
130  template <>
131  struct make_signed<unsigned short>
132  {
133  typedef short type;
134  };
135 
136  template <>
137  struct make_signed<unsigned int>
138  {
139  typedef int type;
140  };
141 
142  template <>
143  struct make_signed<unsigned long>
144  {
145  typedef long type;
146  };
147 
148  template <>
149  struct make_signed<unsigned long long>
150  {
151  typedef long long type;
152  };
153 
154  template <typename genType>
155  struct make_unsigned
156  {};
157 
158  template <>
159  struct make_unsigned<char>
160  {
161  typedef unsigned char type;
162  };
163 
164  template <>
165  struct make_unsigned<short>
166  {
167  typedef unsigned short type;
168  };
169 
170  template <>
171  struct make_unsigned<int>
172  {
173  typedef unsigned int type;
174  };
175 
176  template <>
177  struct make_unsigned<long>
178  {
179  typedef unsigned long type;
180  };
181 
182  template <>
183  struct make_unsigned<long long>
184  {
185  typedef unsigned long long type;
186  };
187 
188  template <>
189  struct make_unsigned<unsigned char>
190  {
191  typedef unsigned char type;
192  };
193 
194  template <>
195  struct make_unsigned<unsigned short>
196  {
197  typedef unsigned short type;
198  };
199 
200  template <>
201  struct make_unsigned<unsigned int>
202  {
203  typedef unsigned int type;
204  };
205 
206  template <>
207  struct make_unsigned<unsigned long>
208  {
209  typedef unsigned long type;
210  };
211 
212  template <>
213  struct make_unsigned<unsigned long long>
214  {
215  typedef unsigned long long type;
216  };
217 # endif//GLM_HAS_MAKE_SIGNED
218 }//namespace detail
219 
220  typedef detail::int8 int8;
221  typedef detail::int16 int16;
222  typedef detail::int32 int32;
223  typedef detail::int64 int64;
224 
225  typedef detail::uint8 uint8;
226  typedef detail::uint16 uint16;
227  typedef detail::uint32 uint32;
228  typedef detail::uint64 uint64;
229 
232 
238  typedef detail::lowp_int_t lowp_int;
239 
245  typedef detail::mediump_int_t mediump_int;
246 
252  typedef detail::highp_int_t highp_int;
253 
259  typedef detail::lowp_uint_t lowp_uint;
260 
266  typedef detail::mediump_uint_t mediump_uint;
267 
273  typedef detail::highp_uint_t highp_uint;
274 
275 #if(!defined(GLM_PRECISION_HIGHP_INT) && !defined(GLM_PRECISION_MEDIUMP_INT) && !defined(GLM_PRECISION_LOWP_INT))
276  typedef mediump_int int_t;
277 #elif(defined(GLM_PRECISION_HIGHP_INT) && !defined(GLM_PRECISION_MEDIUMP_INT) && !defined(GLM_PRECISION_LOWP_INT))
278  typedef highp_int int_t;
279 #elif(!defined(GLM_PRECISION_HIGHP_INT) && defined(GLM_PRECISION_MEDIUMP_INT) && !defined(GLM_PRECISION_LOWP_INT))
280  typedef mediump_int int_t;
281 #elif(!defined(GLM_PRECISION_HIGHP_INT) && !defined(GLM_PRECISION_MEDIUMP_INT) && defined(GLM_PRECISION_LOWP_INT))
282  typedef lowp_int int_t;
283 #else
284 # error "GLM error: multiple default precision requested for signed interger types"
285 #endif
286 
287 #if(!defined(GLM_PRECISION_HIGHP_UINT) && !defined(GLM_PRECISION_MEDIUMP_UINT) && !defined(GLM_PRECISION_LOWP_UINT))
288  typedef mediump_uint uint_t;
289 #elif(defined(GLM_PRECISION_HIGHP_UINT) && !defined(GLM_PRECISION_MEDIUMP_UINT) && !defined(GLM_PRECISION_LOWP_UINT))
290  typedef highp_uint uint_t;
291 #elif(!defined(GLM_PRECISION_HIGHP_UINT) && defined(GLM_PRECISION_MEDIUMP_UINT) && !defined(GLM_PRECISION_LOWP_UINT))
292  typedef mediump_uint uint_t;
293 #elif(!defined(GLM_PRECISION_HIGHP_UINT) && !defined(GLM_PRECISION_MEDIUMP_UINT) && defined(GLM_PRECISION_LOWP_UINT))
294  typedef lowp_uint uint_t;
295 #else
296 # error "GLM error: multiple default precision requested for unsigned interger types"
297 #endif
298 
302  typedef unsigned int uint;
303 
305 
307 // check type sizes
308 #ifndef GLM_STATIC_ASSERT_NULL
309  GLM_STATIC_ASSERT(sizeof(glm::int8) == 1, "int8 size isn't 1 byte on this platform");
310  GLM_STATIC_ASSERT(sizeof(glm::int16) == 2, "int16 size isn't 2 bytes on this platform");
311  GLM_STATIC_ASSERT(sizeof(glm::int32) == 4, "int32 size isn't 4 bytes on this platform");
312  GLM_STATIC_ASSERT(sizeof(glm::int64) == 8, "int64 size isn't 8 bytes on this platform");
313 
314  GLM_STATIC_ASSERT(sizeof(glm::uint8) == 1, "uint8 size isn't 1 byte on this platform");
315  GLM_STATIC_ASSERT(sizeof(glm::uint16) == 2, "uint16 size isn't 2 bytes on this platform");
316  GLM_STATIC_ASSERT(sizeof(glm::uint32) == 4, "uint32 size isn't 4 bytes on this platform");
317  GLM_STATIC_ASSERT(sizeof(glm::uint64) == 8, "uint64 size isn't 8 bytes on this platform");
318 #endif//GLM_STATIC_ASSERT_NULL
319 
320 }//namespace glm
detail::int16 int16_t
16 bit signed integer type.
Definition: fwd.hpp:300
detail::int64 int64_t
64 bit signed integer type.
Definition: fwd.hpp:308
detail::mediump_int_t mediump_int
Medium precision signed integer.
Definition: type_int.hpp:245
detail::int8 int8
8 bit signed integer type.
Definition: type_int.hpp:220
unsigned int uint
Unsigned integer type.
Definition: type_int.hpp:302
detail::lowp_uint_t lowp_uint
Low precision unsigned integer.
Definition: type_int.hpp:259
detail::highp_int_t highp_int
High precision signed integer.
Definition: type_int.hpp:252
detail::uint8 uint8_t
8 bit unsigned integer type.
Definition: fwd.hpp:905
detail::int16 int16
16 bit signed integer type.
Definition: type_int.hpp:221
detail::int64 int64
64 bit signed integer type.
Definition: type_int.hpp:223
detail::int8 int8_t
8 bit signed integer type.
Definition: fwd.hpp:296
detail::uint16 uint16
16 bit unsigned integer type.
Definition: type_int.hpp:226
Definition: _noise.hpp:31
OpenGL Mathematics (glm.g-truc.net)
detail::lowp_int_t lowp_int
Low precision signed integer.
Definition: type_int.hpp:238
detail::uint64 uint64
64 bit unsigned integer type.
Definition: type_int.hpp:228
detail::uint8 uint8
8 bit unsigned integer type.
Definition: type_int.hpp:225
detail::uint32 uint32
32 bit unsigned integer type.
Definition: type_int.hpp:227
detail::uint32 uint32_t
32 bit unsigned integer type.
Definition: fwd.hpp:913
detail::int32 int32_t
32 bit signed integer type.
Definition: fwd.hpp:304
detail::uint64 uint64_t
64 bit unsigned integer type.
Definition: fwd.hpp:917
detail::mediump_uint_t mediump_uint
Medium precision unsigned integer.
Definition: type_int.hpp:266
detail::uint16 uint16_t
16 bit unsigned integer type.
Definition: fwd.hpp:909
detail::highp_uint_t highp_uint
High precision unsigned integer.
Definition: type_int.hpp:273
detail::int32 int32
32 bit signed integer type.
Definition: type_int.hpp:222