Loading...
Searching...
No Matches
GfxExecNode.hpp
1#pragma once
2
3#include <State/ValueConversion.hpp>
4
5#include <Process/ExecutionContext.hpp>
6
7#include <Gfx/GfxContext.hpp>
8#include <Gfx/GfxDevice.hpp>
9#include <Gfx/GfxExecContext.hpp>
10
11#include <ossia/dataflow/graph_edge.hpp>
12#include <ossia/dataflow/graph_node.hpp>
13#include <ossia/dataflow/port.hpp>
14
15#include <score_plugin_gfx_export.h>
16
17namespace Gfx
18{
19
20template <typename Vector>
21int64_t
22index_of(Vector&& v, const typename std::remove_reference_t<Vector>::value_type& t)
23{
24 if(auto it = ossia::find(v, t); it != v.end())
25 {
26 return std::distance(v.begin(), it);
27 }
28 return -1;
29}
30
32{
33 ossia::value value{};
34 ossia::value_port* port{};
35 bool changed{};
36};
37
38using exec_controls = std::vector<std::shared_ptr<exec_control>>;
39class SCORE_PLUGIN_GFX_EXPORT gfx_exec_node : public ossia::graph_node
40{
41public:
43
44 exec_controls controls;
45 exec_controls control_outs;
46
47 GfxExecutionAction* exec_context{};
49 : exec_context{&e_ctx}
50 {
51 }
52
53 const std::shared_ptr<control>& add_control()
54 {
55 auto port = new ossia::value_inlet;
56 m_inlets.push_back(port);
57
58 controls.push_back(std::make_shared<control>());
59 auto& c = controls.back();
60 c->port = &**port;
61 c->changed = true;
62
63 return c;
64 }
65
66 const std::shared_ptr<control>& add_control_out()
67 {
68 auto port = new ossia::value_outlet;
69 m_outlets.push_back(port);
70
71 control_outs.push_back(std::make_shared<control>());
72 auto& c = control_outs.back();
73 c->port = &**port;
74 c->changed = false;
75
76 return c;
77 }
78
79 auto add_value_port()
80 {
81 auto port = new ossia::value_inlet;
82 m_inlets.push_back(port);
83 return port;
84 }
85
86 void add_texture()
87 {
88 auto port = new ossia::texture_inlet;
89 m_inlets.push_back(port);
90 }
91
92 void add_texture_out()
93 {
94 auto port = new ossia::texture_outlet;
95 m_outlets.push_back(port);
96 }
97
98 void add_audio()
99 {
100 auto inletport = new ossia::audio_inlet;
101 m_inlets.push_back(inletport);
102 }
103
105
106 int32_t id{-1};
107 std::atomic_int32_t script_index{0};
108 ossia::time_value m_last_flicks{};
109 void run(const ossia::token_request& tk, ossia::exec_state_facade) noexcept override;
110
111 void link_cable_to_inlet(ossia::inlet* inlet, int inlet_i);
112 using ossia::graph_node::m_inlets;
113 using ossia::graph_node::m_outlets;
114};
115
116struct SCORE_PLUGIN_GFX_EXPORT con_unvalidated
117{
118 const Execution::Context& ctx;
119 const std::size_t i;
120 const int32_t script_index{};
121 std::weak_ptr<gfx_exec_node> weak_node;
122 void operator()(const ossia::value& val);
123};
124
125}
Definition GfxExecContext.hpp:16
Definition GfxExecNode.hpp:40
Binds the rendering pipeline to ossia processes.
Definition CameraDevice.cpp:28
Definition ExecutionContext.hpp:76
Definition GfxExecNode.hpp:117
Definition GfxExecNode.hpp:32