File 0003-Fix-api-change-of-vsg-FrameStamp-create.patch of Package mingw32-vsgvr

From 340faa0c2f0a5fd2c4cb682be88ce12a38658911 Mon Sep 17 00:00:00 2001
From: Ralf Habacker <ralf.habacker@freenet.de>
Date: Wed, 20 Mar 2024 14:03:11 +0100
Subject: [PATCH 3/7] Fix api change of vsg::FrameStamp::create()

Fix #53
---
 vsgvr/include/vsgvr/app/Viewer.h | 10 +++++++++-
 vsgvr/src/vsgvr/app/Viewer.cpp   | 20 ++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/vsgvr/include/vsgvr/app/Viewer.h b/vsgvr/include/vsgvr/app/Viewer.h
index cc6d4a5..ae716a1 100644
--- a/vsgvr/include/vsgvr/app/Viewer.h
+++ b/vsgvr/include/vsgvr/app/Viewer.h
@@ -106,8 +106,15 @@ namespace vsgvr {
             /// **must** call releaseFrame() once after rendering, even if this method returns false.
             ///
             /// @return Whether the application should render.
-            bool advanceToNextFrame();
 
+#if VSG_VERSION_MAJOR >= 1 && VSG_VERSION_MINOR >= 1
+            /// hint for setting the FrameStamp::simulationTime to time since start_point()
+            static constexpr double UseTimeSinceStartPoint = std::numeric_limits<double>::max();
+
+            bool advanceToNextFrame(double simulationTime = UseTimeSinceStartPoint);
+#else
+            bool advanceToNextFrame();
+#endif
             /// Submit rendering tasks to Vulkan
             void recordAndSubmit();
 
@@ -167,6 +174,7 @@ namespace vsgvr {
             XrFrameState _frameState;
             vsg::ref_ptr<vsg::FrameStamp> _frameStamp;
             std::vector<XrCompositionLayerBaseHeader*> _layers;
+            vsg::clock::time_point _start_time_point;
     };
 }
 
diff --git a/vsgvr/src/vsgvr/app/Viewer.cpp b/vsgvr/src/vsgvr/app/Viewer.cpp
index 60390e0..d5ab0c4 100644
--- a/vsgvr/src/vsgvr/app/Viewer.cpp
+++ b/vsgvr/src/vsgvr/app/Viewer.cpp
@@ -107,7 +107,11 @@ namespace vsgvr
     return PollEventsResult::RunningDontRender;
   }
 
+#if VSG_VERSION_MAJOR >= 1 && VSG_VERSION_MINOR >= 1
+  bool Viewer::advanceToNextFrame(double simulationTime)
+#else
   bool Viewer::advanceToNextFrame()
+#endif
   {
     // Viewer::acquireNextFrame
     _frameState = XrFrameState();
@@ -128,12 +132,28 @@ namespace vsgvr
     if (!_frameStamp)
     {
       // first frame, initialize to frame count and indices to 0
+#if VSG_VERSION_MAJOR >= 1 && VSG_VERSION_MINOR >= 1
+
+      _start_time_point = t;
+
+      if (simulationTime == UseTimeSinceStartPoint) simulationTime = 0.0;
+      _frameStamp = vsg::FrameStamp::create(t, 0, simulationTime);
+#else
       _frameStamp = vsg::FrameStamp::create(t, 0);
+#endif
     }
     else
     {
       // after first frame so increment frame count and indices
+#if VSG_VERSION_MAJOR >= 1 && VSG_VERSION_MINOR >= 1
+      if (simulationTime == UseTimeSinceStartPoint)
+      {
+          simulationTime = std::chrono::duration<double, std::chrono::seconds::period>(t - _start_time_point).count();
+      }
+      _frameStamp = vsg::FrameStamp::create(t, _frameStamp->frameCount + 1, simulationTime);
+#else
       _frameStamp = vsg::FrameStamp::create(t, _frameStamp->frameCount + 1);
+#endif
     }
 
     for (auto& layer : compositionLayers)
-- 
2.50.0

openSUSE Build Service is sponsored by