Loading...
Searching...
No Matches
GfxParameter.hpp
1#pragma once
2#include <Gfx/GfxContext.hpp>
3#include <Gfx/GfxExecContext.hpp>
4
5#include <ossia/gfx/texture_parameter.hpp>
6#include <ossia/network/base/device.hpp>
7#include <ossia/network/base/parameter.hpp>
8#include <ossia/network/base/protocol.hpp>
9
10namespace Gfx
11{
12class gfx_parameter_base : public ossia::gfx::texture_parameter
13{
14protected:
15 GfxExecutionAction* context{};
16
17public:
18 score::gfx::Node* node{};
19 int32_t node_id{};
20
22 ossia::net::node_base& n, score::gfx::Node* node, GfxExecutionAction* ctx)
23 : texture_parameter{n}
24 , context{ctx}
25 , node{node}
26 {
27 node_id = context->ui->register_node(std::unique_ptr<score::gfx::Node>{node});
28 }
29
30 void push_texture(port_index idx)
31 {
32 port_index source = idx;
33 port_index sink = port_index{this->node_id, 0};
34 context->setEdge(source, sink);
35 }
36
37 virtual ~gfx_parameter_base() { context->ui->unregister_node(node_id); }
38};
39
40class gfx_protocol_base : public ossia::net::protocol_base
41{
42public:
44 : protocol_base{flags{}}
45 , context{&ctx}
46 {
47 }
48 GfxExecutionAction* context{};
49 bool pull(ossia::net::parameter_base&) override { return false; }
50 bool push(const ossia::net::parameter_base&, const ossia::value& v) override
51 {
52 return false;
53 }
54 bool push_raw(const ossia::net::full_parameter_data&) override { return false; }
55 bool observe(ossia::net::parameter_base&, bool) override { return false; }
56 bool update(ossia::net::node_base& node_base) override { return false; }
57};
58
59class gfx_node_base : public ossia::net::node_base
60{
61 ossia::net::device_base& m_device;
62 gfx_node_base* m_parent{};
63 std::unique_ptr<gfx_parameter_base> m_parameter;
64
65public:
67 ossia::net::device_base& dev, gfx_protocol_base& proto, score::gfx::Node* gfxmodel,
68 std::string name)
69 : m_device{dev}
70 , m_parameter{std::make_unique<gfx_parameter_base>(*this, gfxmodel, proto.context)}
71 {
72 m_name = std::move(name);
73 }
74
75 gfx_parameter_base* get_parameter() const override { return m_parameter.get(); }
76
77private:
78 ossia::net::device_base& get_device() const override { return m_device; }
79 ossia::net::node_base* get_parent() const override { return m_parent; }
80 ossia::net::node_base& set_name(std::string) override { return *this; }
81 ossia::net::parameter_base* create_parameter(ossia::val_type) override
82 {
83 return m_parameter.get();
84 }
85 bool remove_parameter() override { return false; }
86
87 std::unique_ptr<ossia::net::node_base> make_child(const std::string& name) override
88 {
89 return {};
90 }
91 void removing_child(ossia::net::node_base& node_base) override { }
92};
93
94}
Definition GfxExecContext.hpp:16
Definition GfxParameter.hpp:60
Definition GfxParameter.hpp:13
Definition GfxParameter.hpp:41
Root data model for visual nodes.
Definition score-plugin-gfx/Gfx/Graph/Node.hpp:60
Binds the rendering pipeline to ossia processes.
Definition CameraDevice.cpp:28