Skip to content
Snippets Groups Projects
Commit d3ee335e authored by Mathias Paulin's avatar Mathias Paulin :speech_balloon:
Browse files

Renderer controler is now an inner class of the configurable Renderer

parent 8b295ff6
No related branches found
No related tags found
No related merge requests found
......@@ -80,7 +80,8 @@ void AddCustomAttributeToMeshes() {
auto theMesh = ro->getMesh();
auto displayMesh =
dynamic_cast<Ra::Engine::Data::AttribArrayDisplayable*>( theMesh.get() );
std::dynamic_pointer_cast<Ra::Engine::Data::AttribArrayDisplayable>(
theMesh );
LOG( logINFO ) << "\t\tMesh " << displayMesh->getName() << " is processed.";
auto& coreMesh = displayMesh->getAttribArrayGeometry();
......
......@@ -29,11 +29,11 @@ int NodeBasedRendererMagic = 0xFF0F00F0;
static const GLenum buffers[] = {GL_COLOR_ATTACHMENT0};
static RenderControlFunctor noOpController;
static NodeBasedRenderer::RenderControlFunctor noOpController;
NodeBasedRenderer::NodeBasedRenderer() : Renderer(), m_controller{noOpController} {}
NodeBasedRenderer::NodeBasedRenderer( RenderControlFunctor& controller ) :
NodeBasedRenderer::NodeBasedRenderer( NodeBasedRenderer::RenderControlFunctor& controller ) :
Renderer(), m_controller{controller} {}
NodeBasedRenderer::~NodeBasedRenderer() = default;
......@@ -145,6 +145,8 @@ void NodeBasedRenderer::initializeInternal() {
void NodeBasedRenderer::resizeInternal() {
m_controller.resize( m_width, m_height );
m_sharedTextures["Depth (RadiumNBR)"]->resize( m_width, m_height );
m_sharedTextures["Linear RGB (RadiumNBR)"]->resize( m_width, m_height );
......
......@@ -11,42 +11,34 @@ class Framebuffer;
namespace RadiumNBR {
/// Todo, put this somewhere else. This is needed to locate resources by cclient applications
/// Todo, put this somewhere else. This is needed to locate resources by client applications
extern int NodeBasedRendererMagic;
class NodeBasedRenderer;
class UIPass;
class DebugPass;
/**
* Rendering functor prototype
* @todo make this a concept
*/
struct RenderControlFunctor {
virtual ~RenderControlFunctor() = default;
/// Configuration function.
/// Called once at the configuration of the renderer
virtual void configure( NodeBasedRenderer* renderer, int w, int h ){};
/// Resize function
/// Called each time the renderer is resized
virtual void resize( int w, int h ){};
/// Update function
/// Called once before each frame to update the internal state of the renderer
virtual void update( const Ra::Engine::Data::ViewingParameters& renderData ){};
};
/** Node based for the Radium Engine
* This Renderer is fully configurable, either dynammically or programatically.
* It implements the Ra::Engine::Rendering/Renderer interface and can be configured by adding
* as many RadiumNBR::RenderPass as needed.
* This Renderer is fully configurable, either dynamically or programmatically.
* It implements the Ra::Engine::Rendering/Renderer interface.
*
* A NodeBasedRenderer is configured by using the RenderControlFunctor given at construction.
* A RenderControlFunctor offers the following services :
* - configure() : add to the renderer as many RadiumNBR::RenderPass as needed. This method is
* called once when initializing the renderer. This method could also initialize internal
* resources into the controller that could be used to control the rendering.
* - resize() : called each time the renderer output is resized. This will allow modify controller
* resources that depends on the size of the output (e.g. internal textures ...)
* - update() : Called once before each frame to update the internal state of the renderer.
*
* It defines two textures that migh be shared between passes :
* - a depth buffer attachable texture
* - a Linear space RGBA color texture
* A NodeBasedRenderer defines two textures that might be shared between passes :
* - a depth buffer attachable texture, stored with the key "Depth (RadiumNBR)" into the shared
* textures collection
* - a Linear space RGBA color texture, stored with the key "Linear RGB (RadiumNBR)" into the
* shared textures collection
*
* It allows to apply a linearRGB to sRGB color transformation before displaying the image.
* If requested on the base Ra::Engine::Rendering::Renderer, a NodeBasedRenderer apply a
* post-process step on the "Linear RGB (RadiumNBR)" that convert colors from linearRGB to sRGB
* color space before displaying the image.
*
*
* @see rendering.md for description of the renderer
......@@ -55,11 +47,39 @@ class NodeBasedRenderer_LIBRARY_API NodeBasedRenderer : public Ra::Engine::Rende
{
public:
//
/**
* Rendering functor prototype
* @todo make this a concept
*/
struct RenderControlFunctor {
RenderControlFunctor() = default;
virtual ~RenderControlFunctor() = default;
RenderControlFunctor( const RenderControlFunctor& ) = delete;
RenderControlFunctor( const RenderControlFunctor&& ) = delete;
RenderControlFunctor& operator=( RenderControlFunctor&& ) = delete;
RenderControlFunctor& operator=( const RenderControlFunctor& ) = delete;
/// Configuration function.
/// Called once at the configuration of the renderer
virtual void configure( NodeBasedRenderer* renderer, int w, int h ){};
/// Resize function
/// Called each time the renderer is resized
virtual void resize( int w, int h ){};
/// Update function
/// Called once before each frame to update the internal state of the renderer
virtual void update( const Ra::Engine::Data::ViewingParameters& renderData ){};
};
/// Construct a renderer that has to be configured explicitely
NodeBasedRenderer();
/// Construct a renderer configured and managed through the controller
explicit NodeBasedRenderer( RenderControlFunctor& controller );
/// The destructor is defaulted
~NodeBasedRenderer() override;
[[nodiscard]] std::string getRendererName() const override { return "Configurable Renderer"; }
......@@ -102,8 +122,6 @@ class NodeBasedRenderer_LIBRARY_API NodeBasedRenderer : public Ra::Engine::Rende
void debugInternal( const Ra::Engine::Data::ViewingParameters& renderData ) override;
void uiInternal( const Ra::Engine::Data::ViewingParameters& renderData ) override;
// TODO : merge these two function into initResources ?
/** Initialize internal resources for the renderer.
* The base function creates the depth and final color texture to be shared by the rendering
* passes that need them.
......@@ -134,7 +152,7 @@ class NodeBasedRenderer_LIBRARY_API NodeBasedRenderer : public Ra::Engine::Rende
/// internal FBO used for post-processing
std::unique_ptr<globjects::Framebuffer> m_postprocessFbo;
/// vector of this renderer render passes, sorted by precedence (first pass is at index 0)
/// collection of render passes, sorted by precedence (first pass is at key 0)
std::map<int, std::shared_ptr<RenderPass>> m_renderPasses;
/// The default pass
......@@ -147,7 +165,7 @@ class NodeBasedRenderer_LIBRARY_API NodeBasedRenderer : public Ra::Engine::Rende
std::unique_ptr<UIPass> m_uiPass;
bool m_showUi{false};
/// The pass to draw UI object
/// The pass to draw Debug object
std::unique_ptr<DebugPass> m_debugPass;
bool m_showDebug{false};
};
......
......@@ -8,7 +8,8 @@ class ClearPass;
* This class parameterize the renderer just after the OpenGL system was initialized.
* when a method of this controler is called, the OpenGL context of the drawing window is activated.
*/
class NodeBasedRenderer_LIBRARY_API VisualizationController : public RadiumNBR::RenderControlFunctor
class NodeBasedRenderer_LIBRARY_API VisualizationController
: public RadiumNBR::NodeBasedRenderer::RenderControlFunctor
{
public:
/*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment