• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 ///////////////////////////////////////////////////////////////////////////////////
2 /// OpenGL Mathematics (glm.g-truc.net)
3 ///
4 /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
5 /// Permission is hereby granted, free of charge, to any person obtaining a copy
6 /// of this software and associated documentation files (the "Software"), to deal
7 /// in the Software without restriction, including without limitation the rights
8 /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 /// copies of the Software, and to permit persons to whom the Software is
10 /// furnished to do so, subject to the following conditions:
11 ///
12 /// The above copyright notice and this permission notice shall be included in
13 /// all copies or substantial portions of the Software.
14 ///
15 /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 /// THE SOFTWARE.
22 ///
23 /// @ref core
24 /// @file glm/core/type_int.hpp
25 /// @date 2008-08-22 / 2013-03-30
26 /// @author Christophe Riccio
27 ///////////////////////////////////////////////////////////////////////////////////
28 
29 #ifndef glm_core_type_int
30 #define glm_core_type_int
31 
32 #include "setup.hpp"
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 | GLM_COMPILER_LLVM_GCC | GLM_COMPILER_CLANG))
59 			__extension__ typedef signed long long		sint64;
60 			__extension__ typedef unsigned long long	uint64;
61 #		elif(GLM_COMPILER & GLM_COMPILER_BC)
62 			typedef Int64					sint64;
63 			typedef Uint64					uint64;
64 #		else//unknown compiler
65 			typedef signed long	long		sint64;
66 			typedef unsigned long long		uint64;
67 #		endif//GLM_COMPILER
68 
69 		typedef signed char					int8;
70 		typedef signed short				int16;
71 		typedef signed int					int32;
72 		typedef sint64						int64;
73 
74 		typedef unsigned char				uint8;
75 		typedef unsigned short				uint16;
76 		typedef unsigned int				uint32;
77 		typedef uint64						uint64;
78 #endif//
79 
80 	typedef signed int						lowp_int_t;
81 	typedef signed int						mediump_int_t;
82 	typedef signed int						highp_int_t;
83 
84 	typedef unsigned int					lowp_uint_t;
85 	typedef unsigned int					mediump_uint_t;
86 	typedef unsigned int					highp_uint_t;
87 }//namespace detail
88 
89 	typedef detail::int8					int8;
90 	typedef detail::int16					int16;
91 	typedef detail::int32					int32;
92 	typedef detail::int64					int64;
93 
94 	typedef detail::uint8					uint8;
95 	typedef detail::uint16					uint16;
96 	typedef detail::uint32					uint32;
97 	typedef detail::uint64					uint64;
98 
99 	/// @addtogroup core_precision
100 	/// @{
101 
102 	/// Low precision signed integer.
103 	/// There is no guarantee on the actual precision.
104 	///
105 	/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.3 Integers</a>
106 	/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
107 	typedef detail::lowp_int_t				lowp_int;
108 
109 	/// Medium precision signed integer.
110 	/// There is no guarantee on the actual precision.
111 	///
112 	/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.3 Integers</a>
113 	/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
114 	typedef detail::mediump_int_t			mediump_int;
115 
116 	/// High precision signed integer.
117 	/// There is no guarantee on the actual precision.
118 	///
119 	/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.3 Integers</a>
120 	/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
121 	typedef detail::highp_int_t				highp_int;
122 
123 	/// Low precision unsigned integer.
124 	/// There is no guarantee on the actual precision.
125 	///
126 	/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.3 Integers</a>
127 	/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
128 	typedef detail::lowp_uint_t				lowp_uint;
129 
130 	/// Medium precision unsigned integer.
131 	/// There is no guarantee on the actual precision.
132 	///
133 	/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.3 Integers</a>
134 	/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
135 	typedef detail::mediump_uint_t			mediump_uint;
136 
137 	/// High precision unsigned integer.
138 	/// There is no guarantee on the actual precision.
139 	///
140 	/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.3 Integers</a>
141 	/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
142 	typedef detail::highp_uint_t			highp_uint;
143 
144 #if(!defined(GLM_PRECISION_HIGHP_INT) && !defined(GLM_PRECISION_MEDIUMP_INT) && !defined(GLM_PRECISION_LOWP_INT))
145 	typedef mediump_int					int_t;
146 #elif(defined(GLM_PRECISION_HIGHP_INT) && !defined(GLM_PRECISION_MEDIUMP_INT) && !defined(GLM_PRECISION_LOWP_INT))
147 	typedef highp_int					int_t;
148 #elif(!defined(GLM_PRECISION_HIGHP_INT) && defined(GLM_PRECISION_MEDIUMP_INT) && !defined(GLM_PRECISION_LOWP_INT))
149 	typedef mediump_int					int_t;
150 #elif(!defined(GLM_PRECISION_HIGHP_INT) && !defined(GLM_PRECISION_MEDIUMP_INT) && defined(GLM_PRECISION_LOWP_INT))
151 	typedef lowp_int					int_t;
152 #else
153 #	error "GLM error: multiple default precision requested for signed interger types"
154 #endif
155 
156 #if(!defined(GLM_PRECISION_HIGHP_UINT) && !defined(GLM_PRECISION_MEDIUMP_UINT) && !defined(GLM_PRECISION_LOWP_UINT))
157 	typedef mediump_uint				uint_t;
158 #elif(defined(GLM_PRECISION_HIGHP_UINT) && !defined(GLM_PRECISION_MEDIUMP_UINT) && !defined(GLM_PRECISION_LOWP_UINT))
159 	typedef highp_uint					uint_t;
160 #elif(!defined(GLM_PRECISION_HIGHP_UINT) && defined(GLM_PRECISION_MEDIUMP_UINT) && !defined(GLM_PRECISION_LOWP_UINT))
161 	typedef mediump_uint				uint_t;
162 #elif(!defined(GLM_PRECISION_HIGHP_UINT) && !defined(GLM_PRECISION_MEDIUMP_UINT) && defined(GLM_PRECISION_LOWP_UINT))
163 	typedef lowp_uint					uint_t;
164 #else
165 #	error "GLM error: multiple default precision requested for unsigned interger types"
166 #endif
167 
168 	/// Unsigned integer type.
169 	///
170 	/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.3 Integers</a>
171 	typedef unsigned int				uint;
172 
173 	/// @}
174 
175 ////////////////////
176 // check type sizes
177 #ifndef GLM_STATIC_ASSERT_NULL
178 	GLM_STATIC_ASSERT(sizeof(glm::int8) == 1, "int8 size isn't 1 byte on this platform");
179 	GLM_STATIC_ASSERT(sizeof(glm::int16) == 2, "int16 size isn't 2 bytes on this platform");
180 	GLM_STATIC_ASSERT(sizeof(glm::int32) == 4, "int32 size isn't 4 bytes on this platform");
181 	GLM_STATIC_ASSERT(sizeof(glm::int64) == 8, "int64 size isn't 8 bytes on this platform");
182 
183 	GLM_STATIC_ASSERT(sizeof(glm::uint8) == 1, "uint8 size isn't 1 byte on this platform");
184 	GLM_STATIC_ASSERT(sizeof(glm::uint16) == 2, "uint16 size isn't 2 bytes on this platform");
185 	GLM_STATIC_ASSERT(sizeof(glm::uint32) == 4, "uint32 size isn't 4 bytes on this platform");
186 	GLM_STATIC_ASSERT(sizeof(glm::uint64) == 8, "uint64 size isn't 8 bytes on this platform");
187 #endif//GLM_STATIC_ASSERT_NULL
188 
189 }//namespace glm
190 
191 #endif//glm_core_type_int
192