1 | /// @ref gtc_type_ptr |
2 | /// @file glm/gtc/type_ptr.hpp |
3 | /// |
4 | /// @see core (dependence) |
5 | /// @see gtc_quaternion (dependence) |
6 | /// |
7 | /// @defgroup gtc_type_ptr GLM_GTC_type_ptr |
8 | /// @ingroup gtc |
9 | /// |
10 | /// Include <glm/gtc/type_ptr.hpp> to use the features of this extension. |
11 | /// |
12 | /// Handles the interaction between pointers and vector, matrix types. |
13 | /// |
14 | /// This extension defines an overloaded function, glm::value_ptr. It returns |
15 | /// a pointer to the memory layout of the object. Matrix types store their values |
16 | /// in column-major order. |
17 | /// |
18 | /// This is useful for uploading data to matrices or copying data to buffer objects. |
19 | /// |
20 | /// Example: |
21 | /// @code |
22 | /// #include <glm/glm.hpp> |
23 | /// #include <glm/gtc/type_ptr.hpp> |
24 | /// |
25 | /// glm::vec3 aVector(3); |
26 | /// glm::mat4 someMatrix(1.0); |
27 | /// |
28 | /// glUniform3fv(uniformLoc, 1, glm::value_ptr(aVector)); |
29 | /// glUniformMatrix4fv(uniformMatrixLoc, 1, GL_FALSE, glm::value_ptr(someMatrix)); |
30 | /// @endcode |
31 | /// |
32 | /// <glm/gtc/type_ptr.hpp> need to be included to use the features of this extension. |
33 | |
34 | #pragma once |
35 | |
36 | // Dependency: |
37 | #include "../gtc/quaternion.hpp" |
38 | #include "../gtc/vec1.hpp" |
39 | #include "../vec2.hpp" |
40 | #include "../vec3.hpp" |
41 | #include "../vec4.hpp" |
42 | #include "../mat2x2.hpp" |
43 | #include "../mat2x3.hpp" |
44 | #include "../mat2x4.hpp" |
45 | #include "../mat3x2.hpp" |
46 | #include "../mat3x3.hpp" |
47 | #include "../mat3x4.hpp" |
48 | #include "../mat4x2.hpp" |
49 | #include "../mat4x3.hpp" |
50 | #include "../mat4x4.hpp" |
51 | #include <cstring> |
52 | |
53 | #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) |
54 | # pragma message("GLM: GLM_GTC_type_ptr extension included") |
55 | #endif |
56 | |
57 | namespace glm |
58 | { |
59 | /// @addtogroup gtc_type_ptr |
60 | /// @{ |
61 | |
62 | /// Return the constant address to the data of the input parameter. |
63 | /// @see gtc_type_ptr |
64 | template<typename genType> |
65 | GLM_FUNC_DECL typename genType::value_type const * value_ptr(genType const& v); |
66 | |
67 | /// Build a vector from a pointer. |
68 | /// @see gtc_type_ptr |
69 | template <typename T, qualifier Q> |
70 | GLM_FUNC_DECL vec<1, T, Q> make_vec1(vec<1, T, Q> const& v); |
71 | |
72 | /// Build a vector from a pointer. |
73 | /// @see gtc_type_ptr |
74 | template <typename T, qualifier Q> |
75 | GLM_FUNC_DECL vec<1, T, Q> make_vec1(vec<2, T, Q> const& v); |
76 | |
77 | /// Build a vector from a pointer. |
78 | /// @see gtc_type_ptr |
79 | template <typename T, qualifier Q> |
80 | GLM_FUNC_DECL vec<1, T, Q> make_vec1(vec<3, T, Q> const& v); |
81 | |
82 | /// Build a vector from a pointer. |
83 | /// @see gtc_type_ptr |
84 | template <typename T, qualifier Q> |
85 | GLM_FUNC_DECL vec<1, T, Q> make_vec1(vec<4, T, Q> const& v); |
86 | |
87 | /// Build a vector from a pointer. |
88 | /// @see gtc_type_ptr |
89 | template <typename T, qualifier Q> |
90 | GLM_FUNC_DECL vec<2, T, Q> make_vec2(vec<1, T, Q> const& v); |
91 | |
92 | /// Build a vector from a pointer. |
93 | /// @see gtc_type_ptr |
94 | template <typename T, qualifier Q> |
95 | GLM_FUNC_DECL vec<2, T, Q> make_vec2(vec<2, T, Q> const& v); |
96 | |
97 | /// Build a vector from a pointer. |
98 | /// @see gtc_type_ptr |
99 | template <typename T, qualifier Q> |
100 | GLM_FUNC_DECL vec<2, T, Q> make_vec2(vec<3, T, Q> const& v); |
101 | |
102 | /// Build a vector from a pointer. |
103 | /// @see gtc_type_ptr |
104 | template <typename T, qualifier Q> |
105 | GLM_FUNC_DECL vec<2, T, Q> make_vec2(vec<4, T, Q> const& v); |
106 | |
107 | /// Build a vector from a pointer. |
108 | /// @see gtc_type_ptr |
109 | template <typename T, qualifier Q> |
110 | GLM_FUNC_DECL vec<3, T, Q> make_vec3(vec<1, T, Q> const& v); |
111 | |
112 | /// Build a vector from a pointer. |
113 | /// @see gtc_type_ptr |
114 | template <typename T, qualifier Q> |
115 | GLM_FUNC_DECL vec<3, T, Q> make_vec3(vec<2, T, Q> const& v); |
116 | |
117 | /// Build a vector from a pointer. |
118 | /// @see gtc_type_ptr |
119 | template <typename T, qualifier Q> |
120 | GLM_FUNC_DECL vec<3, T, Q> make_vec3(vec<3, T, Q> const& v); |
121 | |
122 | /// Build a vector from a pointer. |
123 | /// @see gtc_type_ptr |
124 | template <typename T, qualifier Q> |
125 | GLM_FUNC_DECL vec<3, T, Q> make_vec3(vec<4, T, Q> const& v); |
126 | |
127 | /// Build a vector from a pointer. |
128 | /// @see gtc_type_ptr |
129 | template <typename T, qualifier Q> |
130 | GLM_FUNC_DECL vec<4, T, Q> make_vec4(vec<1, T, Q> const& v); |
131 | |
132 | /// Build a vector from a pointer. |
133 | /// @see gtc_type_ptr |
134 | template <typename T, qualifier Q> |
135 | GLM_FUNC_DECL vec<4, T, Q> make_vec4(vec<2, T, Q> const& v); |
136 | |
137 | /// Build a vector from a pointer. |
138 | /// @see gtc_type_ptr |
139 | template <typename T, qualifier Q> |
140 | GLM_FUNC_DECL vec<4, T, Q> make_vec4(vec<3, T, Q> const& v); |
141 | |
142 | /// Build a vector from a pointer. |
143 | /// @see gtc_type_ptr |
144 | template <typename T, qualifier Q> |
145 | GLM_FUNC_DECL vec<4, T, Q> make_vec4(vec<4, T, Q> const& v); |
146 | |
147 | /// Build a vector from a pointer. |
148 | /// @see gtc_type_ptr |
149 | template<typename T> |
150 | GLM_FUNC_DECL vec<2, T, defaultp> make_vec2(T const * const ptr); |
151 | |
152 | /// Build a vector from a pointer. |
153 | /// @see gtc_type_ptr |
154 | template<typename T> |
155 | GLM_FUNC_DECL vec<3, T, defaultp> make_vec3(T const * const ptr); |
156 | |
157 | /// Build a vector from a pointer. |
158 | /// @see gtc_type_ptr |
159 | template<typename T> |
160 | GLM_FUNC_DECL vec<4, T, defaultp> make_vec4(T const * const ptr); |
161 | |
162 | /// Build a matrix from a pointer. |
163 | /// @see gtc_type_ptr |
164 | template<typename T> |
165 | GLM_FUNC_DECL mat<2, 2, T, defaultp> make_mat2x2(T const * const ptr); |
166 | |
167 | /// Build a matrix from a pointer. |
168 | /// @see gtc_type_ptr |
169 | template<typename T> |
170 | GLM_FUNC_DECL mat<2, 3, T, defaultp> make_mat2x3(T const * const ptr); |
171 | |
172 | /// Build a matrix from a pointer. |
173 | /// @see gtc_type_ptr |
174 | template<typename T> |
175 | GLM_FUNC_DECL mat<2, 4, T, defaultp> make_mat2x4(T const * const ptr); |
176 | |
177 | /// Build a matrix from a pointer. |
178 | /// @see gtc_type_ptr |
179 | template<typename T> |
180 | GLM_FUNC_DECL mat<3, 2, T, defaultp> make_mat3x2(T const * const ptr); |
181 | |
182 | /// Build a matrix from a pointer. |
183 | /// @see gtc_type_ptr |
184 | template<typename T> |
185 | GLM_FUNC_DECL mat<3, 3, T, defaultp> make_mat3x3(T const * const ptr); |
186 | |
187 | /// Build a matrix from a pointer. |
188 | /// @see gtc_type_ptr |
189 | template<typename T> |
190 | GLM_FUNC_DECL mat<3, 4, T, defaultp> make_mat3x4(T const * const ptr); |
191 | |
192 | /// Build a matrix from a pointer. |
193 | /// @see gtc_type_ptr |
194 | template<typename T> |
195 | GLM_FUNC_DECL mat<4, 2, T, defaultp> make_mat4x2(T const * const ptr); |
196 | |
197 | /// Build a matrix from a pointer. |
198 | /// @see gtc_type_ptr |
199 | template<typename T> |
200 | GLM_FUNC_DECL mat<4, 3, T, defaultp> make_mat4x3(T const * const ptr); |
201 | |
202 | /// Build a matrix from a pointer. |
203 | /// @see gtc_type_ptr |
204 | template<typename T> |
205 | GLM_FUNC_DECL mat<4, 4, T, defaultp> make_mat4x4(T const * const ptr); |
206 | |
207 | /// Build a matrix from a pointer. |
208 | /// @see gtc_type_ptr |
209 | template<typename T> |
210 | GLM_FUNC_DECL mat<2, 2, T, defaultp> make_mat2(T const * const ptr); |
211 | |
212 | /// Build a matrix from a pointer. |
213 | /// @see gtc_type_ptr |
214 | template<typename T> |
215 | GLM_FUNC_DECL mat<3, 3, T, defaultp> make_mat3(T const * const ptr); |
216 | |
217 | /// Build a matrix from a pointer. |
218 | /// @see gtc_type_ptr |
219 | template<typename T> |
220 | GLM_FUNC_DECL mat<4, 4, T, defaultp> make_mat4(T const * const ptr); |
221 | |
222 | /// Build a quaternion from a pointer. |
223 | /// @see gtc_type_ptr |
224 | template<typename T> |
225 | GLM_FUNC_DECL qua<T, defaultp> make_quat(T const * const ptr); |
226 | |
227 | /// @} |
228 | }//namespace glm |
229 | |
230 | #include "type_ptr.inl" |
231 | |