• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /// @ref gtc_type_ptr
2 /// @file glm/gtc/type_ptr.hpp
3 ///
4 /// @see core (dependence)
5 /// @see gtc_half_float (dependence)
6 /// @see gtc_quaternion (dependence)
7 ///
8 /// @defgroup gtc_type_ptr GLM_GTC_type_ptr
9 /// @ingroup gtc
10 ///
11 /// @brief Handles the interaction between pointers and vector, matrix types.
12 ///
13 /// This extension defines an overloaded function, glm::value_ptr, which
14 /// takes any of the \ref core_template "core template types". 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 these functionalities.
33 
34 #pragma once
35 
36 // Dependency:
37 #include "../gtc/quaternion.hpp"
38 #include "../vec2.hpp"
39 #include "../vec3.hpp"
40 #include "../vec4.hpp"
41 #include "../mat2x2.hpp"
42 #include "../mat2x3.hpp"
43 #include "../mat2x4.hpp"
44 #include "../mat3x2.hpp"
45 #include "../mat3x3.hpp"
46 #include "../mat3x4.hpp"
47 #include "../mat4x2.hpp"
48 #include "../mat4x3.hpp"
49 #include "../mat4x4.hpp"
50 #include <cstring>
51 
52 #if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
53 #	pragma message("GLM: GLM_GTC_type_ptr extension included")
54 #endif
55 
56 namespace glm
57 {
58 	/// @addtogroup gtc_type_ptr
59 	/// @{
60 
61 	/// Return the constant address to the data of the input parameter.
62 	/// @see gtc_type_ptr
63 	template<typename genType>
64 	GLM_FUNC_DECL typename genType::value_type const * value_ptr(genType const & vec);
65 
66 	/// Build a vector from a pointer.
67 	/// @see gtc_type_ptr
68 	template<typename T>
69 	GLM_FUNC_DECL tvec2<T, defaultp> make_vec2(T const * const ptr);
70 
71 	/// Build a vector from a pointer.
72 	/// @see gtc_type_ptr
73 	template<typename T>
74 	GLM_FUNC_DECL tvec3<T, defaultp> make_vec3(T const * const ptr);
75 
76 	/// Build a vector from a pointer.
77 	/// @see gtc_type_ptr
78 	template<typename T>
79 	GLM_FUNC_DECL tvec4<T, defaultp> make_vec4(T const * const ptr);
80 
81 	/// Build a matrix from a pointer.
82 	/// @see gtc_type_ptr
83 	template<typename T>
84 	GLM_FUNC_DECL tmat2x2<T, defaultp> make_mat2x2(T const * const ptr);
85 
86 	/// Build a matrix from a pointer.
87 	/// @see gtc_type_ptr
88 	template<typename T>
89 	GLM_FUNC_DECL tmat2x3<T, defaultp> make_mat2x3(T const * const ptr);
90 
91 	/// Build a matrix from a pointer.
92 	/// @see gtc_type_ptr
93 	template<typename T>
94 	GLM_FUNC_DECL tmat2x4<T, defaultp> make_mat2x4(T const * const ptr);
95 
96 	/// Build a matrix from a pointer.
97 	/// @see gtc_type_ptr
98 	template<typename T>
99 	GLM_FUNC_DECL tmat3x2<T, defaultp> make_mat3x2(T const * const ptr);
100 
101 	/// Build a matrix from a pointer.
102 	/// @see gtc_type_ptr
103 	template<typename T>
104 	GLM_FUNC_DECL tmat3x3<T, defaultp> make_mat3x3(T const * const ptr);
105 
106 	/// Build a matrix from a pointer.
107 	/// @see gtc_type_ptr
108 	template<typename T>
109 	GLM_FUNC_DECL tmat3x4<T, defaultp> make_mat3x4(T const * const ptr);
110 
111 	/// Build a matrix from a pointer.
112 	/// @see gtc_type_ptr
113 	template<typename T>
114 	GLM_FUNC_DECL tmat4x2<T, defaultp> make_mat4x2(T const * const ptr);
115 
116 	/// Build a matrix from a pointer.
117 	/// @see gtc_type_ptr
118 	template<typename T>
119 	GLM_FUNC_DECL tmat4x3<T, defaultp> make_mat4x3(T const * const ptr);
120 
121 	/// Build a matrix from a pointer.
122 	/// @see gtc_type_ptr
123 	template<typename T>
124 	GLM_FUNC_DECL tmat4x4<T, defaultp> make_mat4x4(T const * const ptr);
125 
126 	/// Build a matrix from a pointer.
127 	/// @see gtc_type_ptr
128 	template<typename T>
129 	GLM_FUNC_DECL tmat2x2<T, defaultp> make_mat2(T const * const ptr);
130 
131 	/// Build a matrix from a pointer.
132 	/// @see gtc_type_ptr
133 	template<typename T>
134 	GLM_FUNC_DECL tmat3x3<T, defaultp> make_mat3(T const * const ptr);
135 
136 	/// Build a matrix from a pointer.
137 	/// @see gtc_type_ptr
138 	template<typename T>
139 	GLM_FUNC_DECL tmat4x4<T, defaultp> make_mat4(T const * const ptr);
140 
141 	/// Build a quaternion from a pointer.
142 	/// @see gtc_type_ptr
143 	template<typename T>
144 	GLM_FUNC_DECL tquat<T, defaultp> make_quat(T const * const ptr);
145 
146 	/// @}
147 }//namespace glm
148 
149 #include "type_ptr.inl"
150