Radium Engine  1.5.20
Loading...
Searching...
No Matches
Ra::Engine::Rendering::Renderer Class Referenceabstract

#include <Engine/Rendering/Renderer.hpp>

+ Inheritance diagram for Ra::Engine::Rendering::Renderer:
+ Collaboration diagram for Ra::Engine::Rendering::Renderer:

Classes

struct  PickingQuery
 
class  PickingResult
 Result of a PickingQuery. More...
 
struct  TimerData
 

Public Types

enum  PickingMode {
  RO = 0 , VERTEX , EDGE , TRIANGLE ,
  C_VERTEX , C_EDGE , C_TRIANGLE , NONE
}
 
enum  PickingPurpose { SELECTION = 0 , MANIPULATION }
 

Public Member Functions

 Renderer ()
 
const TimerDatagetTimerData () const
 
Data::TexturegetDisplayTexture () const
 
void lockRendering ()
 
void unlockRendering ()
 
void toggleWireframe ()
 
void enableWireframe (bool enabled)
 
void toggleDrawDebug ()
 
void enableDebugDraw (bool enabled)
 
void enablePostProcess (bool enabled)
 
void render (const Data::ViewingParameters &renderData)
 Tell the renderer it needs to render. This method does the following steps :
 
void initialize (uint width, uint height)
 Initialize renderer.
 
void resize (uint width, uint height)
 Resize the viewport and all the screen textures, fbos. This function must be overrided as soon as some FBO or screensized texture is used (since the default implementation just resizes its own fbos / textures)
 
void addPickingRequest (const PickingQuery &query)
 
const std::vector< PickingResult > & getPickingResults () const
 
const std::vector< PickingQuery > & getPickingQueries () const
 
void setMousePosition (const Core::Vector2 &pos)
 
void setBrushRadius (Scalar brushRadius)
 
bool hasLight () const
 Tell if the renderer has an usable light.
 
void setBackgroundColor (const Core::Utils::Color &color)
 Update the background color (does not trigger a redraw)
 
const Core::Utils::ColorgetBackgroundColor () const
 
virtual void addLight (const Scene::Light *light)
 
virtual void reloadShaders ()
 
virtual void displayTexture (const std::string &texName)
 Change the texture that is displayed on screen. Set m_displayedIsDepth to true if depth linearization is wanted.
 
virtual std::vector< std::stringgetAvailableTextures () const
 Return the names of renderer available textures.
 
virtual std::string getRendererName () const =0
 Get the name of the renderer, e.g to be displayed in the UI.
 
virtual bool buildRenderTechnique (RenderObject *ro) const =0
 
int buildAllRenderTechniques () const
 
virtual std::unique_ptr< uchar[]> grabFrame (size_t &w, size_t &h) const
 
PickingResult doPickingNow (const PickingQuery &query, const Data::ViewingParameters &renderData)
 

Protected Types

using RenderObjectPtr = std::shared_ptr<RenderObject>
 

Protected Member Functions

virtual void initializeInternal ()=0
 initializeInternal Initialize the renderer dependant resources.
 
virtual void resizeInternal ()=0
 
virtual void updateStepInternal (const Data::ViewingParameters &renderData)=0
 
virtual void renderInternal (const Data::ViewingParameters &renderData)=0
 All the scene rendering magics basically happens here.
 
virtual void postProcessInternal (const Data::ViewingParameters &renderData)=0
 Do all post processing stuff. If you override this method, be careful to fill.
 
virtual void debugInternal (const Data::ViewingParameters &renderData)=0
 Add the debug layer with useful informations.
 
virtual void uiInternal (const Data::ViewingParameters &renderData)=0
 Draw the UI data.
 

Protected Attributes

uint m_width { 0 }
 
uint m_height { 0 }
 
Data::ShaderProgramManagerm_shaderProgramManager { nullptr }
 
RenderObjectManager * m_renderObjectManager { nullptr }
 
Data::Texturem_displayedTexture { nullptr }
 The texture that will be displayed on screen. If no call to.
 
std::vector< Ra::Engine::Scene::LightManager * > m_lightmanagers
 
bool m_renderQueuesUpToDate { false }
 
std::vector< RenderObjectPtrm_fancyRenderObjects
 
std::vector< RenderObjectPtrm_debugRenderObjects
 
