0.9.9 API documenation

- Main Page
- Modules
- Files

- File List

_vectorize.hpp
Go to the documentation of this file.
1
4 #pragma once
5
6 #include "type_vec1.hpp"
7 #include "type_vec2.hpp"
8 #include "type_vec3.hpp"
9 #include "type_vec4.hpp"
10
11 namespace glm{
12 namespace detail
13 {
14 template<length_t L, typename R, typename T, qualifier Q>
15 struct functor1{};
16
17 template<typename R, typename T, qualifier Q>
18 struct functor1<1, R, T, Q>
19 {
20 GLM_FUNC_QUALIFIER static vec<1, R, Q> call(R (*Func) (T x), vec<1, T, Q> const& v)
21 {
22 return vec<1, R, Q>(Func(v.x));
23 }
24 };
25
26 template<typename R, typename T, qualifier Q>
27 struct functor1<2, R, T, Q>
28 {
29 GLM_FUNC_QUALIFIER static vec<2, R, Q> call(R (*Func) (T x), vec<2, T, Q> const& v)
30 {
31 return vec<2, R, Q>(Func(v.x), Func(v.y));
32 }
33 };
34
35 template<typename R, typename T, qualifier Q>
36 struct functor1<3, R, T, Q>
37 {
38 GLM_FUNC_QUALIFIER static vec<3, R, Q> call(R (*Func) (T x), vec<3, T, Q> const& v)
39 {
40 return vec<3, R, Q>(Func(v.x), Func(v.y), Func(v.z));
41 }
42 };
43
44 template<typename R, typename T, qualifier Q>
45 struct functor1<4, R, T, Q>
46 {
47 GLM_FUNC_QUALIFIER static vec<4, R, Q> call(R (*Func) (T x), vec<4, T, Q> const& v)
48 {
49 return vec<4, R, Q>(Func(v.x), Func(v.y), Func(v.z), Func(v.w));
50 }
51 };
52
53 template<length_t L, typename T, qualifier Q>
54 struct functor2{};
55
56 template<typename T, qualifier Q>
57 struct functor2<1, T, Q>
58 {
59 GLM_FUNC_QUALIFIER static vec<1, T, Q> call(T (*Func) (T x, T y), vec<1, T, Q> const& a, vec<1, T, Q> const& b)
60 {
61 return vec<1, T, Q>(Func(a.x, b.x));
62 }
63 };
64
65 template<typename T, qualifier Q>
66 struct functor2<2, T, Q>
67 {
68 GLM_FUNC_QUALIFIER static vec<2, T, Q> call(T (*Func) (T x, T y), vec<2, T, Q> const& a, vec<2, T, Q> const& b)
69 {
70 return vec<2, T, Q>(Func(a.x, b.x), Func(a.y, b.y));
71 }
72 };
73
74 template<typename T, qualifier Q>
75 struct functor2<3, T, Q>
76 {
77 GLM_FUNC_QUALIFIER static vec<3, T, Q> call(T (*Func) (T x, T y), vec<3, T, Q> const& a, vec<3, T, Q> const& b)
78 {
79 return vec<3, T, Q>(Func(a.x, b.x), Func(a.y, b.y), Func(a.z, b.z));
80 }
81 };
82
83 template<typename T, qualifier Q>
84 struct functor2<4, T, Q>
85 {
86 GLM_FUNC_QUALIFIER static vec<4, T, Q> call(T (*Func) (T x, T y), vec<4, T, Q> const& a, vec<4, T, Q> const& b)
87 {
88 return vec<4, T, Q>(Func(a.x, b.x), Func(a.y, b.y), Func(a.z, b.z), Func(a.w, b.w));
89 }
90 };
91
92 template<length_t L, typename T, qualifier Q>
93 struct functor2_vec_sca{};
94
95 template<typename T, qualifier Q>
96 struct functor2_vec_sca<1, T, Q>
97 {
98 GLM_FUNC_QUALIFIER static vec<1, T, Q> call(T (*Func) (T x, T y), vec<1, T, Q> const& a, T b)
99 {
100 return vec<1, T, Q>(Func(a.x, b));
101 }
102 };
103
104 template<typename T, qualifier Q>
105 struct functor2_vec_sca<2, T, Q>
106 {
107 GLM_FUNC_QUALIFIER static vec<2, T, Q> call(T (*Func) (T x, T y), vec<2, T, Q> const& a, T b)
108 {
109 return vec<2, T, Q>(Func(a.x, b), Func(a.y, b));
110 }
111 };
112
113 template<typename T, qualifier Q>
114 struct functor2_vec_sca<3, T, Q>
115 {
116 GLM_FUNC_QUALIFIER static vec<3, T, Q> call(T (*Func) (T x, T y), vec<3, T, Q> const& a, T b)
117 {
118 return vec<3, T, Q>(Func(a.x, b), Func(a.y, b), Func(a.z, b));
119 }
120 };
121
122 template<typename T, qualifier Q>
123 struct functor2_vec_sca<4, T, Q>
124 {
125 GLM_FUNC_QUALIFIER static vec<4, T, Q> call(T (*Func) (T x, T y), vec<4, T, Q> const& a, T b)
126 {
127 return vec<4, T, Q>(Func(a.x, b), Func(a.y, b), Func(a.z, b), Func(a.w, b));
128 }
129 };
130 }//namespace detail
131 }//namespace glm
type_vec4.hpp
Core features
type_vec2.hpp
Core features
glm
Definition: common.hpp:20
type_vec3.hpp
Core features
type_vec1.hpp
Core features