Commit 4e627cc8 authored by Johan Andruejol's avatar Johan Andruejol

Add option to compile without any rendering

The option iMSTK_WITH_RENDERING has been added. It's ON by default.
When turned OFF, VTK is compiled without any of the Rendering OpenGL nor
iMSTK Vulcan and VTK classes.
parent b4e91fb0
......@@ -120,5 +120,6 @@ ExternalProject_Add( ${PROJECT_NAME}
-D${PROJECT_NAME}_USE_Vulkan:BOOL=${${PROJECT_NAME}_USE_Vulkan}
-D${PROJECT_NAME}_ENABLE_AUDIO:BOOL=${${PROJECT_NAME}_ENABLE_AUDIO}
-D${PROJECT_NAME}_ENABLE_VR:BOOL=${${PROJECT_NAME}_ENABLE_VR}
-D${PROJECT_NAME}_WITH_RENDERING:BOOL=${${PROJECT_NAME}_WITH_RENDERING}
DEPENDS ${${PROJECT_NAME}_DEPENDENCIES}
)
......@@ -9,6 +9,12 @@ endif(${${PROJECT_NAME}_ENABLE_VR})
#-----------------------------------------------------------------------------
# Add External Project
#-----------------------------------------------------------------------------
if(${iMSTK_WITH_RENDERING})
set(rendering_backend "OpenGL2")
else()
set(rendering_backend "None")
endif()
include(imstkAddExternalProject)
imstk_add_external_project( VTK
GIT_REPOSITORY https://gitlab.kitware.com/vtk/vtk.git
......@@ -18,19 +24,22 @@ imstk_add_external_project( VTK
-DBUILD_EXAMPLES:BOOL=OFF
-DBUILD_TESTING:BOOL=OFF
-DVTK_Group_StandAlone:BOOL=OFF
-DVTK_Group_Rendering:BOOL=OFF
-DModule_vtkRenderingOpenGL2:BOOL=ON
-DVTK_Group_Rendering:BOOL=${iMSTK_WITH_RENDERING}
-DModule_vtkRenderingOpenGL2:BOOL=${iMSTK_WITH_RENDERING}
-DModule_vtkIOXML:BOOL=ON
-DModule_vtkIOLegacy:BOOL=ON
-DModule_vtkIOPLY:BOOL=ON
-DModule_vtkIOGeometry:BOOL=ON
-DModule_vtkInteractionStyle:BOOL=ON
-DModule_vtkRenderingAnnotation:BOOL=ON
-DModule_vtkRenderingAnnotation:BOOL=${iMSTK_WITH_RENDERING}
-DModule_vtkRenderingOpenVR:BOOL=${${PROJECT_NAME}_ENABLE_VR}
-DModule_vtkInteractionWidgets:BOOL=ON
-DModule_vtkglew:BOOL=ON
-DModule_vtkRenderingContext2D:BOOL=ON
-DVTK_RENDERING_BACKEND:STRING=OpenGL2
-DModule_vtkInteractionWidgets:BOOL=${iMSTK_WITH_RENDERING}
-DModule_vtkglew:BOOL=${iMSTK_WITH_RENDERING}
-DModule_vtkRenderingContext2D:BOOL=${iMSTK_WITH_RENDERING}
-DModule_vtkFiltersCore:BOOL=ON
-DModule_vtkRenderingCore:BOOL=ON
-DModule_vtkImagingCore:BOOL=ON
-DVTK_RENDERING_BACKEND:STRING=${rendering_backend}
-DVTK_WRAP_PYTHON:BOOL=OFF
-DVTK_OPENVR_OBJECT_FACTORY:BOOL=OFF
-DVTK_LEGACY_REMOVE:BOOL=ON
......
......@@ -18,7 +18,8 @@ set(CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/CMake/Utilities
${CMAKE_MODULE_PATH}
)
set(${PROJECT_NAME}_CMAKE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/CMake)
set(${PROJECT_NAME}_CMAKE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/CMake)
include(CMakeDependentOption)
#-----------------------------------------------------------------------------
# Set a default build type if none was specified
......@@ -79,6 +80,7 @@ endif()
# Options
#-----------------------------------------------------------------------------
option(BUILD_EXAMPLES "Build iMSTK examples" ON)
option(${PROJECT_NAME}_WITH_RENDERING "Build ${PROJECT_NAME} with rendering." ON)
#-----------------------------------------------------------------------------
# SUPERBUILD
......@@ -101,17 +103,15 @@ if(${PROJECT_NAME}_SUPERBUILD)
imstk_define_dependency(Uncrustify)
endif()
option(${PROJECT_NAME}_USE_Vulkan "Use the custom Vulkan renderer." OFF)
imstk_define_dependency(glm)
cmake_dependent_option(${PROJECT_NAME}_ENABLE_VR "Allow the usage of VR rendering." OFF "${PROJECT_NAME}_WITH_RENDERING" OFF)
if(${PROJECT_NAME}_USE_Vulkan)
imstk_define_dependency(glfw)
imstk_define_dependency(gli)
endif()
option(${PROJECT_NAME}_ENABLE_VR "Allow the usage of VR rendering." OFF)
cmake_dependent_option(${PROJECT_NAME}_USE_Vulkan "Use the custom Vulkan renderer." OFF "${PROJECT_NAME}_WITH_RENDERING" OFF)
if(${PROJECT_NAME}_ENABLE_VR)
imstk_define_dependency(openvr)
endif()
......@@ -324,6 +324,13 @@ if(BUILD_TESTING)
include_directories(${GoogleMock_INCLUDE_DIRS})
endif()
# Rendering definition
if(${PROJECT_NAME}_WITH_RENDERING)
add_definitions( -DiMSTK_WITH_RENDERING )
else()
remove_definitions( -DiMSTK_WITH_RENDERING )
endif()
# External data
if(BUILD_TESTING OR BUILD_EXAMPLES)
include(imstkExternalData)
......
......@@ -83,6 +83,7 @@ int main()
cam1->setPosition(Vec3d(-5.5, 2.5, 32));
cam1->setFocalPoint(Vec3d(1, 1, 0));
#ifdef iMSTK_WITH_RENDERING
#ifndef iMSTK_USE_Vulkan
auto viewer = sdk->getViewer();
auto screenShotUtility
......@@ -95,6 +96,7 @@ int main()
screenShotUtility->saveScreenShot();
return false;
});
#endif
#endif
std::cout << "PRESS 'b' for taking screenshot" << std::endl;
......
......@@ -85,26 +85,27 @@ set(VULKAN_CPP_FILES
VulkanRenderer/PostProcessing/imstkVulkanPostProcess.cpp
VulkanRenderer/PostProcessing/imstkVulkanPostProcessingChain.cpp)
if( NOT iMSTK_USE_Vulkan )
set(RENDERING_H_FILES ${VTK_H_FILES})
set(RENDERING_CPP_FILES ${VTK_CPP_FILES})
set(RENDERING_SUBDIR
VTKRenderer
VTKRenderer/RenderDelegate)
set(RENDERING_DEPENDENCIES
GUIOverlay)
else()
set(RENDERING_H_FILES ${VULKAN_H_FILES})
set(RENDERING_CPP_FILES ${VULKAN_CPP_FILES})
set(RENDERING_SUBDIR
VulkanRenderer
VulkanRenderer/RenderDelegate
VulkanRenderer/PostProcessing)
set(RENDERING_DEPENDENCIES
${VulkanSDK_LIBRARIES}
glfw
gli
GUIOverlay)
if(${iMSTK_WITH_RENDERING})
if( NOT iMSTK_USE_Vulkan )
set(RENDERING_H_FILES ${VTK_H_FILES})
set(RENDERING_CPP_FILES ${VTK_CPP_FILES})
set(RENDERING_SUBDIR
VTKRenderer
VTKRenderer/RenderDelegate)
set(RENDERING_DEPENDENCIES)
else()
set(RENDERING_H_FILES ${VULKAN_H_FILES})
set(RENDERING_CPP_FILES ${VULKAN_CPP_FILES})
set(RENDERING_SUBDIR
VulkanRenderer
VulkanRenderer/RenderDelegate
VulkanRenderer/PostProcessing)
set(RENDERING_DEPENDENCIES
${VulkanSDK_LIBRARIES}
glfw
gli
)
endif()
endif()
include(imstkAddLibrary)
......@@ -125,6 +126,7 @@ imstk_add_library( Rendering
Scene
Animation
glm
GUIOverlay
#VERBOSE
)
......
......@@ -24,16 +24,18 @@ set(VULKAN_CPP_FILES
VulkanRenderer/imstkVulkanScreenCaptureUtility.cpp
VulkanRenderer/imstkVulkanViewer.cpp)
if( NOT iMSTK_USE_Vulkan )
set(SIMULATIONMANAGER_H_FILES ${VTK_H_FILES})
set(SIMULATIONMANAGER_CPP_FILES ${VTK_CPP_FILES})
set(SIMULATIONMANAGER_SUBDIR
VTKRenderer)
else()
set(SIMULATIONMANAGER_H_FILES ${VULKAN_H_FILES})
set(SIMULATIONMANAGER_CPP_FILES ${VULKAN_CPP_FILES})
set(SIMULATIONMANAGER_SUBDIR
VulkanRenderer)
if(${iMSTK_WITH_RENDERING})
if( NOT iMSTK_USE_Vulkan )
set(SIMULATIONMANAGER_H_FILES ${VTK_H_FILES})
set(SIMULATIONMANAGER_CPP_FILES ${VTK_CPP_FILES})
set(SIMULATIONMANAGER_SUBDIR
VTKRenderer)
else()
set(SIMULATIONMANAGER_H_FILES ${VULKAN_H_FILES})
set(SIMULATIONMANAGER_CPP_FILES ${VULKAN_CPP_FILES})
set(SIMULATIONMANAGER_SUBDIR
VulkanRenderer)
endif()
endif()
include(imstkAddLibrary)
......@@ -60,6 +62,7 @@ imstk_add_library( SimulationManager
Rendering
Devices
Collision
GUIOverlay
)
#-----------------------------------------------------------------------------
......
......@@ -34,6 +34,7 @@ SimulationManager::SimulationManager(const bool disableRendering, const bool ena
if (!disableRendering)
{
#ifdef iMSTK_WITH_RENDERING
#ifdef iMSTK_USE_Vulkan
m_viewer = std::make_shared<VulkanViewer>(this);
#else
......@@ -48,6 +49,7 @@ SimulationManager::SimulationManager(const bool disableRendering, const bool ena
}
m_viewer = std::make_shared<VTKViewer>(this, false);
#endif
#endif
#endif
}
}
......
......@@ -33,11 +33,13 @@
#include "imstkLogUtility.h"
#include "imstkViewer.h"
#ifdef iMSTK_WITH_RENDERING
#ifdef iMSTK_USE_Vulkan
#include "imstkVulkanViewer.h"
#else
#include "imstkVTKViewer.h"
#endif
#endif
namespace imstk
{
......
......@@ -9,6 +9,7 @@ set(iMSTK_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@")
list(INSERT CMAKE_MODULE_PATH 0 "${iMSTK_SOURCE_DIR}/CMake")
# iMSTK settings
set(iMSTK_WITH_RENDERING @iMSTK_WITH_RENDERING)
set(iMSTK_USE_OMNI @iMSTK_USE_OMNI@)
set(iMSTK_USE_Vulkan @iMSTK_USE_Vulkan@)
set(VegaFEM_DIR @VegaFEM_DIR@)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment