Skip to content

Commit

Permalink
[examples] add support for libGLTF for graph-base rendering exemple
Browse files Browse the repository at this point in the history
  • Loading branch information
MathiasPaulin committed Mar 21, 2023
1 parent b27d088 commit ddd1f8e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
15 changes: 15 additions & 0 deletions examples/DataflowExamples/GraphRendering/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
19 changes: 19 additions & 0 deletions examples/DataflowExamples/GraphRendering/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@

#include <Dataflow/QtGui/GraphEditor/GraphEditorWindow.hpp>

#ifdef USE_RADIUMGLTF
# include <Engine/Scene/SystemDisplay.hpp>
# include <IO/Gltf/Loader/glTFFileLoader.hpp>
# include <IO/Gltf/Writer/glTFFileWriter.hpp>
# include <glTFLibrary.hpp>
#endif

// Qt Widgets
#include <QtWidgets>

Expand Down Expand Up @@ -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<Ra::Core::Asset::FileLoaderInterface> loader =
std::make_shared<GLTF::glTFFileLoader>();
Ra::Engine::RadiumEngine::getInstance()->registerFileLoader( loader );
#endif
addFileMenu( window );
addRendererMenu( window, m_renderers );
return window;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit ddd1f8e

Please sign in to comment.