From 2583d8952eb65826e69fbda74ec5bfe15df67a58 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Wed, 16 Nov 2022 11:07:35 +0100 Subject: [PATCH 01/14] Fix static and shared building on Windows --- CMakeLists.txt | 4 ++++ vsgvr/CMakeLists.txt | 8 +++++++- vsgvr/include/vsgvr/actions/OpenXRAction.h | 2 +- vsgvr/include/vsgvr/actions/OpenXRActionPoseBinding.h | 2 +- vsgvr/include/vsgvr/actions/OpenXRActionSet.h | 2 +- vsgvr/include/vsgvr/app/OpenXRViewer.h | 2 +- vsgvr/include/vsgvr/xr/OpenXREventHandler.h | 2 +- vsgvr/include/vsgvr/xr/OpenXRGraphicsBindingVulkan.h | 2 +- vsgvr/include/vsgvr/xr/OpenXRInstance.h | 2 +- vsgvr/include/vsgvr/xr/OpenXRProjectionMatrix.h | 2 +- vsgvr/include/vsgvr/xr/OpenXRSession.h | 2 +- vsgvr/include/vsgvr/xr/OpenXRSwapchain.h | 2 +- vsgvr/include/vsgvr/xr/OpenXRTraits.h | 2 +- vsgvr/include/vsgvr/xr/OpenXRViewMatrix.h | 2 +- 14 files changed, 23 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a68aa6c..1a8fb88 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 3.14) project(VSGVR) +option(BUILD_SHARED_LIBS "Build shared libraries" OFF) + +include(GNUInstallDirs) + include(FetchContent) if( NOT CMAKE_BUILD_TYPE AND NOT MSVC ) diff --git a/vsgvr/CMakeLists.txt b/vsgvr/CMakeLists.txt index 9fbf971..70683cc 100644 --- a/vsgvr/CMakeLists.txt +++ b/vsgvr/CMakeLists.txt @@ -28,7 +28,7 @@ set( SOURCES src/vsgvr/actions/OpenXRActionPoseBinding.cpp ) -add_library( vsgvr STATIC ${SOURCES} ${HEADERS} ) +add_library( vsgvr ${SOURCES} ${HEADERS} ) target_include_directories( vsgvr PRIVATE @@ -36,3 +36,9 @@ target_include_directories( ) target_link_libraries( vsgvr PUBLIC vsg::vsg ) target_link_libraries( vsgvr PUBLIC openxr_loader ) +if(WIN32 AND BUILD_SHARED_LIBS) + target_compile_options(vsgvr PRIVATE "-DVSGVR_DECLSPEC=__declspec(dllexport)") + target_compile_options(vsgvr INTERFACE "-DVSGVR_DECLSPEC=__declspec(dllimport)") +else() + target_compile_options(vsgvr PUBLIC -DVSGVR_DECLSPEC=) +endif() diff --git a/vsgvr/include/vsgvr/actions/OpenXRAction.h b/vsgvr/include/vsgvr/actions/OpenXRAction.h index 4cc18f5..3eb7fd0 100644 --- a/vsgvr/include/vsgvr/actions/OpenXRAction.h +++ b/vsgvr/include/vsgvr/actions/OpenXRAction.h @@ -28,7 +28,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. namespace vsgvr { class OpenXRInstance; class OpenXRActionSet; - class VSG_DECLSPEC OpenXRAction : public vsg::Inherit + class VSGVR_DECLSPEC OpenXRAction : public vsg::Inherit { public: OpenXRAction(OpenXRActionSet* actionSet, XrActionType actionType, std::string name, std::string localisedName ); diff --git a/vsgvr/include/vsgvr/actions/OpenXRActionPoseBinding.h b/vsgvr/include/vsgvr/actions/OpenXRActionPoseBinding.h index 50aaac1..8fbc87e 100644 --- a/vsgvr/include/vsgvr/actions/OpenXRActionPoseBinding.h +++ b/vsgvr/include/vsgvr/actions/OpenXRActionPoseBinding.h @@ -33,7 +33,7 @@ namespace vsgvr { * An action of type XR_INPUT_ACTION_TYPE_POSE, and an associated action space * The space will only be valid while a session is running */ - class VSG_DECLSPEC OpenXRActionPoseBinding : public vsg::Inherit + class VSGVR_DECLSPEC OpenXRActionPoseBinding : public vsg::Inherit { public: OpenXRActionPoseBinding(OpenXRActionSet* actionSet, std::string name, std::string localisedName); diff --git a/vsgvr/include/vsgvr/actions/OpenXRActionSet.h b/vsgvr/include/vsgvr/actions/OpenXRActionSet.h index b2f4556..2ae6dfb 100644 --- a/vsgvr/include/vsgvr/actions/OpenXRActionSet.h +++ b/vsgvr/include/vsgvr/actions/OpenXRActionSet.h @@ -27,7 +27,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. namespace vsgvr { class OpenXRInstance; - class VSG_DECLSPEC OpenXRActionSet : public vsg::Inherit + class VSGVR_DECLSPEC OpenXRActionSet : public vsg::Inherit { public: OpenXRActionSet(OpenXRInstance* instance, std::string name, std::string localisedName, uint32_t priority = 0); diff --git a/vsgvr/include/vsgvr/app/OpenXRViewer.h b/vsgvr/include/vsgvr/app/OpenXRViewer.h index 2e7581f..2766052 100644 --- a/vsgvr/include/vsgvr/app/OpenXRViewer.h +++ b/vsgvr/include/vsgvr/app/OpenXRViewer.h @@ -51,7 +51,7 @@ namespace vsgvr { * * Any elements in vsg which require a vsg::Window cannot work with this viewer (TODO) * * While some functions are similar, this class does not directly inherit from vsg::Viewer (TODO) */ - class VSG_DECLSPEC OpenXRViewer : public vsg::Inherit + class VSGVR_DECLSPEC OpenXRViewer : public vsg::Inherit { public: /** diff --git a/vsgvr/include/vsgvr/xr/OpenXREventHandler.h b/vsgvr/include/vsgvr/xr/OpenXREventHandler.h index 90aa8cb..a7db518 100644 --- a/vsgvr/include/vsgvr/xr/OpenXREventHandler.h +++ b/vsgvr/include/vsgvr/xr/OpenXREventHandler.h @@ -29,7 +29,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. namespace vsgvr { class OpenXRInstance; class OpenXRSession; - class VSG_DECLSPEC OpenXREventHandler : public vsg::Inherit + class VSGVR_DECLSPEC OpenXREventHandler : public vsg::Inherit { public: OpenXREventHandler(); diff --git a/vsgvr/include/vsgvr/xr/OpenXRGraphicsBindingVulkan.h b/vsgvr/include/vsgvr/xr/OpenXRGraphicsBindingVulkan.h index 05ea449..84859e9 100644 --- a/vsgvr/include/vsgvr/xr/OpenXRGraphicsBindingVulkan.h +++ b/vsgvr/include/vsgvr/xr/OpenXRGraphicsBindingVulkan.h @@ -49,7 +49,7 @@ namespace vsgvr { VkPhysicalDevice* physicalDevice; }; - class VSG_DECLSPEC OpenXRGraphicsBindingVulkan : public vsg::Inherit + class VSGVR_DECLSPEC OpenXRGraphicsBindingVulkan : public vsg::Inherit { public: static VulkanRequirements getVulkanRequirements(vsg::ref_ptr xrInstance); diff --git a/vsgvr/include/vsgvr/xr/OpenXRInstance.h b/vsgvr/include/vsgvr/xr/OpenXRInstance.h index 8ba05fe..b93c122 100644 --- a/vsgvr/include/vsgvr/xr/OpenXRInstance.h +++ b/vsgvr/include/vsgvr/xr/OpenXRInstance.h @@ -29,7 +29,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include namespace vsgvr { - class VSG_DECLSPEC OpenXRInstance : public vsg::Inherit + class VSGVR_DECLSPEC OpenXRInstance : public vsg::Inherit { public: OpenXRInstance() = delete; diff --git a/vsgvr/include/vsgvr/xr/OpenXRProjectionMatrix.h b/vsgvr/include/vsgvr/xr/OpenXRProjectionMatrix.h index 37f2397..25eb825 100644 --- a/vsgvr/include/vsgvr/xr/OpenXRProjectionMatrix.h +++ b/vsgvr/include/vsgvr/xr/OpenXRProjectionMatrix.h @@ -32,7 +32,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. namespace vsgvr { - class VSG_DECLSPEC OpenXRProjectionMatrix : public vsg::Inherit + class VSGVR_DECLSPEC OpenXRProjectionMatrix : public vsg::Inherit { public: OpenXRProjectionMatrix(vsg::dmat4 matrix) diff --git a/vsgvr/include/vsgvr/xr/OpenXRSession.h b/vsgvr/include/vsgvr/xr/OpenXRSession.h index 4205a05..e41cd4f 100644 --- a/vsgvr/include/vsgvr/xr/OpenXRSession.h +++ b/vsgvr/include/vsgvr/xr/OpenXRSession.h @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include namespace vsgvr { - class VSG_DECLSPEC OpenXRSession : public vsg::Inherit + class VSGVR_DECLSPEC OpenXRSession : public vsg::Inherit { public: OpenXRSession() = delete; diff --git a/vsgvr/include/vsgvr/xr/OpenXRSwapchain.h b/vsgvr/include/vsgvr/xr/OpenXRSwapchain.h index b34794d..4d3cea9 100644 --- a/vsgvr/include/vsgvr/xr/OpenXRSwapchain.h +++ b/vsgvr/include/vsgvr/xr/OpenXRSwapchain.h @@ -38,7 +38,7 @@ namespace vsgvr virtual ~SwapchainImage(); }; - class VSG_DECLSPEC OpenXRSwapchain : public vsg::Inherit + class VSGVR_DECLSPEC OpenXRSwapchain : public vsg::Inherit { public: OpenXRSwapchain() = delete; diff --git a/vsgvr/include/vsgvr/xr/OpenXRTraits.h b/vsgvr/include/vsgvr/xr/OpenXRTraits.h index c762dd5..c008568 100644 --- a/vsgvr/include/vsgvr/xr/OpenXRTraits.h +++ b/vsgvr/include/vsgvr/xr/OpenXRTraits.h @@ -27,7 +27,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include namespace vsgvr { - class OpenXrTraits { + class VSGVR_DECLSPEC OpenXrTraits { public: OpenXrTraits(); std::vector xrExtensions = { diff --git a/vsgvr/include/vsgvr/xr/OpenXRViewMatrix.h b/vsgvr/include/vsgvr/xr/OpenXRViewMatrix.h index 43f2095..7882d25 100644 --- a/vsgvr/include/vsgvr/xr/OpenXRViewMatrix.h +++ b/vsgvr/include/vsgvr/xr/OpenXRViewMatrix.h @@ -30,7 +30,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include namespace vsgvr { - class VSG_DECLSPEC OpenXRViewMatrix : public vsg::Inherit + class VSGVR_DECLSPEC OpenXRViewMatrix : public vsg::Inherit { public: OpenXRViewMatrix(const vsg::dmat4& m) : From 0b39b8670c2324a7b8d01ae68e004281c7513545 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Wed, 16 Nov 2022 11:04:09 +0100 Subject: [PATCH 02/14] Use cmake related install settings from vsg By using vsg_setup_xxx macros basic support for install location and build related settings are available to match other vsg related packages. --- CMakeLists.txt | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a8fb88..418c42b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,18 +1,13 @@ cmake_minimum_required(VERSION 3.14) -project(VSGVR) - -option(BUILD_SHARED_LIBS "Build shared libraries" OFF) - -include(GNUInstallDirs) +project(vsgvr + VERSION 0.4.0 + DESCRIPTION "VulkanSceneGraph based virtual reality viewer" + LANGUAGES CXX +) include(FetchContent) -if( NOT CMAKE_BUILD_TYPE AND NOT MSVC ) - set( CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE ) - set_property( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Release" "Debug" "MinSizeRel" "RelWithDebInfo" ) -endif() - # Compiler/Tool requirements set( CMAKE_CXX_STANDARD 17 ) set(OpenGL_GL_PREFERENCE GLVND) @@ -21,6 +16,11 @@ set(OpenGL_GL_PREFERENCE GLVND) find_package(vsg 1.0.0 NO_CMAKE_FIND_ROOT_PATH) find_package(Vulkan REQUIRED) +vsg_setup_dir_vars() +vsg_setup_build_vars() +vsg_add_target_clobber() +vsg_add_target_uninstall() + add_subdirectory( deps/openxr ) add_subdirectory( vsgvr ) From 4fbd0cfced29fc81a5aa39de5a19688efe472502 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Wed, 16 Nov 2022 10:42:05 +0100 Subject: [PATCH 03/14] Add support to find installed vsgvr data files To find data files when vsgvr is packaged by a distribution, the search is extended to the vsgvr data install location, which is relative based on the path of the executable and determined by the cmake buildsystem. This is required to support a portable installation, such as those found on Windows. In order for the executable to find the required data files when running from the build directory, the location of the data files in the build directory directory has been adjusted. --- CMakeLists.txt | 10 +++++++--- example_vr.cpp | 8 ++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 418c42b..ea80fd7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,10 @@ add_subdirectory( deps/openxr ) add_subdirectory( vsgvr ) +# setup relative data install path +file(RELATIVE_PATH VSGVR_REL_DATADIR ${CMAKE_INSTALL_FULL_BINDIR} ${CMAKE_INSTALL_FULL_DATADIR}/vsgvr) +add_definitions(-DVSGVR_REL_DATADIR=\"${VSGVR_REL_DATADIR}\") + add_executable( example_vr example_vr.cpp ) target_link_libraries( example_vr vsg::vsg vsgvr ) target_include_directories( example_vr PRIVATE @@ -32,6 +36,6 @@ target_include_directories( example_vr PRIVATE vsgvr/include ) # Copy models into the build dir -configure_file(models/world/world.vsgt ${CMAKE_CURRENT_BINARY_DIR}/world.vsgt COPYONLY) -configure_file(models/controller/controller.vsgt ${CMAKE_CURRENT_BINARY_DIR}/controller.vsgt COPYONLY) -configure_file(models/controller/controller2.vsgt ${CMAKE_CURRENT_BINARY_DIR}/controller2.vsgt COPYONLY) +configure_file(models/world/world.vsgt ${CMAKE_CURRENT_BINARY_DIR}/share/vsgvr/world.vsgt COPYONLY) +configure_file(models/controller/controller.vsgt ${CMAKE_CURRENT_BINARY_DIR}/share/vsgvr/controller.vsgt COPYONLY) +configure_file(models/controller/controller2.vsgt ${CMAKE_CURRENT_BINARY_DIR}/share/vsgvr/controller2.vsgt COPYONLY) diff --git a/example_vr.cpp b/example_vr.cpp index 394188c..e38cc30 100644 --- a/example_vr.cpp +++ b/example_vr.cpp @@ -21,6 +21,10 @@ int main(int argc, char **argv) { auto options = vsg::Options::create(); arguments.read(options); + // add relative data path based on binary dir + vsg::Path dataPath = vsg::filePath(vsg::executableFilePath()); + dataPath.append(VSGVR_REL_DATADIR); + options->paths.push_back(dataPath); vsg::Path filename = "world.vsgt"; if (argc > 1) filename = arguments[1]; @@ -34,11 +38,11 @@ int main(int argc, char **argv) { return 0; auto controllerNodeLeft = vsg::MatrixTransform::create(); - controllerNodeLeft->addChild(vsg::read_cast("controller.vsgt")); + controllerNodeLeft->addChild(vsg::read_cast("controller.vsgt", options)); vsg_scene->addChild(controllerNodeLeft); auto controllerNodeRight = vsg::MatrixTransform::create(); - controllerNodeRight->addChild(vsg::read_cast("controller2.vsgt")); + controllerNodeRight->addChild(vsg::read_cast("controller2.vsgt", options)); vsg_scene->addChild(controllerNodeRight); // Initialise OpenXR From 3ab8a260d5ceaee507d7a96469fcf9eef5606ee9 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Wed, 16 Nov 2022 10:42:49 +0100 Subject: [PATCH 04/14] Add support to install binaries and files This is required for packaging. --- CMakeLists.txt | 9 +++++++++ vsgvr/CMakeLists.txt | 7 +++++++ vsgvr/vsgvrConfig.cmake.in | 5 +++++ 3 files changed, 21 insertions(+) create mode 100644 vsgvr/vsgvrConfig.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index ea80fd7..8acfae1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,16 @@ target_include_directories( example_vr PRIVATE ${OPENVR_ROOT}/headers vsgvr/include ) +install(TARGETS example_vr) + # Copy models into the build dir configure_file(models/world/world.vsgt ${CMAKE_CURRENT_BINARY_DIR}/share/vsgvr/world.vsgt COPYONLY) configure_file(models/controller/controller.vsgt ${CMAKE_CURRENT_BINARY_DIR}/share/vsgvr/controller.vsgt COPYONLY) configure_file(models/controller/controller2.vsgt ${CMAKE_CURRENT_BINARY_DIR}/share/vsgvr/controller2.vsgt COPYONLY) + +install(FILES + models/world/world.vsgt + models/controller/controller.vsgt + models/controller/controller2.vsgt + DESTINATION ${CMAKE_INSTALL_DATADIR}/vsgvr +) diff --git a/vsgvr/CMakeLists.txt b/vsgvr/CMakeLists.txt index 70683cc..956d3e0 100644 --- a/vsgvr/CMakeLists.txt +++ b/vsgvr/CMakeLists.txt @@ -42,3 +42,10 @@ if(WIN32 AND BUILD_SHARED_LIBS) else() target_compile_options(vsgvr PUBLIC -DVSGVR_DECLSPEC=) endif() + +install(TARGETS vsgvr ${INSTALL_TARGETS_DEFAULT_FLAGS}) +install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/vsgvr) + +vsg_add_cmake_support_files( + CONFIG_TEMPLATE vsgvrConfig.cmake.in +) diff --git a/vsgvr/vsgvrConfig.cmake.in b/vsgvr/vsgvrConfig.cmake.in new file mode 100644 index 0000000..cfe3971 --- /dev/null +++ b/vsgvr/vsgvrConfig.cmake.in @@ -0,0 +1,5 @@ +include(CMakeFindDependencyMacro) + +@FIND_DEPENDENCY_OUT@ + +include("${CMAKE_CURRENT_LIST_DIR}/vsgvrTargets.cmake") From f68cd86f0025b3a88f156159e118d0beeccfbeca Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Wed, 16 Nov 2022 13:43:01 +0100 Subject: [PATCH 05/14] Install versioned vsgvr library In case the vsgvr is build as shared library it needs to be versioned, which is a requirement for example on openSUSE distributions. --- CMakeLists.txt | 2 ++ vsgvr/CMakeLists.txt | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8acfae1..009dc7a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,8 @@ project(vsgvr LANGUAGES CXX ) +set(VSGVR_SOVERSION 0) + include(FetchContent) # Compiler/Tool requirements diff --git a/vsgvr/CMakeLists.txt b/vsgvr/CMakeLists.txt index 956d3e0..64f78f0 100644 --- a/vsgvr/CMakeLists.txt +++ b/vsgvr/CMakeLists.txt @@ -42,6 +42,15 @@ if(WIN32 AND BUILD_SHARED_LIBS) else() target_compile_options(vsgvr PUBLIC -DVSGVR_DECLSPEC=) endif() +set_target_properties(vsgvr PROPERTIES + VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} + SOVERSION ${VSGVR_SOVERSION} +) +if(WIN32) + set_target_properties(vsgvr PROPERTIES + RUNTIME_OUTPUT_NAME vsgvr-${VSGVR_SOVERSION} + ) +endif() install(TARGETS vsgvr ${INSTALL_TARGETS_DEFAULT_FLAGS}) install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/vsgvr) From bab6bb122dc1465502553c9d51b71ab9e87fd898 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 22 Nov 2022 12:34:15 +0100 Subject: [PATCH 06/14] Add support to use OpenXR sdk from distribution This is required for packaging. --- CMakeLists.txt | 11 ++++++++++- vsgvr/CMakeLists.txt | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 009dc7a..819fcfc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,16 @@ vsg_setup_build_vars() vsg_add_target_clobber() vsg_add_target_uninstall() -add_subdirectory( deps/openxr ) +find_package(OpenXR QUIET) +if(OpenXR_FOUND) + set(OpenXR_LIBRARY OpenXR::openxr_loader) +elseif(IS_DIRECTORY deps/openxr) + message(STATUS "Using embedded OpenXR development kit") + add_subdirectory(deps/openxr) + set(OpenXR_LIBRARY openxr_loader) +else() + message(FATAL_ERROR "Could not find OpenXR development kit") +endif() add_subdirectory( vsgvr ) diff --git a/vsgvr/CMakeLists.txt b/vsgvr/CMakeLists.txt index 64f78f0..822c938 100644 --- a/vsgvr/CMakeLists.txt +++ b/vsgvr/CMakeLists.txt @@ -35,7 +35,7 @@ target_include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/include ) target_link_libraries( vsgvr PUBLIC vsg::vsg ) -target_link_libraries( vsgvr PUBLIC openxr_loader ) +target_link_libraries( vsgvr PUBLIC ${OpenXR_LIBRARY}) if(WIN32 AND BUILD_SHARED_LIBS) target_compile_options(vsgvr PRIVATE "-DVSGVR_DECLSPEC=__declspec(dllexport)") target_compile_options(vsgvr INTERFACE "-DVSGVR_DECLSPEC=__declspec(dllimport)") From e2ba5eb6ce61fa9e89869461490415de36213ea5 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 22 Nov 2022 13:11:20 +0100 Subject: [PATCH 07/14] Fix finding include headers --- vsgvr/CMakeLists.txt | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/vsgvr/CMakeLists.txt b/vsgvr/CMakeLists.txt index 822c938..83fe2a0 100644 --- a/vsgvr/CMakeLists.txt +++ b/vsgvr/CMakeLists.txt @@ -1,31 +1,17 @@ -file(GLOB HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/vsgvr/*.h ) +file(GLOB HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/vsgvr/*/*.h ) set( SOURCES - include/vsgvr/xr/OpenXRCommon.h - include/vsgvr/xr/OpenXRInstance.h - src/vsgvr/xr/OpenXRInstance.cpp - include/vsgvr/xr/OpenXREventHandler.h - src/vsgvr/xr/OpenXREventHandler.cpp - include/vsgvr/xr/OpenXRTraits.h - src/vsgvr/xr/OpenXRTraits.cpp - include/vsgvr/app/OpenXRViewer.h + src/vsgvr/actions/OpenXRAction.cpp + src/vsgvr/actions/OpenXRActionPoseBinding.cpp + src/vsgvr/actions/OpenXRActionSet.cpp src/vsgvr/app/OpenXRViewer.cpp - include/vsgvr/xr/OpenXRGraphicsBindingVulkan.h + src/vsgvr/xr/OpenXREventHandler.cpp src/vsgvr/xr/OpenXRGraphicsBindingVulkan.cpp - include/vsgvr/xr/OpenXRSession.h + src/vsgvr/xr/OpenXRInstance.cpp src/vsgvr/xr/OpenXRSession.cpp - include/vsgvr/xr/OpenXRSwapchain.h src/vsgvr/xr/OpenXRSwapchain.cpp - include/vsgvr/xr/OpenXRViewMatrix.h - include/vsgvr/xr/OpenXRProjectionMatrix.h - - include/vsgvr/actions/OpenXRAction.h - src/vsgvr/actions/OpenXRAction.cpp - include/vsgvr/actions/OpenXRActionSet.h - src/vsgvr/actions/OpenXRActionSet.cpp - include/vsgvr/actions/OpenXRActionPoseBinding.h - src/vsgvr/actions/OpenXRActionPoseBinding.cpp + src/vsgvr/xr/OpenXRTraits.cpp ) add_library( vsgvr ${SOURCES} ${HEADERS} ) From 3194d821af2a8ac52b4ae4aa33fdb13be7f2f2ee Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 22 Nov 2022 10:37:15 +0100 Subject: [PATCH 08/14] Fix possible crash in OpenXRActionPoseBinding::destroyActionSpace() In case _space is 0, the application will crash. --- vsgvr/src/vsgvr/actions/OpenXRActionPoseBinding.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vsgvr/src/vsgvr/actions/OpenXRActionPoseBinding.cpp b/vsgvr/src/vsgvr/actions/OpenXRActionPoseBinding.cpp index 4e3b62e..83e8375 100644 --- a/vsgvr/src/vsgvr/actions/OpenXRActionPoseBinding.cpp +++ b/vsgvr/src/vsgvr/actions/OpenXRActionPoseBinding.cpp @@ -61,8 +61,10 @@ namespace vsgvr void OpenXRActionPoseBinding::destroyActionSpace() { - xr_check(xrDestroySpace(_space)); - _space = 0; + if (_space) { + xr_check(xrDestroySpace(_space)); + _space = nullptr; + } } void OpenXRActionPoseBinding::setSpaceLocation(XrSpaceLocation location) From 24a51fe1bf28affd956bf8d6aa4259739265feda Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Thu, 13 Oct 2022 11:31:29 +0200 Subject: [PATCH 09/14] =?UTF-8?q?Fix=20build=20error=20with=20gcc=207.5:?= =?UTF-8?q?=20=E2=80=98cerr|cout=E2=80=99=20is=20not=20a=20member=20of=20?= =?UTF-8?q?=E2=80=98std=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example_vr.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/example_vr.cpp b/example_vr.cpp index e38cc30..28af502 100644 --- a/example_vr.cpp +++ b/example_vr.cpp @@ -10,6 +10,8 @@ #include #include +#include + int main(int argc, char **argv) { try { From a3a422bdc7a787f8e4d0bf9dd73fe49de720bcf0 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 22 Nov 2022 16:15:01 +0100 Subject: [PATCH 10/14] Fix build error: cannot convert 'std::nullptr_t' to 'XrSpace' {aka 'long long unsigned int'} in assignment This happened with mingw gcc12. --- vsgvr/src/vsgvr/actions/OpenXRActionPoseBinding.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vsgvr/src/vsgvr/actions/OpenXRActionPoseBinding.cpp b/vsgvr/src/vsgvr/actions/OpenXRActionPoseBinding.cpp index 83e8375..510bd24 100644 --- a/vsgvr/src/vsgvr/actions/OpenXRActionPoseBinding.cpp +++ b/vsgvr/src/vsgvr/actions/OpenXRActionPoseBinding.cpp @@ -63,7 +63,7 @@ namespace vsgvr { if (_space) { xr_check(xrDestroySpace(_space)); - _space = nullptr; + _space = 0; } } From d87901623d1cbe3bf95dbe751fffedbbf800c2cf Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Wed, 16 Nov 2022 11:08:16 +0100 Subject: [PATCH 11/14] Cleanup displaying errors and exit code --- example_vr.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/example_vr.cpp b/example_vr.cpp index 28af502..cf3f2e4 100644 --- a/example_vr.cpp +++ b/example_vr.cpp @@ -36,8 +36,10 @@ int main(int argc, char **argv) { // load the scene graph vsg::ref_ptr vsg_scene = vsg::read_cast(filename, options); - if (!vsg_scene) - return 0; + if (!vsg_scene) { + std::cerr << "Could not read the scene graph" << std::endl; + return EXIT_FAILURE; + } auto controllerNodeLeft = vsg::MatrixTransform::create(); controllerNodeLeft->addChild(vsg::read_cast("controller.vsgt", options)); @@ -286,7 +288,7 @@ int main(int argc, char **argv) { } catch( const vsg::Exception& e ) { - std::cout << "VSG Exception: " << e.message << std::endl; + std::cerr << "VSG Exception: " << e.message << std::endl; return EXIT_FAILURE; } } From abcd56804764e942d0e87ff9f7a363366c12706d Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Wed, 23 Nov 2022 08:42:43 +0100 Subject: [PATCH 12/14] Use additional cmake related macros from vsg This adds cmake target like 'cppcheck' for static code analysis, 'clang-format' for code formatting, 'clobber' to clean git sources, 'docs' for generating api documentation. --- CMakeLists.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 819fcfc..e79827b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,22 @@ find_package(Vulkan REQUIRED) vsg_setup_dir_vars() vsg_setup_build_vars() + +vsg_add_target_clang_format( + FILES + ${PROJECT_SOURCE_DIR}/vsgvr/include/vsgvr/*.h + ${PROJECT_SOURCE_DIR}/vsgvr/srv/vsgvr/*.cpp +) +vsg_add_target_cppcheck( + FILES + ${PROJECT_SOURCE_DIR}/vsgvr/include/vsgvr/*.h + ${PROJECT_SOURCE_DIR}/vsgvr/srv/vsgvr/*.cpp +) vsg_add_target_clobber() +vsg_add_target_docs( + FILES + ${PROJECT_SOURCE_DIR}/vsgvr/include +) vsg_add_target_uninstall() find_package(OpenXR QUIET) From 88249b83ccb4e84dfa108b469681400fe760f3f2 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 22 Nov 2022 12:34:27 +0100 Subject: [PATCH 13/14] Use vsg provided macro vsg_add_feature_summary() --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e79827b..cced4bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,3 +74,5 @@ install(FILES models/controller/controller2.vsgt DESTINATION ${CMAKE_INSTALL_DATADIR}/vsgvr ) + +vsg_add_feature_summary() From df42a72307aee1260525d759d4507de07e5e7ced Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 22 Nov 2022 12:50:41 +0100 Subject: [PATCH 14/14] Create and install executable as `vsgopenxrvrviewer' in order to use a consistent name The target name is currently not changed to avoid collisions with further restructuring. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cced4bb..5b0af0a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,7 +60,7 @@ target_link_libraries( example_vr vsg::vsg vsgvr ) target_include_directories( example_vr PRIVATE ${OPENVR_ROOT}/headers vsgvr/include ) - +set_target_properties(example_vr PROPERTIES OUTPUT_NAME vsgopenxrviewer) install(TARGETS example_vr) # Copy models into the build dir