aboutsummaryrefslogtreecommitdiff
path: root/visualization
diff options
context:
space:
mode:
Diffstat (limited to 'visualization')
-rw-r--r--visualization/qmpvisualization.cpp14
-rw-r--r--visualization/qmpvisualization.hpp1
2 files changed, 14 insertions, 1 deletions
diff --git a/visualization/qmpvisualization.cpp b/visualization/qmpvisualization.cpp
index 3dc0324..207b8cd 100644
--- a/visualization/qmpvisualization.cpp
+++ b/visualization/qmpvisualization.cpp
@@ -245,6 +245,7 @@ void qmpVisualization::reset()
delete pool[i];
pool.clear();
elb = ctk = lstk = cfr = 0;
+ roffset = 0;
tspool.clear();
cts = 0x0402;
cks = 0;
@@ -909,7 +910,7 @@ bool qmpVisualization::update()
{
if (rendermode)
{
- ctk = 1e6 * (cfr) / tfps / ctp * api->getDivision() + lstk;
+ ctk = 1e6 * cfr / tfps / ctp * api->getDivision() + lstk;
++cfr;
}
else
@@ -981,11 +982,22 @@ bool qmpVisualization::update()
}
if (~ltpc && ctp != pool[ltpc]->key)
{
+ uint32_t oldtp = ctp;
ctp = pool[ltpc]->key;
if (rendermode)
{
+ if (ctk > pool[ltpc]->tcs)
+ {
+ double oldtpft = (double)(ctk - pool[ltpc]->tcs) * (oldtp / 1e6 / api->getDivision());
+ roffset += oldtpft;
+ }
lstk = pool[ltpc]->tcs;
cfr = 1;
+ while (roffset > 1. / tfps) //usually only run once
+ {
+ ++ cfr;
+ roffset -= 1. / tfps;
+ }
}
}
int t, r;
diff --git a/visualization/qmpvisualization.hpp b/visualization/qmpvisualization.hpp
index c0bc067..c53f548 100644
--- a/visualization/qmpvisualization.hpp
+++ b/visualization/qmpvisualization.hpp
@@ -42,6 +42,7 @@ private:
uint32_t rpnid[16], rpnval[16];
std::chrono::steady_clock::time_point lst;
double etps;
+ double roffset;
bool shouldclose, playing, debug;
bool rendermode, hidewindow;
int herh, heh, hfrf;