Loading...
Searching...
No Matches
MultiWindowNode.hpp
1#pragma once
2#include <Gfx/Graph/OutputNode.hpp>
3#include <Gfx/WindowDevice.hpp>
4
5namespace score::gfx
6{
7class Window;
8
9struct SCORE_PLUGIN_GFX_EXPORT MultiWindowNode : OutputNode
10{
11 explicit MultiWindowNode(
12 Configuration conf, const std::vector<Gfx::OutputMapping>& mappings);
13 virtual ~MultiWindowNode();
14
15 void startRendering() override;
16 void render() override;
17 void onRendererChange() override;
18 bool canRender() const override;
19 void stopRendering() override;
20
21 void setRenderer(std::shared_ptr<RenderList> r) override;
22 RenderList* renderer() const override;
23
24 void createOutput(score::gfx::OutputConfiguration) override;
25 void destroyOutput() override;
26 void updateGraphicsAPI(GraphicsApi) override;
27 void setVSyncCallback(std::function<void()>) override;
28
29 std::shared_ptr<RenderState> renderState() const override;
30 score::gfx::OutputNodeRenderer* createRenderer(RenderList& r) const noexcept override;
31 Configuration configuration() const noexcept override;
32
34 {
35 float width{0.0f};
36 float gamma{2.2f};
37 };
38
40 {
41 std::shared_ptr<Window> window;
42 QRhiSwapChain* swapChain{};
43 QRhiRenderBuffer* depthStencil{};
44 QRhiRenderPassDescriptor* renderPassDescriptor{};
45 QRectF sourceRect{0, 0, 1, 1};
46 bool hasSwapChain{};
47
48 EdgeBlendData blendLeft, blendRight, blendTop, blendBottom;
49
50 Gfx::CornerWarp cornerWarp;
51 };
52
53 const std::vector<WindowOutput>& windowOutputs() const noexcept
54 {
55 return m_windowOutputs;
56 }
57
58 void setRenderSize(QSize sz);
59 void setSourceRect(int windowIndex, QRectF rect);
60 void setEdgeBlend(int windowIndex, int side, float width, float gamma);
61 void setCornerWarp(int windowIndex, const Gfx::CornerWarp& warp);
62
63 std::function<void(float)> onFps;
64 // Called after all windows are created in createOutput(), before swap chains are initialized
65 std::function<void()> onWindowsCreated;
66
67private:
68 void renderBlack();
69 void initWindow(int index, GraphicsApi api);
70
71 Configuration m_conf;
72 std::vector<Gfx::OutputMapping> m_mappings;
73 std::vector<WindowOutput> m_windowOutputs;
74
75 std::shared_ptr<RenderState> m_renderState;
76 std::weak_ptr<RenderList> m_renderer;
77
78 std::function<void()> m_vsyncCallback;
79};
80}
Base class for sink nodes (QWindow, spout, syphon, NDI output, ...)
Definition OutputNode.hpp:31
Definition OutputNode.hpp:18
List of nodes to be rendered to an output.
Definition RenderList.hpp:19
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:12
GraphicsApi
Available graphics APIs to use.
Definition RenderState.hpp:20
Definition WindowSettings.hpp:33
Definition MultiWindowNode.hpp:34
Definition MultiWindowNode.hpp:40
Definition MultiWindowNode.hpp:10
Definition OutputNode.hpp:11
Definition OutputNode.hpp:61