• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/// @ref gtc_type_ptr
2/// @file glm/gtc/type_ptr.inl
3
4#include <cstring>
5
6namespace glm
7{
8	/// @addtogroup gtc_type_ptr
9	/// @{
10
11	/// Return the constant address to the data of the vector input.
12	/// @see gtc_type_ptr
13	template<typename T, precision P>
14	GLM_FUNC_QUALIFIER T const * value_ptr
15	(
16		tvec2<T, P> const & vec
17	)
18	{
19		return &(vec.x);
20	}
21
22	//! Return the address to the data of the vector input.
23	/// @see gtc_type_ptr
24	template<typename T, precision P>
25	GLM_FUNC_QUALIFIER T * value_ptr
26	(
27		tvec2<T, P> & vec
28	)
29	{
30		return &(vec.x);
31	}
32
33	/// Return the constant address to the data of the vector input.
34	/// @see gtc_type_ptr
35	template<typename T, precision P>
36	GLM_FUNC_QUALIFIER T const * value_ptr
37	(
38		tvec3<T, P> const & vec
39	)
40	{
41		return &(vec.x);
42	}
43
44	//! Return the address to the data of the vector input.
45	/// @see gtc_type_ptr
46	template<typename T, precision P>
47	GLM_FUNC_QUALIFIER T * value_ptr
48	(
49		tvec3<T, P> & vec
50	)
51	{
52		return &(vec.x);
53	}
54
55	/// Return the constant address to the data of the vector input.
56	/// @see gtc_type_ptr
57	template<typename T, precision P>
58	GLM_FUNC_QUALIFIER T const * value_ptr
59	(
60		tvec4<T, P> const & vec
61	)
62	{
63		return &(vec.x);
64	}
65
66	//! Return the address to the data of the vector input.
67	//! From GLM_GTC_type_ptr extension.
68	template<typename T, precision P>
69	GLM_FUNC_QUALIFIER T * value_ptr
70	(
71		tvec4<T, P> & vec
72	)
73	{
74		return &(vec.x);
75	}
76
77	/// Return the constant address to the data of the matrix input.
78	/// @see gtc_type_ptr
79	template<typename T, precision P>
80	GLM_FUNC_QUALIFIER T const * value_ptr
81	(
82		tmat2x2<T, P> const & mat
83	)
84	{
85		return &(mat[0].x);
86	}
87
88	//! Return the address to the data of the matrix input.
89	/// @see gtc_type_ptr
90	template<typename T, precision P>
91	GLM_FUNC_QUALIFIER T * value_ptr
92	(
93		tmat2x2<T, P> & mat
94	)
95	{
96		return &(mat[0].x);
97	}
98
99	/// Return the constant address to the data of the matrix input.
100	/// @see gtc_type_ptr
101	template<typename T, precision P>
102	GLM_FUNC_QUALIFIER T const * value_ptr
103	(
104		tmat3x3<T, P> const & mat
105	)
106	{
107		return &(mat[0].x);
108	}
109
110	//! Return the address to the data of the matrix input.
111	/// @see gtc_type_ptr
112	template<typename T, precision P>
113	GLM_FUNC_QUALIFIER T * value_ptr
114	(
115		tmat3x3<T, P> & mat
116	)
117	{
118		return &(mat[0].x);
119	}
120
121	/// Return the constant address to the data of the matrix input.
122	/// @see gtc_type_ptr
123	template<typename T, precision P>
124	GLM_FUNC_QUALIFIER T const * value_ptr
125	(
126		tmat4x4<T, P> const & mat
127	)
128	{
129		return &(mat[0].x);
130	}
131
132	//! Return the address to the data of the matrix input.
133	//! From GLM_GTC_type_ptr extension.
134	template<typename T, precision P>
135	GLM_FUNC_QUALIFIER T * value_ptr
136	(
137		tmat4x4<T, P> & mat
138	)
139	{
140		return &(mat[0].x);
141	}
142
143	/// Return the constant address to the data of the matrix input.
144	/// @see gtc_type_ptr
145	template<typename T, precision P>
146	GLM_FUNC_QUALIFIER T const * value_ptr
147	(
148		tmat2x3<T, P> const & mat
149	)
150	{
151		return &(mat[0].x);
152	}
153
154	//! Return the address to the data of the matrix input.
155	/// @see gtc_type_ptr
156	template<typename T, precision P>
157	GLM_FUNC_QUALIFIER T * value_ptr
158	(
159		tmat2x3<T, P> & mat
160	)
161	{
162		return &(mat[0].x);
163	}
164
165	/// Return the constant address to the data of the matrix input.
166	/// @see gtc_type_ptr
167	template<typename T, precision P>
168	GLM_FUNC_QUALIFIER T const * value_ptr
169	(
170		tmat3x2<T, P> const & mat
171	)
172	{
173		return &(mat[0].x);
174	}
175
176	//! Return the address to the data of the matrix input.
177	/// @see gtc_type_ptr
178	template<typename T, precision P>
179	GLM_FUNC_QUALIFIER T * value_ptr
180	(
181		tmat3x2<T, P> & mat
182	)
183	{
184		return &(mat[0].x);
185	}
186
187	/// Return the constant address to the data of the matrix input.
188	/// @see gtc_type_ptr
189	template<typename T, precision P>
190	GLM_FUNC_QUALIFIER T const * value_ptr
191	(
192		tmat2x4<T, P> const & mat
193	)
194	{
195		return &(mat[0].x);
196	}
197
198	//! Return the address to the data of the matrix input.
199	/// @see gtc_type_ptr
200	template<typename T, precision P>
201	GLM_FUNC_QUALIFIER T * value_ptr
202	(
203		tmat2x4<T, P> & mat
204	)
205	{
206		return &(mat[0].x);
207	}
208
209	/// Return the constant address to the data of the matrix input.
210	/// @see gtc_type_ptr
211	template<typename T, precision P>
212	GLM_FUNC_QUALIFIER T const * value_ptr
213	(
214		tmat4x2<T, P> const & mat
215	)
216	{
217		return &(mat[0].x);
218	}
219
220	//! Return the address to the data of the matrix input.
221	/// @see gtc_type_ptr
222	template<typename T, precision P>
223	GLM_FUNC_QUALIFIER T * value_ptr
224	(
225		tmat4x2<T, P> & mat
226	)
227	{
228		return &(mat[0].x);
229	}
230
231	/// Return the constant address to the data of the matrix input.
232	/// @see gtc_type_ptr
233	template<typename T, precision P>
234	GLM_FUNC_QUALIFIER T const * value_ptr
235	(
236		tmat3x4<T, P> const & mat
237	)
238	{
239		return &(mat[0].x);
240	}
241
242	//! Return the address to the data of the matrix input.
243	/// @see gtc_type_ptr
244	template<typename T, precision P>
245	GLM_FUNC_QUALIFIER T * value_ptr
246	(
247		tmat3x4<T, P> & mat
248	)
249	{
250		return &(mat[0].x);
251	}
252
253	/// Return the constant address to the data of the matrix input.
254	/// @see gtc_type_ptr
255	template<typename T, precision P>
256	GLM_FUNC_QUALIFIER T const * value_ptr
257	(
258		tmat4x3<T, P> const & mat
259	)
260	{
261		return &(mat[0].x);
262	}
263
264	/// Return the address to the data of the matrix input.
265	/// @see gtc_type_ptr
266	template<typename T, precision P>
267	GLM_FUNC_QUALIFIER T * value_ptr(tmat4x3<T, P> & mat)
268	{
269		return &(mat[0].x);
270	}
271
272	/// Return the constant address to the data of the input parameter.
273	/// @see gtc_type_ptr
274	template<typename T, precision P>
275	GLM_FUNC_QUALIFIER T const * value_ptr
276	(
277		tquat<T, P> const & q
278	)
279	{
280		return &(q[0]);
281	}
282
283	/// Return the address to the data of the quaternion input.
284	/// @see gtc_type_ptr
285	template<typename T, precision P>
286	GLM_FUNC_QUALIFIER T * value_ptr
287	(
288		tquat<T, P> & q
289	)
290	{
291		return &(q[0]);
292	}
293
294	/// Build a vector from a pointer.
295	/// @see gtc_type_ptr
296	template <typename T>
297	GLM_FUNC_QUALIFIER tvec2<T, defaultp> make_vec2(T const * const ptr)
298	{
299		tvec2<T, defaultp> Result;
300		memcpy(value_ptr(Result), ptr, sizeof(tvec2<T, defaultp>));
301		return Result;
302	}
303
304	/// Build a vector from a pointer.
305	/// @see gtc_type_ptr
306	template <typename T>
307	GLM_FUNC_QUALIFIER tvec3<T, defaultp> make_vec3(T const * const ptr)
308	{
309		tvec3<T, defaultp> Result;
310		memcpy(value_ptr(Result), ptr, sizeof(tvec3<T, defaultp>));
311		return Result;
312	}
313
314	/// Build a vector from a pointer.
315	/// @see gtc_type_ptr
316	template <typename T>
317	GLM_FUNC_QUALIFIER tvec4<T, defaultp> make_vec4(T const * const ptr)
318	{
319		tvec4<T, defaultp> Result;
320		memcpy(value_ptr(Result), ptr, sizeof(tvec4<T, defaultp>));
321		return Result;
322	}
323
324	/// Build a matrix from a pointer.
325	/// @see gtc_type_ptr
326	template <typename T>
327	GLM_FUNC_QUALIFIER tmat2x2<T, defaultp> make_mat2x2(T const * const ptr)
328	{
329		tmat2x2<T, defaultp> Result;
330		memcpy(value_ptr(Result), ptr, sizeof(tmat2x2<T, defaultp>));
331		return Result;
332	}
333
334	/// Build a matrix from a pointer.
335	/// @see gtc_type_ptr
336	template <typename T>
337	GLM_FUNC_QUALIFIER tmat2x3<T, defaultp> make_mat2x3(T const * const ptr)
338	{
339		tmat2x3<T, defaultp> Result;
340		memcpy(value_ptr(Result), ptr, sizeof(tmat2x3<T, defaultp>));
341		return Result;
342	}
343
344	/// Build a matrix from a pointer.
345	/// @see gtc_type_ptr
346	template <typename T>
347	GLM_FUNC_QUALIFIER tmat2x4<T, defaultp> make_mat2x4(T const * const ptr)
348	{
349		tmat2x4<T, defaultp> Result;
350		memcpy(value_ptr(Result), ptr, sizeof(tmat2x4<T, defaultp>));
351		return Result;
352	}
353
354	/// Build a matrix from a pointer.
355	/// @see gtc_type_ptr
356	template <typename T>
357	GLM_FUNC_QUALIFIER tmat3x2<T, defaultp> make_mat3x2(T const * const ptr)
358	{
359		tmat3x2<T, defaultp> Result;
360		memcpy(value_ptr(Result), ptr, sizeof(tmat3x2<T, defaultp>));
361		return Result;
362	}
363
364	//! Build a matrix from a pointer.
365	/// @see gtc_type_ptr
366	template <typename T>
367	GLM_FUNC_QUALIFIER tmat3x3<T, defaultp> make_mat3x3(T const * const ptr)
368	{
369		tmat3x3<T, defaultp> Result;
370		memcpy(value_ptr(Result), ptr, sizeof(tmat3x3<T, defaultp>));
371		return Result;
372	}
373
374	//! Build a matrix from a pointer.
375	/// @see gtc_type_ptr
376	template <typename T>
377	GLM_FUNC_QUALIFIER tmat3x4<T, defaultp> make_mat3x4(T const * const ptr)
378	{
379		tmat3x4<T, defaultp> Result;
380		memcpy(value_ptr(Result), ptr, sizeof(tmat3x4<T, defaultp>));
381		return Result;
382	}
383
384	//! Build a matrix from a pointer.
385	/// @see gtc_type_ptr
386	template <typename T>
387	GLM_FUNC_QUALIFIER tmat4x2<T, defaultp> make_mat4x2(T const * const ptr)
388	{
389		tmat4x2<T, defaultp> Result;
390		memcpy(value_ptr(Result), ptr, sizeof(tmat4x2<T, defaultp>));
391		return Result;
392	}
393
394	//! Build a matrix from a pointer.
395	/// @see gtc_type_ptr
396	template <typename T>
397	GLM_FUNC_QUALIFIER tmat4x3<T, defaultp> make_mat4x3(T const * const ptr)
398	{
399		tmat4x3<T, defaultp> Result;
400		memcpy(value_ptr(Result), ptr, sizeof(tmat4x3<T, defaultp>));
401		return Result;
402	}
403
404	//! Build a matrix from a pointer.
405	/// @see gtc_type_ptr
406	template <typename T>
407	GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> make_mat4x4(T const * const ptr)
408	{
409		tmat4x4<T, defaultp> Result;
410		memcpy(value_ptr(Result), ptr, sizeof(tmat4x4<T, defaultp>));
411		return Result;
412	}
413
414	//! Build a matrix from a pointer.
415	/// @see gtc_type_ptr
416	template <typename T>
417	GLM_FUNC_QUALIFIER tmat2x2<T, defaultp> make_mat2(T const * const ptr)
418	{
419		return make_mat2x2(ptr);
420	}
421
422	//! Build a matrix from a pointer.
423	/// @see gtc_type_ptr
424	template <typename T>
425	GLM_FUNC_QUALIFIER tmat3x3<T, defaultp> make_mat3(T const * const ptr)
426	{
427		return make_mat3x3(ptr);
428	}
429
430	//! Build a matrix from a pointer.
431	/// @see gtc_type_ptr
432	template <typename T>
433	GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> make_mat4(T const * const ptr)
434	{
435		return make_mat4x4(ptr);
436	}
437
438	//! Build a quaternion from a pointer.
439	/// @see gtc_type_ptr
440	template <typename T>
441	GLM_FUNC_QUALIFIER tquat<T, defaultp> make_quat(T const * const ptr)
442	{
443		tquat<T, defaultp> Result;
444		memcpy(value_ptr(Result), ptr, sizeof(tquat<T, defaultp>));
445		return Result;
446	}
447
448	/// @}
449}//namespace glm
450
451