std::vector< RenderObjectPtrm_xrayRenderObjects
 
std::vector< RenderObjectPtrm_uiRenderObjects
 
std::unique_ptr< Data::Displayablem_quadMesh
 
bool m_drawDebug { true }
 
bool m_wireframe { false }
 
bool m_postProcessEnabled { true }
 
std::unique_ptr< Data::Texturem_depthTexture
 Depth texture : might be attached to the main framebuffer.
 
std::unique_ptr< Data::Texturem_fancyTexture
 Final color texture : might be attached to the main framebuffer.
 
std::map< std::string, Data::Texture * > m_secondaryTextures
 Textures exposed in the texture section box to be displayed.
 

Detailed Description

Abstract renderer for the engine.

See also
Radium Engine default rendering informations

Definition at line 44 of file Renderer.hpp.

Member Typedef Documentation

◆ RenderObjectPtr

Member Enumeration Documentation

◆ PickingMode

Picking mode

Enumerator
RO 

Pick a mesh.

VERTEX 

Pick a vertex of a mesh.

EDGE 

Pick an edge of a mesh.

TRIANGLE 

Pick a triangle of a mesh.

C_VERTEX 

Picks all vertices of a mesh within a screen space circle.

C_EDGE 

Picks all edges of a mesh within a screen space circle.

C_TRIANGLE 

Picks all triangles of a mesh within a screen space circle.

NONE 

Do not pick ;)

Definition at line 65 of file Renderer.hpp.

◆ PickingPurpose

Picking purpose Used to identify what picking operation is realized

Definition at line 80 of file Renderer.hpp.

Constructor & Destructor Documentation

◆ Renderer()

Ra::Engine::Rendering::Renderer::Renderer ( )

Abstract rendere constructor

could be called without openGL context. Call initialize once the openGL rendering context is available before using the renderer

Definition at line 47 of file Renderer.cpp.

Member Function Documentation

◆ addLight()

void Ra::Engine::Rendering::Renderer::addLight ( const Scene::Light * light)
virtual

Add a light to the renderer. may be overridden to filter the light or to specialize the way ligths are added to the renderer ...

Parameters
light

Definition at line 751 of file Renderer.cpp.

◆ addPickingRequest()

void Ra::Engine::Rendering::Renderer::addPickingRequest ( const PickingQuery & query)
inline

Add a new picking query for the next rendering

Parameters
query

Definition at line 591 of file Renderer.hpp.

◆ buildAllRenderTechniques()

int Ra::Engine::Rendering::Renderer::buildAllRenderTechniques ( ) const

Loops over all available renderobjects and, build the associated render technique using buildRenderTechnique(RenderObject *ro)

Returns
the number of render objects initialized

Definition at line 763 of file Renderer.cpp.

+ Here is the call graph for this function:

◆ buildRenderTechnique()

virtual bool Ra::Engine::Rendering::Renderer::buildRenderTechnique ( RenderObject * ro) const
pure virtual

Define, for the given render object, the render technique cooresponding to the renderer.

Parameters
rothe render object to modofy
Returns
True if the renderTechnique was defined.

Implemented in Ra::Engine::Rendering::ForwardRenderer.

◆ debugInternal()

virtual void Ra::Engine::Rendering::Renderer::debugInternal ( const Data::ViewingParameters & renderData)
protectedpure virtual

Add the debug layer with useful informations.

Implemented in Ra::Engine::Rendering::ForwardRenderer.

◆ displayTexture()

void Ra::Engine::Rendering::Renderer::displayTexture ( const std::string & texName)
virtual

Change the texture that is displayed on screen. Set m_displayedIsDepth to true if depth linearization is wanted.

Parameters
texNameThe texture to display.

Definition at line 696 of file Renderer.cpp.

◆ doPickingNow()

Renderer::PickingResult Ra::Engine::Rendering::Renderer::doPickingNow ( const PickingQuery & query,
const Data::ViewingParameters & renderData )

Read the depth value from m_pickingFbo depth buffer. Need to be overridden to take rendering fbo into account in your own renderer.

Returns
the value of the depth buffer under pixel (x,y) return depth value is in "screen space" [0,1]
See also
https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glReadPixels.xhtml
Todo
Fixup prepare picking to take pixel position and rendering window, and read depth in it.

