| 0.9.6

- Main Page
- Modules
- Files

- File List

_vectorize.hpp
Go to the documentation of this file.
1
33 #pragma once
34
35 #include "type_vec1.hpp"
36 #include "type_vec2.hpp"
37 #include "type_vec3.hpp"
38 #include "type_vec4.hpp"
39
40 namespace glm{
41 namespace detail
42 {
43 template <typename R, typename T, precision P, template <typename, precision> class vecType>
44 struct functor1{};
45
46 template <typename R, typename T, precision P>
47 struct functor1<R, T, P, tvec1>
48 {
49 GLM_FUNC_QUALIFIER static tvec1<R, P> call(R (*Func) (T x), tvec1<T, P> const & v)
50 {
51 return tvec1<R, P>(Func(v.x));
52 }
53 };
54
55 template <typename R, typename T, precision P>
56 struct functor1<R, T, P, tvec2>
57 {
58 GLM_FUNC_QUALIFIER static tvec2<R, P> call(R (*Func) (T x), tvec2<T, P> const & v)
59 {
60 return tvec2<R, P>(Func(v.x), Func(v.y));
61 }
62 };
63
64 template <typename R, typename T, precision P>
65 struct functor1<R, T, P, tvec3>
66 {
67 GLM_FUNC_QUALIFIER static tvec3<R, P> call(R (*Func) (T x), tvec3<T, P> const & v)
68 {
69 return tvec3<R, P>(Func(v.x), Func(v.y), Func(v.z));
70 }
71 };
72
73 template <typename R, typename T, precision P>
74 struct functor1<R, T, P, tvec4>
75 {
76 GLM_FUNC_QUALIFIER static tvec4<R, P> call(R (*Func) (T x), tvec4<T, P> const & v)
77 {
78 return tvec4<R, P>(Func(v.x), Func(v.y), Func(v.z), Func(v.w));
79 }
80 };
81
82 template <typename T, precision P, template <typename, precision> class vecType>
83 struct functor2{};
84
85 template <typename T, precision P>
86 struct functor2<T, P, tvec1>
87 {
88 GLM_FUNC_QUALIFIER static tvec1<T, P> call(T (*Func) (T x, T y), tvec1<T, P> const & a, tvec1<T, P> const & b)
89 {
90 return tvec1<T, P>(Func(a.x, b.x));
91 }
92 };
93
94 template <typename T, precision P>
95 struct functor2<T, P, tvec2>
96 {
97 GLM_FUNC_QUALIFIER static tvec2<T, P> call(T (*Func) (T x, T y), tvec2<T, P> const & a, tvec2<T, P> const & b)
98 {
99 return tvec2<T, P>(Func(a.x, b.x), Func(a.y, b.y));
100 }
101 };
102
103 template <typename T, precision P>
104 struct functor2<T, P, tvec3>
105 {
106 GLM_FUNC_QUALIFIER static tvec3<T, P> call(T (*Func) (T x, T y), tvec3<T, P> const & a, tvec3<T, P> const & b)
107 {
108 return tvec3<T, P>(Func(a.x, b.x), Func(a.y, b.y), Func(a.z, b.z));
109 }
110 };
111
112 template <typename T, precision P>
113 struct functor2<T, P, tvec4>
114 {
115 GLM_FUNC_QUALIFIER static tvec4<T, P> call(T (*Func) (T x, T y), tvec4<T, P> const & a, tvec4<T, P> const & b)
116 {
117 return tvec4<T, P>(Func(a.x, b.x), Func(a.y, b.y), Func(a.z, b.z), Func(a.w, b.w));
118 }
119 };
120
121 template <typename T, precision P, template <typename, precision> class vecType>
122 struct functor2_vec_sca{};
123
124 template <typename T, precision P>
125 struct functor2_vec_sca<T, P, tvec1>
126 {
127 GLM_FUNC_QUALIFIER static tvec1<T, P> call(T (*Func) (T x, T y), tvec1<T, P> const & a, T b)
128 {
129 return tvec1<T, P>(Func(a.x, b));
130 }
131 };
132
133 template <typename T, precision P>
134 struct functor2_vec_sca<T, P, tvec2>
135 {
136 GLM_FUNC_QUALIFIER static tvec2<T, P> call(T (*Func) (T x, T y), tvec2<T, P> const & a, T b)
137 {
138 return tvec2<T, P>(Func(a.x, b), Func(a.y, b));
139 }
140 };
141
142 template <typename T, precision P>
143 struct functor2_vec_sca<T, P, tvec3>
144 {
145 GLM_FUNC_QUALIFIER static tvec3<T, P> call(T (*Func) (T x, T y), tvec3<T, P> const & a, T b)
146 {
147 return tvec3<T, P>(Func(a.x, b), Func(a.y, b), Func(a.z, b));
148 }
149 };
150
151 template <typename T, precision P>
152 struct functor2_vec_sca<T, P, tvec4>
153 {
154 GLM_FUNC_QUALIFIER static tvec4<T, P> call(T (*Func) (T x, T y), tvec4<T, P> const & a, T b)
155 {
156 return tvec4<T, P>(Func(a.x, b), Func(a.y, b), Func(a.z, b), Func(a.w, b));
157 }
158 };
159 }//namespace detail
160 }//namespace glm
type_vec4.hpp
OpenGL Mathematics (glm.g-truc.net)
type_vec3.hpp
OpenGL Mathematics (glm.g-truc.net)
type_vec1.hpp
OpenGL Mathematics (glm.g-truc.net)
glm
Definition: _noise.hpp:39
type_vec2.hpp
OpenGL Mathematics (glm.g-truc.net)