From ddd1f8e5599923d5e935c955782359bb0b86ff1c Mon Sep 17 00:00:00 2001 From: Mathias Paulin Date: Fri, 17 Mar 2023 18:55:42 +0100 Subject: [PATCH] [examples] add support for libGLTF for graph-base rendering exemple --- .../GraphRendering/CMakeLists.txt | 15 +++++++++++++++ .../DataflowExamples/GraphRendering/main.cpp | 19 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/examples/DataflowExamples/GraphRendering/CMakeLists.txt b/examples/DataflowExamples/GraphRendering/CMakeLists.txt index 7bb6e7d1adf..af156ab5f3c 100644 --- a/examples/DataflowExamples/GraphRendering/CMakeLists.txt +++ b/examples/DataflowExamples/GraphRendering/CMakeLists.txt @@ -55,4 +55,19 @@ target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17) target_link_libraries(${PROJECT_NAME} PUBLIC ${Qt_LIBRARIES} Radium::Dataflow) +# ------------------------------------------------------------------------------ +# RadiumGlTF is available here https://gitlab.irit.fr/storm/repos/radium/libgltf.git (using the +# right branch). Compile RadiumGlTF, then configure using cmake [your configure args] +# -DRadiumGlTF_DIR="path/to/RadiumGlTF/build-dir/src/RadiumGlTF" -DUSE_RADIUMGLTF=ON to use it for +# this example. +option(USE_RADIUMGLTF "Enable loading/saving files with RadiumGltf extension" OFF) +if(USE_RADIUMGLTF) + message(STATUS "${PROJECT_NAME} uses RadiumGltf extension") + # TODO : find why this find_package is needed (at least on MacOs whe ). + find_package(OpenMP QUIET) + find_package(RadiumGlTF REQUIRED) + target_compile_definitions(${PROJECT_NAME} PUBLIC USE_RADIUMGLTF) + target_link_libraries(${PROJECT_NAME} PUBLIC RadiumGlTF::RadiumGlTF) +endif() + configure_radium_app(NAME ${PROJECT_NAME}) diff --git a/examples/DataflowExamples/GraphRendering/main.cpp b/examples/DataflowExamples/GraphRendering/main.cpp index 5deaba1a9b3..494b5f61fde 100644 --- a/examples/DataflowExamples/GraphRendering/main.cpp +++ b/examples/DataflowExamples/GraphRendering/main.cpp @@ -14,6 +14,13 @@ #include +#ifdef USE_RADIUMGLTF +# include +# include +# include +# include +#endif + // Qt Widgets #include @@ -142,6 +149,12 @@ class DemoWindowFactory : public BaseApplication::WindowFactory inline Ra::Gui::MainWindowInterface* createMainWindow() const override { auto window = new SimpleWindow(); +#ifdef USE_RADIUMGLTF + // register the gltf loader + std::shared_ptr loader = + std::make_shared(); + Ra::Engine::RadiumEngine::getInstance()->registerFileLoader( loader ); +#endif addFileMenu( window ); addRendererMenu( window, m_renderers ); return window; @@ -349,6 +362,12 @@ int main( int argc, char* argv[] ) { app.initialize( DemoWindowFactory( renderers ) ); app.setContinuousUpdate( false ); app.addRadiumMenu(); +#ifdef USE_RADIUMGLTF + app.m_mainWindow->getViewer()->makeCurrent(); + // initialize the use of GLTF library + GLTF::initializeGltf(); + app.m_mainWindow->getViewer()->doneCurrent(); +#endif //! [Initializing the application] return app.exec();