Definition at line 191 of file Renderer.cpp.

+ Here is the call graph for this function:

◆ enableDebugDraw()

void Ra::Engine::Rendering::Renderer::enableDebugDraw ( bool enabled)
inline

Set the debug rendering mode

Parameters
enabledtrue if rendering mode must include debug objects, false else

Definition at line 583 of file Renderer.hpp.

◆ enablePostProcess()

void Ra::Engine::Rendering::Renderer::enablePostProcess ( bool enabled)
inline

set the post-process mode

Parameters
enabledtrue if post processing must bve applied before display.

Definition at line 587 of file Renderer.hpp.

◆ enableWireframe()

void Ra::Engine::Rendering::Renderer::enableWireframe ( bool enabled)
inline

set the fill/wireframe rendering mode

Parameters
enabledtrue if rendering mode must be wireframe, false for fill render mode

Definition at line 575 of file Renderer.hpp.

◆ getAvailableTextures()

std::vector< std::string > Ra::Engine::Rendering::Renderer::getAvailableTextures ( ) const
virtual

Return the names of renderer available textures.

Returns
A vector of strings, containing the name of the different textures

Definition at line 703 of file Renderer.cpp.

+ Here is the call graph for this function:

◆ getBackgroundColor()

const Core::Utils::Color & Ra::Engine::Rendering::Renderer::getBackgroundColor ( ) const
inline

Definition at line 616 of file Renderer.hpp.

◆ getDisplayTexture()

Data::Texture * Ra::Engine::Rendering::Renderer::getDisplayTexture ( ) const
inline

Get the currently displayed texture

Definition at line 559 of file Renderer.hpp.

◆ getPickingQueries()

const std::vector< Renderer::PickingQuery > & Ra::Engine::Rendering::Renderer::getPickingQueries ( ) const
inline

Get the vector of picking queries. Queries in the returned vector correspond to results in the return vector by the function getPickingResults().

Returns
Queries results

Definition at line 599 of file Renderer.hpp.

◆ getPickingResults()

const std::vector< Renderer::PickingResult > & Ra::Engine::Rendering::Renderer::getPickingResults ( ) const
inline

Get the vector of picking results. Results in the returned vector correspond to queries in the return vector by the function getPickingQueries().

Returns
Queries results

Definition at line 595 of file Renderer.hpp.

◆ getRendererName()

virtual std::string Ra::Engine::Rendering::Renderer::getRendererName ( ) const
pure virtual

Get the name of the renderer, e.g to be displayed in the UI.

Returns

Implemented in Ra::Engine::Rendering::ForwardRenderer.

◆ getTimerData()

const Renderer::TimerData & Ra::Engine::Rendering::Renderer::getTimerData ( ) const
inline

Extract the timings from las render

Definition at line 555 of file Renderer.hpp.

◆ grabFrame()

std::unique_ptr< uchar[]> Ra::Engine::Rendering::Renderer::grabFrame ( size_t & w,
size_t & h ) const
virtual

get the content of the current frame

Parameters
wwidth of the region to grab
hheigth oif the region to grab
Returns
the pixel array

Definition at line 717 of file Renderer.cpp.

+ Here is the call graph for this function:

◆ hasLight()

bool Ra::Engine::Rendering::Renderer::hasLight ( ) const

Tell if the renderer has an usable light.

Definition at line 756 of file Renderer.cpp.

◆ initialize()

void Ra::Engine::Rendering::Renderer::initialize ( uint width,
uint height )

Initialize renderer.

For internal resources management in a filesystem

Definition at line 56 of file Renderer.cpp.

+ Here is the call graph for this function:

◆ initializeInternal()

virtual void Ra::Engine::Rendering::Renderer::initializeInternal ( )
protectedpure virtual

initializeInternal Initialize the renderer dependant resources.

Implemented in Ra::Engine::Rendering::ForwardRenderer.

◆ lockRendering()

void Ra::Engine::Rendering::Renderer::lockRendering ( )
inline

Lock rendering. Usefull if there is multithread update of the rendering data

Definition at line 563 of file Renderer.hpp.

+ Here is the call graph for this function:

◆ postProcessInternal()

virtual void Ra::Engine::Rendering::Renderer::postProcessInternal ( const Data::ViewingParameters & renderData)
protectedpure virtual

