• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/// @ref gtx_matrix_major_storage
2/// @file glm/gtx/matrix_major_storage.hpp
3
4namespace glm
5{
6	template <typename T, precision P>
7	GLM_FUNC_QUALIFIER tmat2x2<T, P> rowMajor2
8	(
9		tvec2<T, P> const & v1,
10		tvec2<T, P> const & v2
11	)
12	{
13		tmat2x2<T, P> Result;
14		Result[0][0] = v1.x;
15		Result[1][0] = v1.y;
16		Result[0][1] = v2.x;
17		Result[1][1] = v2.y;
18		return Result;
19	}
20
21	template <typename T, precision P>
22	GLM_FUNC_QUALIFIER tmat2x2<T, P> rowMajor2(
23		const tmat2x2<T, P>& m)
24	{
25		tmat2x2<T, P> Result;
26		Result[0][0] = m[0][0];
27		Result[0][1] = m[1][0];
28		Result[1][0] = m[0][1];
29		Result[1][1] = m[1][1];
30		return Result;
31	}
32
33	template <typename T, precision P>
34	GLM_FUNC_QUALIFIER tmat3x3<T, P> rowMajor3(
35		const tvec3<T, P>& v1,
36		const tvec3<T, P>& v2,
37		const tvec3<T, P>& v3)
38	{
39		tmat3x3<T, P> Result;
40		Result[0][0] = v1.x;
41		Result[1][0] = v1.y;
42		Result[2][0] = v1.z;
43		Result[0][1] = v2.x;
44		Result[1][1] = v2.y;
45		Result[2][1] = v2.z;
46		Result[0][2] = v3.x;
47		Result[1][2] = v3.y;
48		Result[2][2] = v3.z;
49		return Result;
50	}
51
52	template <typename T, precision P>
53	GLM_FUNC_QUALIFIER tmat3x3<T, P> rowMajor3(
54		const tmat3x3<T, P>& m)
55	{
56		tmat3x3<T, P> Result;
57		Result[0][0] = m[0][0];
58		Result[0][1] = m[1][0];
59		Result[0][2] = m[2][0];
60		Result[1][0] = m[0][1];
61		Result[1][1] = m[1][1];
62		Result[1][2] = m[2][1];
63		Result[2][0] = m[0][2];
64		Result[2][1] = m[1][2];
65		Result[2][2] = m[2][2];
66		return Result;
67	}
68
69	template <typename T, precision P>
70	GLM_FUNC_QUALIFIER tmat4x4<T, P> rowMajor4(
71		const tvec4<T, P>& v1,
72		const tvec4<T, P>& v2,
73		const tvec4<T, P>& v3,
74		const tvec4<T, P>& v4)
75	{
76		tmat4x4<T, P> Result;
77		Result[0][0] = v1.x;
78		Result[1][0] = v1.y;
79		Result[2][0] = v1.z;
80		Result[3][0] = v1.w;
81		Result[0][1] = v2.x;
82		Result[1][1] = v2.y;
83		Result[2][1] = v2.z;
84		Result[3][1] = v2.w;
85		Result[0][2] = v3.x;
86		Result[1][2] = v3.y;
87		Result[2][2] = v3.z;
88		Result[3][2] = v3.w;
89		Result[0][3] = v4.x;
90		Result[1][3] = v4.y;
91		Result[2][3] = v4.z;
92		Result[3][3] = v4.w;
93		return Result;
94	}
95
96	template <typename T, precision P>
97	GLM_FUNC_QUALIFIER tmat4x4<T, P> rowMajor4(
98		const tmat4x4<T, P>& m)
99	{
100		tmat4x4<T, P> Result;
101		Result[0][0] = m[0][0];
102		Result[0][1] = m[1][0];
103		Result[0][2] = m[2][0];
104		Result[0][3] = m[3][0];
105		Result[1][0] = m[0][1];
106		Result[1][1] = m[1][1];
107		Result[1][2] = m[2][1];
108		Result[1][3] = m[3][1];
109		Result[2][0] = m[0][2];
110		Result[2][1] = m[1][2];
111		Result[2][2] = m[2][2];
112		Result[2][3] = m[3][2];
113		Result[3][0] = m[0][3];
114		Result[3][1] = m[1][3];
115		Result[3][2] = m[2][3];
116		Result[3][3] = m[3][3];
117		return Result;
118	}
119
120	template <typename T, precision P>
121	GLM_FUNC_QUALIFIER tmat2x2<T, P> colMajor2(
122		const tvec2<T, P>& v1,
123		const tvec2<T, P>& v2)
124	{
125		return tmat2x2<T, P>(v1, v2);
126	}
127
128	template <typename T, precision P>
129	GLM_FUNC_QUALIFIER tmat2x2<T, P> colMajor2(
130		const tmat2x2<T, P>& m)
131	{
132		return tmat2x2<T, P>(m);
133	}
134
135	template <typename T, precision P>
136	GLM_FUNC_QUALIFIER tmat3x3<T, P> colMajor3(
137		const tvec3<T, P>& v1,
138		const tvec3<T, P>& v2,
139		const tvec3<T, P>& v3)
140	{
141		return tmat3x3<T, P>(v1, v2, v3);
142	}
143
144	template <typename T, precision P>
145	GLM_FUNC_QUALIFIER tmat3x3<T, P> colMajor3(
146		const tmat3x3<T, P>& m)
147	{
148		return tmat3x3<T, P>(m);
149	}
150
151	template <typename T, precision P>
152	GLM_FUNC_QUALIFIER tmat4x4<T, P> colMajor4(
153		const tvec4<T, P>& v1,
154		const tvec4<T, P>& v2,
155		const tvec4<T, P>& v3,
156		const tvec4<T, P>& v4)
157	{
158		return tmat4x4<T, P>(v1, v2, v3, v4);
159	}
160
161	template <typename T, precision P>
162	GLM_FUNC_QUALIFIER tmat4x4<T, P> colMajor4(
163		const tmat4x4<T, P>& m)
164	{
165		return tmat4x4<T, P>(m);
166	}
167}//namespace glm
168