Skip to content

Commit 340faa0

Browse files
committed
Fix api change of vsg::FrameStamp::create()
Fix geefr#53
1 parent 20d5349 commit 340faa0

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

vsgvr/include/vsgvr/app/Viewer.h

+9-1
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,15 @@ namespace vsgvr {
106106
/// **must** call releaseFrame() once after rendering, even if this method returns false.
107107
///
108108
/// @return Whether the application should render.
109-
bool advanceToNextFrame();
110109

110+
#if VSG_VERSION_MAJOR >= 1 && VSG_VERSION_MINOR >= 1
111+
/// hint for setting the FrameStamp::simulationTime to time since start_point()
112+
static constexpr double UseTimeSinceStartPoint = std::numeric_limits<double>::max();
113+
114+
bool advanceToNextFrame(double simulationTime = UseTimeSinceStartPoint);
115+
#else
116+
bool advanceToNextFrame();
117+
#endif
111118
/// Submit rendering tasks to Vulkan
112119
void recordAndSubmit();
113120

@@ -167,6 +174,7 @@ namespace vsgvr {
167174
XrFrameState _frameState;
168175
vsg::ref_ptr<vsg::FrameStamp> _frameStamp;
169176
std::vector<XrCompositionLayerBaseHeader*> _layers;
177+
vsg::clock::time_point _start_time_point;
170178
};
171179
}
172180

vsgvr/src/vsgvr/app/Viewer.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ namespace vsgvr
107107
return PollEventsResult::RunningDontRender;
108108
}
109109

110+
#if VSG_VERSION_MAJOR >= 1 && VSG_VERSION_MINOR >= 1
111+
bool Viewer::advanceToNextFrame(double simulationTime)
112+
#else
110113
bool Viewer::advanceToNextFrame()
114+
#endif
111115
{
112116
// Viewer::acquireNextFrame
113117
_frameState = XrFrameState();
@@ -128,12 +132,28 @@ namespace vsgvr
128132
if (!_frameStamp)
129133
{
130134
// first frame, initialize to frame count and indices to 0
135+
#if VSG_VERSION_MAJOR >= 1 && VSG_VERSION_MINOR >= 1
136+
137+
_start_time_point = t;
138+
139+
if (simulationTime == UseTimeSinceStartPoint) simulationTime = 0.0;
140+
_frameStamp = vsg::FrameStamp::create(t, 0, simulationTime);
141+
#else
131142
_frameStamp = vsg::FrameStamp::create(t, 0);
143+
#endif
132144
}
133145
else
134146
{
135147
// after first frame so increment frame count and indices
148+
#if VSG_VERSION_MAJOR >= 1 && VSG_VERSION_MINOR >= 1
149+
if (simulationTime == UseTimeSinceStartPoint)
150+
{
151+
simulationTime = std::chrono::duration<double, std::chrono::seconds::period>(t - _start_time_point).count();
152+
}
153+
_frameStamp = vsg::FrameStamp::create(t, _frameStamp->frameCount + 1, simulationTime);
154+
#else
136155
_frameStamp = vsg::FrameStamp::create(t, _frameStamp->frameCount + 1);
156+
#endif
137157
}
138158

139159
for (auto& layer : compositionLayers)

0 commit comments

Comments
 (0)