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