Loading [MathJax]/jax/output/HTML-CSS/config.js
Radium Engine  1.5.28
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RenderingGraph.cpp
1#include <Dataflow/Rendering/Renderer/RenderingGraph.hpp>
2
3#include <Engine/Rendering/RenderObject.hpp>
4#include <Engine/Rendering/RenderTechnique.hpp>
5
6using namespace Ra::Engine::Rendering;
7
8namespace Ra {
9namespace Dataflow {
10namespace Rendering {
11namespace Renderer {
12using namespace Ra::Dataflow::Rendering::Nodes;
13using namespace Ra::Dataflow::Core;
14
15void RenderingGraph::init() {
17}
18
19bool RenderingGraph::add_node( Node* newNode ) {
20 auto added = DataflowGraph::add_node( newNode );
21 if ( added ) {
22 // Todo : is there something to do ?
23 }
24 return added;
25}
26
27bool RenderingGraph::remove_node( Node* node ) {
28 auto removed = DataflowGraph::remove_node( node );
29 if ( removed ) {
30 // Todo : is there something to do ?
31 }
32 return removed;
33}
34
35/*
36bool RenderingGraph::postCompilationOperation() {
37#if 0
38 m_renderingNodes.clear();
39 m_rtIndexedNodes.clear();
40 m_dataProviders.clear();
41 if ( m_displaySinkNode && m_displayObserverId != -1 ) {
42 m_displaySinkNode->detach( m_displayObserverId );
43 m_displayObserverId = -1;
44 m_displaySinkNode = nullptr;
45 }
46 const auto& compiledNodes = nodes_by_level();
47 int idx = 1; // The renderTechnique id = 0 is reserved for ui/debug objects
48 for ( const auto& lvl : *compiledNodes ) {
49 for ( auto n : lvl ) {
50 auto renderNode = dynamic_cast<RenderingNode*>( n );
51 if ( renderNode != nullptr ) {
52 m_renderingNodes.push_back( renderNode );
53 if ( renderNode->hasRenderTechnique() ) {
54 renderNode->setIndex( idx++ );
55 m_rtIndexedNodes.push_back( renderNode );
56 }
57 renderNode->setShaderProgramManager( m_shaderMngr );
58 }
59 else {
60 auto sceneNode = dynamic_cast<SceneNode*>( n );
61 if ( sceneNode ) { m_dataProviders.push_back( sceneNode ); }
62 else {
63 // Manage all sinks ...
64 auto displaySink = dynamic_cast<DisplaySinkNode*>( n );
65 if ( displaySink ) {
66 m_displaySinkNode = displaySink;
67 // observe the displaySink
68 m_displayObserverId =
69 displaySink->attachMember( this, &RenderingGraph::observeSinks );
70 }
71 }
72 }
73 }
74 }
75#if 0
76 std::cout << "RenderingGraph::postCompilationOperation : got " <<
77 m_renderingNodes.size() << " compiled rendering nodes with " <<
78 m_rtIndexedNodes.size() << " render-passes, " <<
79 m_dataProviders.size() << " scene nodes. \n";
80#endif
81#endif
82return true;
83}
84*/
85#if 0
86void RenderingGraph::observeSinks( const std::vector<TextureType*>& graphOutput ) {
87 m_outputTextures = graphOutput;
88 /*
89 std::cout << "Available output textures are :" << std::endl;
90 int i = 0;
91 for (auto t : m_outputTextures ) {
92 std::cout << "\t tex " << i++ << " : ";
93 if (t) {
94 std::cout << t->getName() << std::endl;
95 } else {
96 std::cout << "nullptr" << std::endl;
97 }
98 }
99 */
100}
101#endif
102
103const std::vector<TextureType*>& RenderingGraph::getImagesOutput() const {
104 return m_outputTextures;
105}
106
107void RenderingGraph::clear_nodes() {
109 m_renderingNodes.clear();
110 m_rtIndexedNodes.clear();
111}
112
113void RenderingGraph::buildRenderTechnique( Ra::Engine::Rendering::RenderObject* ro ) const {
115 for ( const auto& rn : m_rtIndexedNodes ) {
116 rn->buildRenderTechnique( ro, *rt );
117 }
118 rt->updateGL();
119 ro->setRenderTechnique( rt );
120}
121} // namespace Renderer
122} // namespace Rendering
123} // namespace Dataflow
124} // namespace Ra
virtual bool add_node(std::shared_ptr< Node > newNode)
Adds a node to the graph.
virtual void clear_nodes()
Deletes all nodes from the render graph.
std::shared_ptr< Node > node(const std::string &instanceNameNode) const
virtual bool remove_node(std::shared_ptr< Node > node)
Removes a node from the graph.
void init() override
Initializes the node content.
Base abstract class for all the nodes added and used by the node system.
Definition Node.hpp:40
T make_shared(T... args)
Rendering engines.
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:4