Do all post processing stuff. If you override this method, be careful to fill.

See also
m_fancyTexture since it is the texture that will be displayed at the very end of the
render method.
Parameters
renderDataThe basic data needed for the rendering : Time elapsed since last frame, camera view matrix, camera projection matrix.

Implemented in Ra::Engine::Rendering::ForwardRenderer.

◆ reloadShaders()

void Ra::Engine::Rendering::Renderer::reloadShaders ( )
virtual

Reload, recompile and relink all shaders and programmed internally used by the renderer.

Definition at line 713 of file Renderer.cpp.

+ Here is the call graph for this function:

◆ render()

void Ra::Engine::Rendering::Renderer::render ( const Data::ViewingParameters & renderData)

Tell the renderer it needs to render. This method does the following steps :

  1. call
    See also
    updateRenderObjectsInternal method
  2. call
    See also
    renderInternal method
  3. call
    See also
    postProcessInternal method
  4. render the final texture in the right framebuffer*
Parameters
renderDataThe basic data needed for the rendering : Time elapsed since last frame, camera view matrix, camera projection matrix.
Note
* What "render in the right buffer" means, is that, for example, when using QOpenGLWidget, Qt binds its own framebuffer before calling updateGL() method. So, render() takes that into account by saving an eventual bound framebuffer, and restores it before drawing the last final texture. If no framebuffer was bound, it draws into GL_BACK.

Definition at line 315 of file Renderer.cpp.

+ Here is the call graph for this function:

◆ renderInternal()

virtual void Ra::Engine::Rendering::Renderer::renderInternal ( const Data::ViewingParameters & renderData)
protectedpure virtual

All the scene rendering magics basically happens here.

Parameters
renderDataThe basic data needed for the rendering : Time elapsed since last frame, camera view matrix, camera projection matrix.

Implemented in Ra::Engine::Rendering::ForwardRenderer.

◆ resize()

void Ra::Engine::Rendering::Renderer::resize ( uint width,
uint height )

Resize the viewport and all the screen textures, fbos. This function must be overrided as soon as some FBO or screensized texture is used (since the default implementation just resizes its own fbos / textures)

Parameters
widthThe new viewport width
heightThe new viewport height

Definition at line 671 of file Renderer.cpp.

+ Here is the call graph for this function:

◆ resizeInternal()

virtual void Ra::Engine::Rendering::Renderer::resizeInternal ( )
protectedpure virtual

resize the renderer dependent resources

Implemented in Ra::Engine::Rendering::ForwardRenderer.

◆ setBackgroundColor()

void Ra::Engine::Rendering::Renderer::setBackgroundColor ( const Core::Utils::Color & color)
inline

Update the background color (does not trigger a redraw)

Definition at line 612 of file Renderer.hpp.

◆ setBrushRadius()

void Ra::Engine::Rendering::Renderer::setBrushRadius ( Scalar brushRadius)
inline

Definition at line 608 of file Renderer.hpp.

◆ setMousePosition()

void Ra::Engine::Rendering::Renderer::setMousePosition ( const Core::Vector2 & pos)
inline

Definition at line 603 of file Renderer.hpp.

◆ toggleDrawDebug()

void Ra::Engine::Rendering::Renderer::toggleDrawDebug ( )
inline

Toggle debug rendering

Definition at line 579 of file Renderer.hpp.

◆ toggleWireframe()

void Ra::Engine::Rendering::Renderer::toggleWireframe ( )
inline

Toggle the fill/wireframe rendering mode

Definition at line 571 of file Renderer.hpp.

◆ uiInternal()

virtual void Ra::Engine::Rendering::Renderer::uiInternal ( const Data::ViewingParameters & renderData)
protectedpure virtual

Draw the UI data.

Implemented in Ra::Engine::Rendering::ForwardRenderer.

◆ unlockRendering()

void Ra::Engine::Rendering::Renderer::unlockRendering ( )
inline

Unlock the rendering.

Definition at line 567 of file Renderer.hpp.

+ Here is the call graph for this function:

◆ updateStepInternal()

virtual void Ra::Engine::Rendering::Renderer::updateStepInternal ( const Data::ViewingParameters & renderData)
protectedpure virtual

Update the renderer dependent resources for the next frame

Parameters
renderData

