From fa5a170a2950be065cdca1f3647e65cf0b3f3585 Mon Sep 17 00:00:00 2001 From: dlyr Date: Thu, 30 Nov 2023 11:27:36 +0100 Subject: [PATCH 01/15] [core] add allClose in math function. --- src/Core/Math/LinearAlgebra.hpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/Core/Math/LinearAlgebra.hpp b/src/Core/Math/LinearAlgebra.hpp index 583f091c1ee..c2aa553a146 100644 --- a/src/Core/Math/LinearAlgebra.hpp +++ b/src/Core/Math/LinearAlgebra.hpp @@ -374,6 +374,33 @@ bool checkInvalidNumbers( Eigen::Ref matrix, const bool FAIL_ON_A return !invalid; } +/// \brief Returns True if two arrays are element-wise equal within a tolerance. + +/// The tolerance values are positive, typically very small numbers. The relative difference (\b +/// rtol * abs(\b b)) and the absolute difference \b atol are added together to compare against the +/// absolute difference between \b a and \b b. +/// +/// Parameters: +/// +/// \param a,b Input Matrix to compare +/// \param rtol The relative tolerance parameter (see Notes). +/// \param atol The absolute tolerance parameter (see Notes). +/// \see +/// https://stackoverflow.com/questions/15051367/how-to-compare-vectors-approximately-in-eigen, +/// https://numpy.org/doc/stable/reference/generated/numpy.allclose.html +template +bool allClose( const Eigen::DenseBase& a, + const Eigen::DenseBase& b, + const typename DerivedA::RealScalar& rtol = + Eigen::NumTraits::dummy_precision(), + const typename DerivedA::RealScalar& atol = + Eigen::NumTraits::epsilon() ) { + + return ( ( a.derived() - b.derived() ).array().abs() <= + ( atol + rtol * a.derived().array().abs().max( b.derived().array().abs() ) ) ) + .all(); +} + } // namespace Math } // namespace Core } // namespace Ra From 3182d042071e10bfa631b948152862c9a78b7933 Mon Sep 17 00:00:00 2001 From: dlyr Date: Mon, 11 Mar 2024 13:42:16 +0100 Subject: [PATCH 02/15] [engine] Fix out of bound image read. --- src/Engine/Data/EnvironmentTexture.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Engine/Data/EnvironmentTexture.cpp b/src/Engine/Data/EnvironmentTexture.cpp index 5de1caafed2..f6e9a727df6 100644 --- a/src/Engine/Data/EnvironmentTexture.cpp +++ b/src/Engine/Data/EnvironmentTexture.cpp @@ -435,18 +435,17 @@ void EnvironmentTexture::setupTexturesFromSphericalEquiRectangular() { Vector2 st { w * sphericalPhi( d ) / ( 2 * M_PI ), h * sphericalTheta( d ) / M_PI }; // TODO : use st to access and filter the original envmap // for now, no filtering is done. (eq to GL_NEAREST) - int s = int( st.x() ); - int t = int( st.y() ); - int cu = int( ( u / 2 + 0.5 ) * textureSize ); - int cv = int( ( v / 2 + 0.5 ) * textureSize ); - - m_skyData[imgIdx][4 * ( cv * textureSize + cu ) + 0] = - latlonPix[4 * ( t * w + s ) + 0]; - m_skyData[imgIdx][4 * ( cv * textureSize + cu ) + 1] = - latlonPix[4 * ( t * w + s ) + 1]; - m_skyData[imgIdx][4 * ( cv * textureSize + cu ) + 2] = - latlonPix[4 * ( t * w + s ) + 2]; - m_skyData[imgIdx][4 * ( cv * textureSize + cu ) + 3] = 1; + int s = std::clamp( int( st.x() ), 0, w - 1 ); + int t = std::clamp( int( st.y() ), 0, h - 1 ); + int cu = std::clamp( int( ( u / 2 + 0.5 ) * textureSize ), 0, textureSize - 1 ); + int cv = std::clamp( int( ( v / 2 + 0.5 ) * textureSize ), 0, textureSize - 1 ); + int skyIndex = 4 * ( cv * textureSize + cu ); + int latlonIndex = 4 * ( t * w + s ); + + m_skyData[imgIdx][skyIndex + 0] = latlonPix[latlonIndex + 0]; + m_skyData[imgIdx][skyIndex + 1] = latlonPix[latlonIndex + 1]; + m_skyData[imgIdx][skyIndex + 2] = latlonPix[latlonIndex + 2]; + m_skyData[imgIdx][skyIndex + 3] = 1; } } } From 9c3c244aee4b3883d89fcdc663423828d2d1cc07 Mon Sep 17 00:00:00 2001 From: dlyr Date: Mon, 25 Mar 2024 12:38:59 +0100 Subject: [PATCH 03/15] [engine] typo programm -> program. --- src/Engine/Data/ShaderProgramManager.hpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Engine/Data/ShaderProgramManager.hpp b/src/Engine/Data/ShaderProgramManager.hpp index 935f3792f7e..b064ad4f440 100644 --- a/src/Engine/Data/ShaderProgramManager.hpp +++ b/src/Engine/Data/ShaderProgramManager.hpp @@ -29,7 +29,7 @@ class ShaderConfiguration; * configuration, there is only one ShaderProgram instance in the system. * * This manager is a singleton. At the creation of the singleton, one can give parameters that will - * define the default shader programm example : Engine::ShaderProgramManager::createInstance( + * define the default shader program example : Engine::ShaderProgramManager::createInstance( * "Shaders/Default.vert.glsl", "Shaders/Default.frag.glsl" ); * */ @@ -49,7 +49,7 @@ class RA_ENGINE_API ShaderProgramManager final * The shader sources corresponding to the configuration will be compiled, linked and verified. * * - * \param config the configuration of the programm to add to the collection + * \param config the configuration of the program to add to the collection * \return the created shader program. In case of compile/link/verify error, return false * \note ownership on the returned pointer is keep by the manager. * \warning this method is *not* reentrant @@ -58,16 +58,16 @@ class RA_ENGINE_API ShaderProgramManager final addShaderProgram( const Data::ShaderConfiguration& config ); /** - * Get the shader programm corresponding to the given id - * \param id Name of the programm to retrieve - * \return the shader programm retrieved, nullptr if the program was not in the collection + * Get the shader program corresponding to the given id + * \param id Name of the program to retrieve + * \return the shader program retrieved, nullptr if the program was not in the collection */ const Data::ShaderProgram* getShaderProgram( const std::string& id ); /** - * Get the shader programm corresponding to the given configuration - * \param config Name of the programm to retrieve - * \return the shader programm retrieved, or nullptr when no shader programm corresponding to + * Get the shader program corresponding to the given configuration + * \param config Name of the program to retrieve + * \return the shader program retrieved, or nullptr when no shader program corresponding to * the configuration is found. */ const Data::ShaderProgram* getShaderProgram( const Data::ShaderConfiguration& config ); @@ -79,8 +79,8 @@ class RA_ENGINE_API ShaderProgramManager final void reloadAllShaderPrograms(); /** * Programs that did not compiled are temporarilly stored and could be reloaded and compiled - * when one call this method. If the reloaded programm is ok, it is removed from the set of not - * compiled program and added to the programm collection. + * when one call this method. If the reloaded program is ok, it is removed from the set of not + * compiled program and added to the program collection. */ void reloadNotCompiledShaderPrograms(); From f6dc1ec111ef8c680f01ed4c9f37aa4a9894710e Mon Sep 17 00:00:00 2001 From: dlyr Date: Mon, 25 Mar 2024 12:39:56 +0100 Subject: [PATCH 04/15] [gui] add missing viewer's delete pickingManager. --- src/Gui/Viewer/Viewer.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Gui/Viewer/Viewer.cpp b/src/Gui/Viewer/Viewer.cpp index af996546b39..e9fc0c2bcd1 100644 --- a/src/Gui/Viewer/Viewer.cpp +++ b/src/Gui/Viewer/Viewer.cpp @@ -155,6 +155,7 @@ Viewer::~Viewer() { delete m_gizmoManager; doneCurrent(); } + delete m_pickingManager; } void Viewer::setCameraManipulator( CameraManipulator* ci ) { @@ -480,6 +481,8 @@ bool Viewer::initializeGL() { // create default camera interface : trackball m_camera = std::make_unique(); m_camera->getCamera()->setViewport( deviceSize.x(), deviceSize.y() ); + + /// \todo who deletes this light ? auto headlight = new Engine::Scene::DirectionalLight( Ra::Engine::Scene::SystemEntity::getInstance(), "headlight" ); headlight->setColor( Ra::Core::Utils::Color::Grey( 1.0_ra ) ); From 80f8f9099361fc756299a6e8f1d25b536a423f75 Mon Sep 17 00:00:00 2001 From: dlyr Date: Mon, 25 Mar 2024 12:41:21 +0100 Subject: [PATCH 05/15] [headless] split Viewer/RadiumEngine CLI App to have CLI without renderer. --- src/Headless/CLIViewer.cpp | 93 +++++++++++++++++++++-------------- src/Headless/CLIViewer.hpp | 99 +++++++++++++++++++++++++------------- 2 files changed, 121 insertions(+), 71 deletions(-) diff --git a/src/Headless/CLIViewer.cpp b/src/Headless/CLIViewer.cpp index c1ebba1d2ed..7ab1f0c4107 100644 --- a/src/Headless/CLIViewer.cpp +++ b/src/Headless/CLIViewer.cpp @@ -21,34 +21,24 @@ using namespace Ra::Core::Utils; constexpr int defaultSystemPriority = 1000; -CLIViewer::CLIViewer( std::unique_ptr context ) : - CLIBaseApplication(), m_glContext { std::move( context ) } { - // add ->required() to force user to give a filename; - addOption( "-f,--file", m_parameters.m_dataFile, "Data file to process." ) - ->check( CLI::ExistingFile ); - addOption( "-s,--size", m_parameters.m_size, "Size of the computed image." )->delimiter( 'x' ); - addFlag( "-a,--animation", m_parameters.m_animationEnable, "Enable Radium Animation system." ); -} +CLIRadiumEngineApp::CLIRadiumEngineApp( std::unique_ptr context ) : + CLIBaseApplication(), m_glContext { std::move( context ) } {} -CLIViewer::~CLIViewer() { +CLIRadiumEngineApp::~CLIRadiumEngineApp() { if ( m_engineInitialized ) { m_glContext->makeCurrent(); - m_renderer.reset(); m_engine->cleanup(); Ra::Engine::RadiumEngine::destroyInstance(); m_glContext->doneCurrent(); } } -const CLIViewer::ViewerParameters& CLIViewer::getCommandLineParameters() const { - return m_parameters; -} - -int CLIViewer::init( int argc, const char* argv[] ) { +int CLIRadiumEngineApp::init( int argc, const char* argv[] ) { int parseResult = CLIBaseApplication::init( argc, argv ); if ( parseResult != 0 ) { if ( parseResult != 1 ) { LOG( logERROR ) << "Invalid command line argument, the application can't run"; + return parseResult; } return 1; }; @@ -58,16 +48,62 @@ int CLIViewer::init( int argc, const char* argv[] ) { return 1; } - m_glContext->resize( m_parameters.m_size ); - LOG( logINFO ) << "CLIViewer :\n" << m_glContext->getInfo(); - - // Initialize the Radium engine environment - // Create engine m_engine = Ra::Engine::RadiumEngine::createInstance(); m_engine->initialize(); m_engineInitialized = true; + // initialize OpenGL part of the Engine + m_glContext->makeCurrent(); + m_engine->initializeGL(); + m_glContext->doneCurrent(); + + // Init is OK + return 0; +} + +void CLIRadiumEngineApp::openGlAddOns( std::function f ) { + m_glContext->makeCurrent(); + f(); + m_glContext->doneCurrent(); +} + +void CLIRadiumEngineApp::bindOpenGLContext( bool on ) { + if ( on ) { m_glContext->makeCurrent(); } + else { m_glContext->doneCurrent(); } +} + +CLIViewer::CLIViewer( std::unique_ptr context ) : + CLIRadiumEngineApp( std::move( context ) ) { + // add ->required() to force user to give a filename; + addOption( "-f,--file", m_parameters.m_dataFile, "Data file to process." ) + ->check( CLI::ExistingFile ); + addOption( "-s,--size", m_parameters.m_size, "Size of the computed image." )->delimiter( 'x' ); + addFlag( "-a,--animation", m_parameters.m_animationEnable, "Enable Radium Animation system." ); +} + +CLIViewer::~CLIViewer() { + if ( m_engineInitialized ) { + m_glContext->makeCurrent(); + m_renderer.reset(); + m_glContext->doneCurrent(); + } +} + +const CLIViewer::ViewerParameters& CLIViewer::getCommandLineParameters() const { + return m_parameters; +} + +int CLIViewer::init( int argc, const char* argv[] ) { + + int parseResult = CLIRadiumEngineApp::init( argc, argv ); + if ( parseResult != 0 ) { return parseResult; }; + + m_glContext->resize( m_parameters.m_size ); + LOG( logINFO ) << "CLIViewer :\n" << m_glContext->getInfo(); + + // Initialize the Radium engine environment + // Register the GeometrySystem converting loaded assets to meshes m_engine->registerSystem( "GeometrySystem", new Ra::Engine::Scene::GeometrySystem, defaultSystemPriority ); @@ -80,11 +116,6 @@ int CLIViewer::init( int argc, const char* argv[] ) { defaultSystemPriority ); } - // initialize OpenGL part of the Engine - m_glContext->makeCurrent(); - m_engine->initializeGL(); - m_glContext->doneCurrent(); - // register listeners on the OpenGL Context m_glContext->resizeListener().attach( [this]( int width, int height ) { resize( width, height ); } ); @@ -149,18 +180,6 @@ void CLIViewer::compileScene() { } } } - -void CLIViewer::openGlAddOns( std::function f ) { - m_glContext->makeCurrent(); - f(); - m_glContext->doneCurrent(); -} - -void CLIViewer::bindOpenGLContext( bool on ) { - if ( on ) { m_glContext->makeCurrent(); } - else { m_glContext->doneCurrent(); } -} - Ra::Core::Utils::Index CLIViewer::setCamera( Ra::Core::Utils::Index camIdx ) { auto cameraManager = static_cast( Ra::Engine::RadiumEngine::getInstance()->getSystem( "DefaultCameraManager" ) ); diff --git a/src/Headless/CLIViewer.hpp b/src/Headless/CLIViewer.hpp index 83d53ae57d4..2a659215cf0 100644 --- a/src/Headless/CLIViewer.hpp +++ b/src/Headless/CLIViewer.hpp @@ -26,6 +26,7 @@ class Renderer; } // namespace Engine namespace Headless { + /** * Base class for radium based cmdline application. * @@ -33,45 +34,70 @@ namespace Headless { * interaction capabilities. * */ -class HEADLESS_API CLIViewer : public CLIBaseApplication +class HEADLESS_API CLIRadiumEngineApp : public CLIBaseApplication { public: - struct ViewerParameters { - /// Load animation system at startup - bool m_animationEnable { false }; - /// Size of the image - std::array m_size { { 512, 512 } }; - /// image name prefix - std::string m_imgPrefix { "frame" }; - /// The data file to manage - std::string m_dataFile = { "" }; - }; - - public: - /// Instance of the radium engine. - Ra::Engine::RadiumEngine* m_engine; + /** + * \brief Construct the viewer using an OpenGL context of the given version + * \param context the opengl context, e.g. EglOpenGLContext or GlfwOpenGLContext. + */ + explicit CLIRadiumEngineApp( std::unique_ptr context ); + /// Base destructor + virtual ~CLIRadiumEngineApp(); /// To have the same API to access Engine than in Qt based application. const Engine::RadiumEngine* getEngine() const { return m_engine; } - private: - /// Headless OpenGLContext - std::unique_ptr m_glContext; + /** + * \brief Application initialization method. + * + * This method is called by the main function to initialize the app giving its parameters. + * \param argc number of parameter + * \param argv array of string representing the parameters + * \return 0 if the application is correctly initialized or an application dependant error code + * if something went wrong. + * + * Supported command line parameters are --help and --file \ from + * CLIRadiumApplication and the following parameters : + * - --size \ : the size of the rendered picture + * - --animation : load the Radium animation system + * - --env \ : load and use the given environment map. + */ + int init( int argc, const char* argv[] ) override; - /// Shared instance of the renderer - std::shared_ptr m_renderer; + /** Register OpenGL addons + * The given functor will be called with the OpenGL context bound + */ + void openGlAddOns( std::function f ); - /// The camera for rendering - Ra::Core::Asset::Camera* m_camera { nullptr }; + /** Activate/deactivate the OpenGL context */ + void bindOpenGLContext( bool on = true ); - /// The application parameters - ViewerParameters m_parameters; + // private: + protected: /// \todo make privaet and check access + /// Headless OpenGLContext + std::unique_ptr m_glContext; /// is the engine initialized ? bool m_engineInitialized { false }; - /// is the window shown ? - bool m_exposedWindow { false }; + /// Instance of the radium engine. + Ra::Engine::RadiumEngine* m_engine; +}; + +class HEADLESS_API CLIViewer : public CLIRadiumEngineApp +{ + public: + struct ViewerParameters { + /// Load animation system at startup + bool m_animationEnable { false }; + /// Size of the image + std::array m_size { { 512, 512 } }; + /// image name prefix + std::string m_imgPrefix { "frame" }; + /// The data file to manage + std::string m_dataFile = { "" }; + }; public: /** @@ -130,14 +156,6 @@ class HEADLESS_API CLIViewer : public CLIBaseApplication */ void compileScene(); - /** Register OpenGL addons - * The given functor will be called with the OpenGL context bound - */ - void openGlAddOns( std::function f ); - - /** Activate/deactivate the OpenGL context */ - void bindOpenGLContext( bool on = true ); - /** \brief Define the camera to be used for rendering. * If the index is invalid according to the engine's camera manager, set the camera from index 0 * after, if needed, creating and adding to the manager a default camera. @@ -185,6 +203,19 @@ class HEADLESS_API CLIViewer : public CLIBaseApplication protected: /// Observer of the resize event on the OpenGLContext void resize( int width, int height ); + + private: + /// Shared instance of the renderer + std::shared_ptr m_renderer; + + /// The camera for rendering + Ra::Core::Asset::Camera* m_camera { nullptr }; + + /// The application parameters + ViewerParameters m_parameters; + + /// is the window shown ? + bool m_exposedWindow { false }; }; inline std::string CLIViewer::getDataFileName() const { From d2510f8661f0c5e27f894d9ce7465f39e17e63ae Mon Sep 17 00:00:00 2001 From: dlyr Date: Mon, 25 Mar 2024 12:41:51 +0100 Subject: [PATCH 06/15] [examples] use CLI getter (now member variable is private). --- examples/HeadlessExample/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/HeadlessExample/main.cpp b/examples/HeadlessExample/main.cpp index 1175a72ccb1..3cad9330653 100644 --- a/examples/HeadlessExample/main.cpp +++ b/examples/HeadlessExample/main.cpp @@ -39,9 +39,9 @@ int main( int argc, const char* argv[] ) { //! [Configuring the viewer : initialize OpenGL and the Engine] //! [Verifying the OpenGL version available to the engine] - if ( glVersion != viewer.m_engine->getOpenGLVersion() ) { + if ( glVersion != viewer.getEngine()->getOpenGLVersion() ) { std::cout << "OpenGL version mismatch : requested " << glVersion.toString() - << " -- available " << viewer.m_engine->getOpenGLVersion().toString() + << " -- available " << viewer.getEngine()->getOpenGLVersion().toString() << std::endl; } //! [Verifying the OpenGL version available to the engine] From 3f5279e1309c48ff32dc8f85a3253d2c9d11d7a0 Mon Sep 17 00:00:00 2001 From: dlyr Date: Wed, 3 Apr 2024 14:00:54 +0200 Subject: [PATCH 07/15] [cmake] Code coverage verbose message without STATUS. to ease copy paste. --- cmake/CodeCoverage.cmake | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/cmake/CodeCoverage.cmake b/cmake/CodeCoverage.cmake index 45b9fd04d6f..8ab6ead0c0c 100644 --- a/cmake/CodeCoverage.cmake +++ b/cmake/CodeCoverage.cmake @@ -340,36 +340,36 @@ function(setup_target_for_coverage_lcov) message(STATUS "Executed command report") message(STATUS "Command to clean up lcov: ") string(REPLACE ";" " " LCOV_CLEAN_CMD_SPACED "${LCOV_CLEAN_CMD}") - message(STATUS "${LCOV_CLEAN_CMD_SPACED}") + message("${LCOV_CLEAN_CMD_SPACED}") message(STATUS "Command to create baseline: ") string(REPLACE ";" " " LCOV_BASELINE_CMD_SPACED "${LCOV_BASELINE_CMD}") - message(STATUS "${LCOV_BASELINE_CMD_SPACED}") + message("${LCOV_BASELINE_CMD_SPACED}") message(STATUS "Command to run the tests: ") string(REPLACE ";" " " LCOV_EXEC_TESTS_CMD_SPACED "${LCOV_EXEC_TESTS_CMD}") - message(STATUS "${LCOV_EXEC_TESTS_CMD_SPACED}") + message("${LCOV_EXEC_TESTS_CMD_SPACED}") message(STATUS "Command to capture counters and generate report: ") string(REPLACE ";" " " LCOV_CAPTURE_CMD_SPACED "${LCOV_CAPTURE_CMD}") - message(STATUS "${LCOV_CAPTURE_CMD_SPACED}") + message("${LCOV_CAPTURE_CMD_SPACED}") message(STATUS "Command to add baseline counters: ") string(REPLACE ";" " " LCOV_BASELINE_COUNT_CMD_SPACED "${LCOV_BASELINE_COUNT_CMD}") - message(STATUS "${LCOV_BASELINE_COUNT_CMD_SPACED}") + message("${LCOV_BASELINE_COUNT_CMD_SPACED}") message(STATUS "Command to filter collected data: ") string(REPLACE ";" " " LCOV_FILTER_CMD_SPACED "${LCOV_FILTER_CMD}") - message(STATUS "${LCOV_FILTER_CMD_SPACED}") + message("${LCOV_FILTER_CMD_SPACED}") message(STATUS "Command to generate lcov HTML output: ") string(REPLACE ";" " " LCOV_GEN_HTML_CMD_SPACED "${LCOV_GEN_HTML_CMD}") - message(STATUS "${LCOV_GEN_HTML_CMD_SPACED}") + message("${LCOV_GEN_HTML_CMD_SPACED}") if(${Coverage_SONARQUBE}) message(STATUS "Command to generate SonarQube XML output: ") string(REPLACE ";" " " GCOVR_XML_CMD_SPACED "${GCOVR_XML_CMD}") - message(STATUS "${GCOVR_XML_CMD_SPACED}") + message("${GCOVR_XML_CMD_SPACED}") endif() endif() @@ -466,11 +466,11 @@ function(setup_target_for_coverage_gcovr_xml) message(STATUS "Command to run tests: ") string(REPLACE ";" " " GCOVR_XML_EXEC_TESTS_CMD_SPACED "${GCOVR_XML_EXEC_TESTS_CMD}") - message(STATUS "${GCOVR_XML_EXEC_TESTS_CMD_SPACED}") + message("${GCOVR_XML_EXEC_TESTS_CMD_SPACED}") message(STATUS "Command to generate gcovr XML coverage data: ") string(REPLACE ";" " " GCOVR_XML_CMD_SPACED "${GCOVR_XML_CMD}") - message(STATUS "${GCOVR_XML_CMD_SPACED}") + message("${GCOVR_XML_CMD_SPACED}") endif() add_custom_target( @@ -560,15 +560,15 @@ function(setup_target_for_coverage_gcovr_html) message(STATUS "Command to run tests: ") string(REPLACE ";" " " GCOVR_HTML_EXEC_TESTS_CMD_SPACED "${GCOVR_HTML_EXEC_TESTS_CMD}") - message(STATUS "${GCOVR_HTML_EXEC_TESTS_CMD_SPACED}") + message("${GCOVR_HTML_EXEC_TESTS_CMD_SPACED}") message(STATUS "Command to create a folder: ") string(REPLACE ";" " " GCOVR_HTML_FOLDER_CMD_SPACED "${GCOVR_HTML_FOLDER_CMD}") - message(STATUS "${GCOVR_HTML_FOLDER_CMD_SPACED}") + message("${GCOVR_HTML_FOLDER_CMD_SPACED}") message(STATUS "Command to generate gcovr HTML coverage data: ") string(REPLACE ";" " " GCOVR_HTML_CMD_SPACED "${GCOVR_HTML_CMD}") - message(STATUS "${GCOVR_HTML_CMD_SPACED}") + message("${GCOVR_HTML_CMD_SPACED}") endif() add_custom_target( From 22beb8d1f53ed3bc8c58c46eca451d3e6a6ca691 Mon Sep 17 00:00:00 2001 From: dlyr Date: Wed, 3 Apr 2024 16:27:28 +0200 Subject: [PATCH 08/15] [cmake] do not warn missing default on switch. It's not an error, and enforcing is prone to error (e.g. missing enum value case). --- cmake/CompilerOptions.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/cmake/CompilerOptions.cmake b/cmake/CompilerOptions.cmake index 18b9b6e67f0..b3da66e8e7a 100644 --- a/cmake/CompilerOptions.cmake +++ b/cmake/CompilerOptions.cmake @@ -120,7 +120,6 @@ if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHE -Wmissing-braces -Wreturn-type -Wswitch - -Wswitch-default -Wuninitialized -Wmissing-field-initializers $<$: From 74817866f3dba0476f933eab384b5db80ca0a891 Mon Sep 17 00:00:00 2001 From: dlyr Date: Wed, 3 Apr 2024 16:29:07 +0200 Subject: [PATCH 09/15] [core][engine][headless][tests] fix warnings. double brace array initializer, suffix shadow variable with underscore. --- src/Core/Geometry/MeshPrimitives.cpp | 2 +- src/Engine/Data/EnvironmentTexture.cpp | 4 ++-- src/Engine/Data/TextureManager.cpp | 2 +- src/Engine/Scene/ComponentMessenger.cpp | 2 +- src/Headless/CLI/TypeTools.hpp | 2 +- tests/unittest/Core/variableset.cpp | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Core/Geometry/MeshPrimitives.cpp b/src/Core/Geometry/MeshPrimitives.cpp index 04dbe9eb249..7abe1940016 100644 --- a/src/Core/Geometry/MeshPrimitives.cpp +++ b/src/Core/Geometry/MeshPrimitives.cpp @@ -277,7 +277,7 @@ makeGeodesicSphere( Scalar radius, uint numSubdiv, const Utils::optional triVertices = { - vertices[tri[0]], vertices[tri[1]], vertices[tri[2]] }; + { vertices[tri[0]], vertices[tri[1]], vertices[tri[2]] } }; std::array middles; for ( uint v = 0; v < 3; ++v ) { diff --git a/src/Engine/Data/EnvironmentTexture.cpp b/src/Engine/Data/EnvironmentTexture.cpp index f6e9a727df6..a386660dd66 100644 --- a/src/Engine/Data/EnvironmentTexture.cpp +++ b/src/Engine/Data/EnvironmentTexture.cpp @@ -145,7 +145,7 @@ using namespace Ra::Core; // ------------------------------------------------------------------- EnvironmentTexture::EnvironmentTexture( const std::string& mapName, bool isSkybox ) : m_name( mapName ), - m_skyData { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr }, + m_skyData { { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr } }, m_isSkyBox( isSkybox ) { m_type = ( mapName.find( ';' ) != mapName.npos ) ? EnvironmentTexture::EnvMapType::ENVMAP_CUBE : EnvironmentTexture::EnvMapType::ENVMAP_PFM; @@ -175,7 +175,7 @@ void EnvironmentTexture::initializeTexture() { // proper convert shared ptr float[] to void std::array, 6> cubeMap = { - m_skyData[0], m_skyData[1], m_skyData[2], m_skyData[3], m_skyData[4], m_skyData[5] }; + { m_skyData[0], m_skyData[1], m_skyData[2], m_skyData[3], m_skyData[4], m_skyData[5] } }; Ra::Engine::Data::TextureParameters params { m_name, { GL_CLAMP_TO_EDGE, diff --git a/src/Engine/Data/TextureManager.cpp b/src/Engine/Data/TextureManager.cpp index 7991ad7a1ca..0d7444b6016 100644 --- a/src/Engine/Data/TextureManager.cpp +++ b/src/Engine/Data/TextureManager.cpp @@ -24,7 +24,7 @@ TextureManager::TextureHandle TextureManager::addTexture( const TextureParameter TextureHandle handle; // find first free slot in m_textures, e.g. where the stored unique_ptr is nullptr auto it = std::find_if( - m_textures.begin(), m_textures.end(), []( const auto& texture ) { return !texture; } ); + m_textures.begin(), m_textures.end(), []( const auto& texture_ ) { return !texture_; } ); if ( it != m_textures.end() ) { it->swap( texture ); handle.setValue( std::distance( m_textures.begin(), it ) ); diff --git a/src/Engine/Scene/ComponentMessenger.cpp b/src/Engine/Scene/ComponentMessenger.cpp index 2b46d148afa..48f7f811846 100644 --- a/src/Engine/Scene/ComponentMessenger.cpp +++ b/src/Engine/Scene/ComponentMessenger.cpp @@ -10,7 +10,7 @@ RA_SINGLETON_IMPLEMENTATION( ComponentMessenger ); void ComponentMessenger::unregisterAll( const Entity* entity, Component* comp ) { for ( auto& entityList : std::array, 3> { - m_entitySetLists, m_entityGetLists, m_entityRwLists } ) { + { m_entitySetLists, m_entityGetLists, m_entityRwLists } } ) { auto listItr = entityList.get().find( entity ); if ( listItr != entityList.get().end() ) { diff --git a/src/Headless/CLI/TypeTools.hpp b/src/Headless/CLI/TypeTools.hpp index f60b5ddfc0d..5155bd64e31 100644 --- a/src/Headless/CLI/TypeTools.hpp +++ b/src/Headless/CLI/TypeTools.hpp @@ -1341,7 +1341,7 @@ bool lexical_conversion( const std::vector& strings, AssignTo& out if ( strings.size() > 1 ) { retval = retval && lexical_assign( strings[1], v2 ); } - if ( retval ) { output = AssignTo { v1, v2 }; } + if ( retval ) { output = AssignTo { { v1, v2 } }; } return retval; } diff --git a/tests/unittest/Core/variableset.cpp b/tests/unittest/Core/variableset.cpp index 8980d2ac1b9..f8f5378e523 100644 --- a/tests/unittest/Core/variableset.cpp +++ b/tests/unittest/Core/variableset.cpp @@ -158,7 +158,7 @@ TEST_CASE( "Core/Container/VariableSet", "[Core][Container][VariableSet]" ) { print_container( "Initial set", params ); - auto modifyFunction = []( int x ) { return 2 * x + 1; }; + auto modifyFunction = []( int x_ ) { return 2 * x_ + 1; }; REQUIRE( params.getVariable( "i" ) == 0 ); REQUIRE( params.getVariable( "x" ) == 1 ); From 9430d3d8c73e63b3535a93c3ea0c7c3dcd8c5315 Mon Sep 17 00:00:00 2001 From: dlyr Date: Wed, 3 Apr 2024 16:29:40 +0200 Subject: [PATCH 10/15] [tests][cmake] parrallel ctest. --- tests/CMakeLists.txt | 6 ++++-- tests/unittest/CMakeLists.txt | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a73e5c6eae2..83518cee5fe 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -38,7 +38,8 @@ add_custom_target( check COMMAND echo [----] Running tests USES_TERMINAL - COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C ${CMAKE_BUILD_TYPE} + COMMAND ${CMAKE_CTEST_COMMAND} -j $ENV{CMAKE_BUILD_PARALLEL_LEVEL} --output-on-failure -C + ${CMAKE_BUILD_TYPE} DEPENDS unittests integration ) @@ -46,7 +47,8 @@ add_custom_target( check_verbose COMMAND echo [----] Running tests USES_TERMINAL - COMMAND ${CMAKE_CTEST_COMMAND} -V --output-on-failure -C ${CMAKE_BUILD_TYPE} + COMMAND ${CMAKE_CTEST_COMMAND} -j $ENV{CMAKE_BUILD_PARALLEL_LEVEL} -V --output-on-failure -C + ${CMAKE_BUILD_TYPE} DEPENDS unittests integration ) diff --git a/tests/unittest/CMakeLists.txt b/tests/unittest/CMakeLists.txt index ba671f70754..ed7a29055ba 100644 --- a/tests/unittest/CMakeLists.txt +++ b/tests/unittest/CMakeLists.txt @@ -77,6 +77,7 @@ endif() include(../external/Catch2/src/Catch2_download/contrib/Catch.cmake) +# adds catch tests to ctest catch_discover_tests(unittests WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) # convenience target for running only the unit tests From d2f48aec29732f85e0bab0e21398f4816e3c34dd Mon Sep 17 00:00:00 2001 From: dlyr Date: Wed, 3 Apr 2024 16:30:29 +0200 Subject: [PATCH 11/15] [cmake] updates CodeCoverage.cmake according to upstream and local fixes. --- cmake/CodeCoverage.cmake | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/cmake/CodeCoverage.cmake b/cmake/CodeCoverage.cmake index 8ab6ead0c0c..3db68423528 100644 --- a/cmake/CodeCoverage.cmake +++ b/cmake/CodeCoverage.cmake @@ -166,11 +166,19 @@ foreach(LANG ${LANGUAGES}) endforeach() set(COVERAGE_COMPILER_FLAGS "-g --coverage" CACHE INTERNAL "") + if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)") include(CheckCXXCompilerFlag) - check_cxx_compiler_flag(-fprofile-abs-path HAVE_fprofile_abs_path) - if(HAVE_fprofile_abs_path) - set(COVERAGE_COMPILER_FLAGS "${COVERAGE_COMPILER_FLAGS} -fprofile-abs-path") + check_cxx_compiler_flag(-fprofile-abs-path HAVE_cxx_fprofile_abs_path) + if(HAVE_cxx_fprofile_abs_path) + set(COVERAGE_CXX_COMPILER_FLAGS "${COVERAGE_COMPILER_FLAGS} -fprofile-abs-path") + endif() +endif() +if(CMAKE_C_COMPILER_ID MATCHES "(GNU|Clang)") + include(CheckCCompilerFlag) + check_c_compiler_flag(-fprofile-abs-path HAVE_c_fprofile_abs_path) + if(HAVE_c_fprofile_abs_path) + set(COVERAGE_C_COMPILER_FLAGS "${COVERAGE_COMPILER_FLAGS} -fprofile-abs-path") endif() endif() @@ -239,8 +247,7 @@ function(setup_target_for_coverage_lcov) set(LCOV_EXCLUDES "") foreach(EXCLUDE ${Coverage_EXCLUDE} ${COVERAGE_EXCLUDES} ${COVERAGE_LCOV_EXCLUDES}) if(CMAKE_VERSION VERSION_GREATER 3.4) - # this don't support regexp get_filename_component(EXCLUDE ${EXCLUDE} ABSOLUTE BASE_DIR - # ${BASEDIR}) + get_filename_component(EXCLUDE ${EXCLUDE} ABSOLUTE BASE_DIR ${BASEDIR}) endif() list(APPEND LCOV_EXCLUDES "${EXCLUDE}") endforeach() @@ -440,7 +447,7 @@ function(setup_target_for_coverage_gcovr_xml) set(GCOVR_EXCLUDES "") foreach(EXCLUDE ${Coverage_EXCLUDE} ${COVERAGE_EXCLUDES} ${COVERAGE_GCOVR_EXCLUDES}) if(CMAKE_VERSION VERSION_GREATER 3.4) - # get_filename_component(EXCLUDE ${EXCLUDE} ABSOLUTE BASE_DIR ${BASEDIR}) + get_filename_component(EXCLUDE ${EXCLUDE} ABSOLUTE BASE_DIR ${BASEDIR}) endif() list(APPEND GCOVR_EXCLUDES "${EXCLUDE}") endforeach() @@ -523,7 +530,7 @@ function(setup_target_for_coverage_gcovr_html) set(GCOVR_EXCLUDES "") foreach(EXCLUDE ${Coverage_EXCLUDE} ${COVERAGE_EXCLUDES} ${COVERAGE_GCOVR_EXCLUDES}) if(CMAKE_VERSION VERSION_GREATER 3.4) - # get_filename_component(EXCLUDE ${EXCLUDE} ABSOLUTE BASE_DIR ${BASEDIR}) + get_filename_component(EXCLUDE ${EXCLUDE} ABSOLUTE BASE_DIR ${BASEDIR}) endif() list(APPEND GCOVR_EXCLUDES "${EXCLUDE}") endforeach() @@ -648,7 +655,7 @@ function(setup_target_for_coverage_fastcov) --gcov ${GCOV_PATH} --search-directory - ${BASEDIR} + ${CMAKE_BINARY_DIR} --process-gcno --output ${Coverage_NAME}.json @@ -705,7 +712,7 @@ function(setup_target_for_coverage_fastcov) ${Coverage_NAME} # Cleanup fastcov COMMAND ${FASTCOV_PATH} ${Coverage_FASTCOV_ARGS} --gcov ${GCOV_PATH} --search-directory - ${BASEDIR} --zerocounters + ${CMAKE_BINARY_DIR} --zerocounters COMMAND ${FASTCOV_EXEC_TESTS_CMD} COMMAND ${FASTCOV_CAPTURE_CMD} COMMAND ${FASTCOV_CONVERT_CMD} @@ -749,7 +756,9 @@ endfunction() # append_coverage_compiler_flags function(append_coverage_compiler_flags_to_target name) separate_arguments(_flag_list NATIVE_COMMAND "${COVERAGE_COMPILER_FLAGS}") target_compile_options(${name} PRIVATE ${_flag_list}) - if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") + if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU" + OR CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" + ) target_link_libraries(${name} PRIVATE gcov) endif() endfunction() From 497b7a2923c983c6d809bd7515be2b4a9f5ae66b Mon Sep 17 00:00:00 2001 From: dlyr Date: Wed, 3 Apr 2024 16:31:14 +0200 Subject: [PATCH 12/15] [cmake] Update coverage exclude and basedir. --- CMakeLists.txt | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 31a2ac63331..30f0208ccae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -218,26 +218,37 @@ if(RADIUM_ENABLE_TESTING) endif() if(RADIUM_ENABLE_COVERAGE) + append_coverage_compiler_flags() setup_target_for_coverage_lcov( NAME coverage EXECUTABLE - ctest + ${CMAKE_CTEST_COMMAND} + --output-on-failure + -C + ${CMAKE_BUILD_TYPE} -j $ENV{CMAKE_BUILD_PARALLEL_LEVEL} + BASE_DIRECTORY + "/" DEPENDENCIES RadiumLibs unittests integration EXCLUDE + "/*external*/" + "/*/glbinding/*" + "/*/globjects/*" + "/*/OpenMesh/*" + "/*/assimp/*" + "/*/eigen3/*" + "/*/nlohmann/*" + "/*/stb/*" "/usr/*" - "*examples*" - "*external*" - "*install*" - "*/Catch2/*" - "*_autogen/*" - "*build*" - "*mocs*" + "${CMAKE_SOURCE_DIR}/examples*" + "${CMAKE_SOURCE_DIR}/*/Catch2/*" + "${CMAKE_BINARY_DIR}/*_autogen/*" + "${CMAKE_BINARY_DIR}/*mocs*" ) # Fastcov is not supported with gcov llvm: disabling for MacOS Source: @@ -247,16 +258,28 @@ if(RADIUM_ENABLE_COVERAGE) NAME coverage_fastcov EXECUTABLE - ctest + ${CMAKE_CTEST_COMMAND} + --output-on-failure + -C + ${CMAKE_BUILD_TYPE} -j $ENV{CMAKE_BUILD_PARALLEL_LEVEL} DEPENDENCIES RadiumLibs unittests integration + BASE_DIRECTORY + "/" EXCLUDE "/usr/" "examples" + "glbinding" + "globjects" + "OpenMesh" + "assimp" + "eigen3" + "nlohmann" + "stb" "external" "install" "/Catch2/" From b1e0a05dd9a253f193542b6f8ac4f4d49d713d27 Mon Sep 17 00:00:00 2001 From: dlyr Date: Fri, 5 Apr 2024 16:45:11 +0200 Subject: [PATCH 13/15] [cmake] CMAKE_AUTOMOC_PATH_PREFIX to fix coverage. To have absolute includes in moc. --- src/Gui/CMakeLists.txt | 1 + src/PluginBase/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Gui/CMakeLists.txt b/src/Gui/CMakeLists.txt index c348f148ee9..467e75ad947 100644 --- a/src/Gui/CMakeLists.txt +++ b/src/Gui/CMakeLists.txt @@ -17,6 +17,7 @@ find_package(PowerSlider REQUIRED) # Qt set(Qt_LIBRARIES Qt::Core Qt::Widgets Qt::OpenGL Qt::Xml) +set(CMAKE_AUTOMOC_PATH_PREFIX ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) diff --git a/src/PluginBase/CMakeLists.txt b/src/PluginBase/CMakeLists.txt index 6da682d67fa..2bf0b5c70f7 100644 --- a/src/PluginBase/CMakeLists.txt +++ b/src/PluginBase/CMakeLists.txt @@ -13,6 +13,7 @@ find_qt_package(COMPONENTS Core REQUIRED) # Qt set(Qt_LIBRARIES Qt::Core) +set(CMAKE_AUTOMOC_PATH_PREFIX ON) set(CMAKE_AUTOMOC ON) add_library( From e6cb7f5f33017afb2e5cffbeae8090707b2bfe96 Mon Sep 17 00:00:00 2001 From: dlyr Date: Wed, 3 Apr 2024 07:58:32 +0200 Subject: [PATCH 14/15] [gui] Add viewer getter. --- src/Gui/BaseApplication.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Gui/BaseApplication.hpp b/src/Gui/BaseApplication.hpp index 9ea841c28c2..8f42bd512a8 100644 --- a/src/Gui/BaseApplication.hpp +++ b/src/Gui/BaseApplication.hpp @@ -128,6 +128,7 @@ class RA_GUI_API BaseApplication : public QApplication bool isRunning() const { return !m_isAboutToQuit; } const Engine::RadiumEngine* getEngine() const { return m_engine; } + Viewer* getViewer() { return m_viewer; } uint getFrameCount() const { return m_frameCounter; } From 5e66aec7f5ee9cbd32afad72c9f43e4fb80caa82 Mon Sep 17 00:00:00 2001 From: dlyr Date: Wed, 3 Apr 2024 07:59:22 +0200 Subject: [PATCH 15/15] [engine] factorize texture init with for loops. --- src/Core/Geometry/OpenMesh.hpp | 1 + src/Engine/Rendering/ForwardRenderer.cpp | 53 ++++++------------------ src/Engine/Rendering/ForwardRenderer.hpp | 10 ++++- 3 files changed, 23 insertions(+), 41 deletions(-) diff --git a/src/Core/Geometry/OpenMesh.hpp b/src/Core/Geometry/OpenMesh.hpp index b76d9d2555c..1899069e9db 100644 --- a/src/Core/Geometry/OpenMesh.hpp +++ b/src/Core/Geometry/OpenMesh.hpp @@ -1,3 +1,4 @@ + #pragma once #include diff --git a/src/Engine/Rendering/ForwardRenderer.cpp b/src/Engine/Rendering/ForwardRenderer.cpp index 6f171d63d2c..de2dc40918a 100644 --- a/src/Engine/Rendering/ForwardRenderer.cpp +++ b/src/Engine/Rendering/ForwardRenderer.cpp @@ -106,9 +106,12 @@ void ForwardRenderer::initBuffers() { texparams.image.internalFormat = GL_DEPTH_COMPONENT24; texparams.image.format = GL_DEPTH_COMPONENT; texparams.image.type = GL_UNSIGNED_INT; - texparams.name = "Depth (fw renderer)"; + texparams.name = m_textureNames[0]; m_textures[RendererTextures_Depth] = std::make_unique( texparams ); + m_secondaryTextures[m_textureNames[RendererTextures_Depth]] = + m_textures[RendererTextures_Depth].get(); + // Color texture texparams.image.internalFormat = GL_RGBA32F; texparams.image.format = GL_RGBA; @@ -116,37 +119,12 @@ void ForwardRenderer::initBuffers() { texparams.sampler.minFilter = GL_LINEAR; texparams.sampler.magFilter = GL_LINEAR; - texparams.name = "HDR"; - m_textures[RendererTextures_HDR] = std::make_unique( texparams ); - - texparams.name = "Normal"; - m_textures[RendererTextures_Normal] = std::make_unique( texparams ); - - texparams.name = "Diffuse"; - m_textures[RendererTextures_Diffuse] = std::make_unique( texparams ); - - texparams.name = "Specular"; - m_textures[RendererTextures_Specular] = std::make_unique( texparams ); - - texparams.name = "OIT Accum"; - m_textures[RendererTextures_OITAccum] = std::make_unique( texparams ); - - texparams.name = "OIT Revealage"; - m_textures[RendererTextures_OITRevealage] = std::make_unique( texparams ); - - texparams.name = "Volume"; - m_textures[RendererTextures_Volume] = std::make_unique( texparams ); - - m_secondaryTextures["Depth (fw)"] = m_textures[RendererTextures_Depth].get(); - m_secondaryTextures["HDR Texture"] = m_textures[RendererTextures_HDR].get(); - m_secondaryTextures["Normal Texture"] = m_textures[RendererTextures_Normal].get(); - m_secondaryTextures["Diffuse Texture"] = m_textures[RendererTextures_Diffuse].get(); - m_secondaryTextures["Specular Texture"] = m_textures[RendererTextures_Specular].get(); - m_secondaryTextures["OIT Accum"] = m_textures[RendererTextures_OITAccum].get(); - m_secondaryTextures["OIT Revealage"] = m_textures[RendererTextures_OITRevealage].get(); - - // Volume texture is not exposed ... - m_secondaryTextures["Volume"] = m_textures[RendererTextures_Volume].get(); + // init textures other than depth (which is the first in the array, index 0) + for ( int i = RendererTextures_Depth + 1; i < RendererTexture_Count; ++i ) { + texparams.name = m_textureNames[i]; + m_textures[i] = std::make_unique( texparams ); + m_secondaryTextures[m_textureNames[i]] = m_textures[i].get(); + } } void ForwardRenderer::updateStepInternal( const Data::ViewingParameters& renderData ) { @@ -610,14 +588,9 @@ void ForwardRenderer::postProcessInternal( const Data::ViewingParameters& render void ForwardRenderer::resizeInternal() { m_pingPongSize = std::pow( uint( 2 ), uint( std::log2( std::min( m_width, m_height ) ) ) ); - m_textures[RendererTextures_Depth]->resize( m_width, m_height ); - m_textures[RendererTextures_HDR]->resize( m_width, m_height ); - m_textures[RendererTextures_Normal]->resize( m_width, m_height ); - m_textures[RendererTextures_Diffuse]->resize( m_width, m_height ); - m_textures[RendererTextures_Specular]->resize( m_width, m_height ); - m_textures[RendererTextures_OITAccum]->resize( m_width, m_height ); - m_textures[RendererTextures_OITRevealage]->resize( m_width, m_height ); - m_textures[RendererTextures_Volume]->resize( m_width, m_height ); + for ( auto& tex : m_textures ) { + tex->resize( m_width, m_height ); + } m_fbo->bind(); m_fbo->attachTexture( GL_DEPTH_ATTACHMENT, diff --git a/src/Engine/Rendering/ForwardRenderer.hpp b/src/Engine/Rendering/ForwardRenderer.hpp index a9466857fcc..03ce90b1e99 100644 --- a/src/Engine/Rendering/ForwardRenderer.hpp +++ b/src/Engine/Rendering/ForwardRenderer.hpp @@ -53,7 +53,7 @@ class RA_ENGINE_API ForwardRenderer : public Renderer virtual void renderBackground( const Data::ViewingParameters& ) {} enum RendererTextures { - RendererTextures_Depth = 0, + RendererTextures_Depth = 0, // need to be the first, since used for other textures init RendererTextures_HDR, RendererTextures_Normal, RendererTextures_Diffuse, @@ -63,6 +63,14 @@ class RA_ENGINE_API ForwardRenderer : public Renderer RendererTextures_Volume, RendererTexture_Count }; + std::array m_textureNames { { "Depth (fw)", + "HDR", + "Normal", + "Diffuse", + "Specular", + "OIT Accum", + "OIT Revealage", + "Volume" } }; // Default renderer logic here, no need to be accessed by overriding renderers. std::unique_ptr m_fbo;