• 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 gtc_type_ptr
24 /// @file glm/gtc/type_ptr.hpp
25 /// @date 2009-05-06 / 2011-06-05
26 /// @author Christophe Riccio
27 ///
28 /// @see core (dependence)
29 /// @see gtc_half_float (dependence)
30 /// @see gtc_quaternion (dependence)
31 ///
32 /// @defgroup gtc_type_ptr GLM_GTC_type_ptr
33 /// @ingroup gtc
34 ///
35 /// @brief Handles the interaction between pointers and vector, matrix types.
36 ///
37 /// This extension defines an overloaded function, glm::value_ptr, which
38 /// takes any of the \ref core_template "core template types". It returns
39 /// a pointer to the memory layout of the object. Matrix types store their values
40 /// in column-major order.
41 ///
42 /// This is useful for uploading data to matrices or copying data to buffer objects.
43 ///
44 /// Example:
45 /// @code
46 /// #include <glm/glm.hpp>
47 /// #include <glm/gtc/type_ptr.hpp>
48 ///
49 /// glm::vec3 aVector(3);
50 /// glm::mat4 someMatrix(1.0);
51 ///
52 /// glUniform3fv(uniformLoc, 1, glm::value_ptr(aVector));
53 /// glUniformMatrix4fv(uniformMatrixLoc, 1, GL_FALSE, glm::value_ptr(someMatrix));
54 /// @endcode
55 ///
56 /// <glm/gtc/type_ptr.hpp> need to be included to use these functionalities.
57 ///////////////////////////////////////////////////////////////////////////////////
58 
59 #ifndef GLM_GTC_type_ptr
60 #define GLM_GTC_type_ptr
61 
62 // Dependency:
63 #include "../gtc/quaternion.hpp"
64 #include "../vec2.hpp"
65 #include "../vec3.hpp"
66 #include "../vec4.hpp"
67 #include "../mat2x2.hpp"
68 #include "../mat2x3.hpp"
69 #include "../mat2x4.hpp"
70 #include "../mat3x2.hpp"
71 #include "../mat3x3.hpp"
72 #include "../mat3x4.hpp"
73 #include "../mat4x2.hpp"
74 #include "../mat4x3.hpp"
75 #include "../mat4x4.hpp"
76 #include <cstring>
77 
78 #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
79 #	pragma message("GLM: GLM_GTC_type_ptr extension included")
80 #endif
81 
82 namespace glm
83 {
84 	/// @addtogroup gtc_type_ptr
85 	/// @{
86 
87 	/// Return the constant address to the data of the input parameter.
88 	/// @see gtc_type_ptr
89 	template<typename genType>
90 	GLM_FUNC_DECL typename genType::value_type const * value_ptr(genType const & vec);
91 
92 	/// Build a vector from a pointer.
93 	/// @see gtc_type_ptr
94 	template<typename T>
95 	GLM_FUNC_DECL detail::tvec2<T, defaultp> make_vec2(T const * const ptr);
96 
97 	/// Build a vector from a pointer.
98 	/// @see gtc_type_ptr
99 	template<typename T>
100 	GLM_FUNC_DECL detail::tvec3<T, defaultp> make_vec3(T const * const ptr);
101 
102 	/// Build a vector from a pointer.
103 	/// @see gtc_type_ptr
104 	template<typename T>
105 	GLM_FUNC_DECL detail::tvec4<T, defaultp> make_vec4(T const * const ptr);
106 
107 	/// Build a matrix from a pointer.
108 	/// @see gtc_type_ptr
109 	template<typename T>
110 	GLM_FUNC_DECL detail::tmat2x2<T, defaultp> make_mat2x2(T const * const ptr);
111 
112 	/// Build a matrix from a pointer.
113 	/// @see gtc_type_ptr
114 	template<typename T>
115 	GLM_FUNC_DECL detail::tmat2x3<T, defaultp> make_mat2x3(T const * const ptr);
116 
117 	/// Build a matrix from a pointer.
118 	/// @see gtc_type_ptr
119 	template<typename T>
120 	GLM_FUNC_DECL detail::tmat2x4<T, defaultp> make_mat2x4(T const * const ptr);
121 
122 	/// Build a matrix from a pointer.
123 	/// @see gtc_type_ptr
124 	template<typename T>
125 	GLM_FUNC_DECL detail::tmat3x2<T, defaultp> make_mat3x2(T const * const ptr);
126 
127 	/// Build a matrix from a pointer.
128 	/// @see gtc_type_ptr
129 	template<typename T>
130 	GLM_FUNC_DECL detail::tmat3x3<T, defaultp> make_mat3x3(T const * const ptr);
131 
132 	/// Build a matrix from a pointer.
133 	/// @see gtc_type_ptr
134 	template<typename T>
135 	GLM_FUNC_DECL detail::tmat3x4<T, defaultp> make_mat3x4(T const * const ptr);
136 
137 	/// Build a matrix from a pointer.
138 	/// @see gtc_type_ptr
139 	template<typename T>
140 	GLM_FUNC_DECL detail::tmat4x2<T, defaultp> make_mat4x2(
141 		T const * const ptr);
142 
143 	/// Build a matrix from a pointer.
144 	/// @see gtc_type_ptr
145 	template<typename T>
146 	GLM_FUNC_DECL detail::tmat4x3<T, defaultp> make_mat4x3(T const * const ptr);
147 
148 	/// Build a matrix from a pointer.
149 	/// @see gtc_type_ptr
150 	template<typename T>
151 	GLM_FUNC_DECL detail::tmat4x4<T, defaultp> make_mat4x4(T const * const ptr);
152 
153 	/// Build a matrix from a pointer.
154 	/// @see gtc_type_ptr
155 	template<typename T>
156 	GLM_FUNC_DECL detail::tmat2x2<T, defaultp> make_mat2(T const * const ptr);
157 
158 	/// Build a matrix from a pointer.
159 	/// @see gtc_type_ptr
160 	template<typename T>
161 	GLM_FUNC_DECL detail::tmat3x3<T, defaultp> make_mat3(T const * const ptr);
162 
163 	/// Build a matrix from a pointer.
164 	/// @see gtc_type_ptr
165 	template<typename T>
166 	GLM_FUNC_DECL detail::tmat4x4<T, defaultp> make_mat4(T const * const ptr);
167 
168 	/// Build a quaternion from a pointer.
169 	/// @see gtc_type_ptr
170 	template<typename T>
171 	GLM_FUNC_DECL detail::tquat<T, defaultp> make_quat(T const * const ptr);
172 
173 	/// @}
174 }//namespace glm
175 
176 #include "type_ptr.inl"
177 
178 #endif//GLM_GTC_type_ptr
179 
180