0.9.8: _vectorize.hpp Source File

| 0.9.8

- 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 <typename R, typename T, precision P, template <typename, precision> class vecType>
15 struct functor1{};
16
17 template <typename R, typename T, precision P>
18 struct functor1<R, T, P, tvec1>
19 {
20 GLM_FUNC_QUALIFIER static tvec1<R, P> call(R (*Func) (T x), tvec1<T, P> const & v)
21 {
22 return tvec1<R, P>(Func(v.x));
23 }
24 };
25
26 template <typename R, typename T, precision P>
27 struct functor1<R, T, P, tvec2>
28 {
29 GLM_FUNC_QUALIFIER static tvec2<R, P> call(R (*Func) (T x), tvec2<T, P> const & v)
30 {
31 return tvec2<R, P>(Func(v.x), Func(v.y));
32 }
33 };
34
35 template <typename R, typename T, precision P>
36 struct functor1<R, T, P, tvec3>
37 {
38 GLM_FUNC_QUALIFIER static tvec3<R, P> call(R (*Func) (T x), tvec3<T, P> const & v)
39 {
40 return tvec3<R, P>(Func(v.x), Func(v.y), Func(v.z));
41 }
42 };
43
44 template <typename R, typename T, precision P>
45 struct functor1<R, T, P, tvec4>
46 {
47 GLM_FUNC_QUALIFIER static tvec4<R, P> call(R (*Func) (T x), tvec4<T, P> const & v)
48 {
49 return tvec4<R, P>(Func(v.x), Func(v.y), Func(v.z), Func(v.w));
50 }
51 };
52
53 template <typename T, precision P, template <typename, precision> class vecType>
54 struct functor2{};
55
56 template <typename T, precision P>
57 struct functor2<T, P, tvec1>
58 {
59 GLM_FUNC_QUALIFIER static tvec1<T, P> call(T (*Func) (T x, T y), tvec1<T, P> const & a, tvec1<T, P> const & b)
60 {
61 return tvec1<T, P>(Func(a.x, b.x));
62 }
63 };
64
65 template <typename T, precision P>
66 struct functor2<T, P, tvec2>
67 {
68 GLM_FUNC_QUALIFIER static tvec2<T, P> call(T (*Func) (T x, T y), tvec2<T, P> const & a, tvec2<T, P> const & b)
69 {
70 return tvec2<T, P>(Func(a.x, b.x), Func(a.y, b.y));
71 }
72 };
73
74 template <typename T, precision P>
75 struct functor2<T, P, tvec3>
76 {
77 GLM_FUNC_QUALIFIER static tvec3<T, P> call(T (*Func) (T x, T y), tvec3<T, P> const & a, tvec3<T, P> const & b)
78 {
79 return tvec3<T, P>(Func(a.x, b.x), Func(a.y, b.y), Func(a.z, b.z));
80 }
81 };
82
83 template <typename T, precision P>
84 struct functor2<T, P, tvec4>
85 {
86 GLM_FUNC_QUALIFIER static tvec4<T, P> call(T (*Func) (T x, T y), tvec4<T, P> const & a, tvec4<T, P> const & b)
87 {
88 return tvec4<T, P>(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 <typename T, precision P, template <typename, precision> class vecType>
93 struct functor2_vec_sca{};
94
95 template <typename T, precision P>
96 struct functor2_vec_sca<T, P, tvec1>
97 {
98 GLM_FUNC_QUALIFIER static tvec1<T, P> call(T (*Func) (T x, T y), tvec1<T, P> const & a, T b)
99 {
100 return tvec1<T, P>(Func(a.x, b));
101 }
102 };
103
104 template <typename T, precision P>
105 struct functor2_vec_sca<T, P, tvec2>
106 {
107 GLM_FUNC_QUALIFIER static tvec2<T, P> call(T (*Func) (T x, T y), tvec2<T, P> const & a, T b)
108 {
109 return tvec2<T, P>(Func(a.x, b), Func(a.y, b));
110 }
111 };
112
113 template <typename T, precision P>
114 struct functor2_vec_sca<T, P, tvec3>
115 {
116 GLM_FUNC_QUALIFIER static tvec3<T, P> call(T (*Func) (T x, T y), tvec3<T, P> const & a, T b)
117 {
118 return tvec3<T, P>(Func(a.x, b), Func(a.y, b), Func(a.z, b));
119 }
120 };
121
122 template <typename T, precision P>
123 struct functor2_vec_sca<T, P, tvec4>
124 {
125 GLM_FUNC_QUALIFIER static tvec4<T, P> call(T (*Func) (T x, T y), tvec4<T, P> const & a, T b)
126 {
127 return tvec4<T, P>(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_vec3.hpp
GLM Core
glm
Definition: _noise.hpp:11
type_vec2.hpp
GLM Core
type_vec4.hpp
GLM Core
type_vec1.hpp
GLM Core