Implemented in Ra::Engine::Rendering::ForwardRenderer.

Member Data Documentation

◆ m_debugRenderObjects

std::vector<RenderObjectPtr> Ra::Engine::Rendering::Renderer::m_debugRenderObjects
protected

Definition at line 460 of file Renderer.hpp.

◆ m_depthTexture

std::unique_ptr<Data::Texture> Ra::Engine::Rendering::Renderer::m_depthTexture
protected

Depth texture : might be attached to the main framebuffer.

Definition at line 473 of file Renderer.hpp.

◆ m_displayedTexture

Data::Texture* Ra::Engine::Rendering::Renderer::m_displayedTexture { nullptr }
protected

The texture that will be displayed on screen. If no call to.

See also
debugTexture has been done, this is just a pointer to
m_fancyTexture.

Definition at line 451 of file Renderer.hpp.

◆ m_drawDebug

bool Ra::Engine::Rendering::Renderer::m_drawDebug { true }
protected

Definition at line 467 of file Renderer.hpp.

◆ m_fancyRenderObjects

std::vector<RenderObjectPtr> Ra::Engine::Rendering::Renderer::m_fancyRenderObjects
protected

Definition at line 459 of file Renderer.hpp.

◆ m_fancyTexture

std::unique_ptr<Data::Texture> Ra::Engine::Rendering::Renderer::m_fancyTexture
protected

Final color texture : might be attached to the main framebuffer.

Definition at line 475 of file Renderer.hpp.

◆ m_height

uint Ra::Engine::Rendering::Renderer::m_height { 0 }
protected

Definition at line 430 of file Renderer.hpp.

◆ m_lightmanagers

std::vector<Ra::Engine::Scene::LightManager*> Ra::Engine::Rendering::Renderer::m_lightmanagers
protected

A renderer could define several LightManager (for instance, one for point light, one other for infinite light ...)

Definition at line 455 of file Renderer.hpp.

◆ m_postProcessEnabled

bool Ra::Engine::Rendering::Renderer::m_postProcessEnabled { true }
protected

Definition at line 469 of file Renderer.hpp.

◆ m_quadMesh

std::unique_ptr<Data::Displayable> Ra::Engine::Rendering::Renderer::m_quadMesh
protected

Definition at line 465 of file Renderer.hpp.

◆ m_renderObjectManager

RenderObjectManager* Ra::Engine::Rendering::Renderer::m_renderObjectManager { nullptr }
protected

This raw pointer is used as an alias to a std::unique_ptr own by the engine. It is guaranteed that the lifetime of the engine is longer than the lifetime of a Renderer.

See also
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Ri-raw
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rr-ptr

Definition at line 442 of file Renderer.hpp.

◆ m_renderQueuesUpToDate

bool Ra::Engine::Rendering::Renderer::m_renderQueuesUpToDate { false }
protected

Definition at line 457 of file Renderer.hpp.

◆ m_secondaryTextures

std::map<std::string, Data::Texture*> Ra::Engine::Rendering::Renderer::m_secondaryTextures
protected

Textures exposed in the texture section box to be displayed.

Definition at line 477 of file Renderer.hpp.

◆ m_shaderProgramManager

Data::ShaderProgramManager* Ra::Engine::Rendering::Renderer::m_shaderProgramManager { nullptr }
protected

This raw pointer is used as an alias to a std::unique_ptr own by the engine. It is guaranteed that the lifetime of the engine is longer than the lifetime of a Renderer.

See also
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Ri-raw
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rr-ptr

Definition at line 436 of file Renderer.hpp.

◆ m_uiRenderObjects

std::vector<RenderObjectPtr> Ra::Engine::Rendering::Renderer::m_uiRenderObjects
protected

Definition at line 462 of file Renderer.hpp.

◆ m_width

uint Ra::Engine::Rendering::Renderer::m_width { 0 }
protected

Definition at line 429 of file Renderer.hpp.

◆ m_wireframe

bool Ra::Engine::Rendering::Renderer::m_wireframe { false }
protected

Definition at line 468 of file Renderer.hpp.

◆ m_xrayRenderObjects

std::vector<RenderObjectPtr> Ra::Engine::Rendering::Renderer::m_xrayRenderObjects
protected

Definition at line 461 of file Renderer.hpp.


The documentation for this class was generated from the following files: