OGLplus  (0.59.0) a C++ wrapper for rendering APIs

functional_node.hpp
Go to the documentation of this file.
1 #ifndef OGLPLUS_TEXGEN_FUNCTIONAL_NODE_HPP
9 #define OGLPLUS_TEXGEN_FUNCTIONAL_NODE_HPP
10 
11 #include "base_node.hpp"
12 #include "fallback_input.hpp"
13 
14 namespace eagine::oglp::texgen {
15 
16 enum class unary_function {
17  radians,
18  degrees,
19  sin,
20  cos,
21  tan,
22  asin,
23  acos,
24  atan,
25  abs,
26  sign,
27  sqrt,
28  inversesqrt,
29  floor,
30  ceil,
31  exp,
32  exp2,
33  log,
34  log2,
35  negate,
36  length,
37  none
38 };
39 
40 class unary_function_output : public base_output {
41 private:
42  friend class unary_function_node;
43 
44  input_with_const_default<float[4]> _input;
45  unary_function _func;
46 
47 public:
48  unary_function_output(node_intf& parent, unary_function);
49 
50  unary_function_output(node_intf& parent)
51  : unary_function_output(parent, unary_function::none) {}
52 
53  string_view type_name() override;
54 
55  slot_data_type value_type() override;
56 
57  std::ostream& definitions(std::ostream& out, compile_context& ctxt) override;
58 };
59 
60 class unary_function_node
61  : public unary_single_output_node<
62  unary_function_output,
63  decltype(unary_function_output::_input),
64  &unary_function_output::_input> {
65 public:
66  unary_function_node& set_function(unary_function func) {
67  _output._func = func;
68  return *this;
69  }
70 
71  unary_function_node& set_value(float x, float y, float z, float w) {
72  _output._input.fallback().set(x, y, z, w);
73  return *this;
74  }
75 };
76 
77 enum class binary_function {
78  equal,
79  not_equal,
80  less,
81  less_equal,
82  greater,
83  greater_equal,
84  add,
85  subtract,
86  multiply,
87  divide,
88  modulo,
89  max,
90  min,
91  distance,
92  power,
93  dot,
94  average
95 };
96 
97 class binary_function_output : public base_output {
98 private:
99  friend class binary_function_node;
100 
101  input_with_const_default<float[4]> _input_a;
102  input_with_const_default<float[4]> _input_b;
103  binary_function _func;
104 
105 public:
106  binary_function_output(node_intf& parent, binary_function);
107 
108  binary_function_output(node_intf& parent)
109  : binary_function_output(parent, binary_function::average) {}
110 
111  string_view type_name() override;
112 
113  slot_data_type value_type() override;
114 
115  std::ostream& definitions(std::ostream& out, compile_context& ctxt) override;
116 };
117 
118 class binary_function_node
119  : public binary_single_output_node<
120  binary_function_output,
121  decltype(binary_function_output::_input_a),
122  &binary_function_output::_input_a,
123  decltype(binary_function_output::_input_b),
124  &binary_function_output::_input_b> {
125 public:
126  binary_function_node& set_function(binary_function func) {
127  _output._func = func;
128  return *this;
129  }
130 
131  binary_function_node& set_value_a(float x, float y, float z, float w) {
132  _output._input_a.fallback().set(x, y, z, w);
133  return *this;
134  }
135 
136  binary_function_node& set_value_b(float x, float y, float z, float w) {
137  _output._input_b.fallback().set(x, y, z, w);
138  return *this;
139  }
140 };
141 
142 } // namespace eagine::oglp::texgen
143 
144 #if !OGLPLUS_LINK_LIBRARY || defined(OGLPLUS_IMPLEMENTING_LIBRARY)
145 #include <oglplus/texgen/functional_node.inl>
146 #endif
147 
148 #endif // OGLPLUS_TEXGEN_FUNCTIONAL_NODE_HPP
value_type
Value tree value element data type enumeration.
Definition: interface.hpp:27
basic_string_span< const char > string_view
Alias for const string views.
Definition: string_span.hpp:116
static auto type_name(const T &) noexcept -> std::string
Returns the demangled name for type T.
Definition: type_name.hpp:24
@ none
None, not doing frame dump render run.
math::sign< float > sign
Alias for math::sign.
Definition: sign.hpp:17

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).