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

swizzle_node.hpp
Go to the documentation of this file.
1 #ifndef OGLPLUS_TEXGEN_SWIZZLE_NODE_HPP
9 #define OGLPLUS_TEXGEN_SWIZZLE_NODE_HPP
10 
11 #include "base_node.hpp"
12 #include "fallback_input.hpp"
13 #include <string>
14 
15 namespace eagine::oglp::texgen {
16 
17 bool is_valid_swizzle(string_view) noexcept;
18 
19 class swizzle_output : public base_output {
20 public:
21  std::string swizzle;
22  input_with_const_default<float[4]> input;
23 
24  swizzle_output(node_intf& parent);
25  swizzle_output(node_intf& parent, std::string swizzle);
26 
27  string_view type_name() override;
28 
29  slot_data_type value_type() override;
30 
31  std::ostream& definitions(std::ostream& out, compile_context& ctxt) override;
32 };
33 
34 class swizzle_node
35  : public unary_single_output_node<
36  swizzle_output,
37  decltype(swizzle_output::input),
38  &swizzle_output::input> {
39 public:
40  swizzle_node() = default;
41 
42  swizzle_node& set_swizzle(const std::string& swizzle) {
43  if(is_valid_swizzle(string_view(swizzle))) {
44  _output.swizzle = swizzle;
45  }
46  return *this;
47  }
48 };
49 
50 } // namespace eagine::oglp::texgen
51 
52 #if !OGLPLUS_LINK_LIBRARY || defined(OGLPLUS_IMPLEMENTING_LIBRARY)
53 #include <oglplus/texgen/swizzle_node.inl>
54 #endif
55 
56 #endif // OGLPLUS_TEXGEN_SWIZZLE_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

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