mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
Make getTime() relative to first invocation
This commit is contained in:
@@ -123,7 +123,7 @@ double Timer::getTimerPeriod()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Timer::getTime()
|
double Timer::getTimeAbsolute()
|
||||||
{
|
{
|
||||||
// The timer period (reciprocal of the frequency.)
|
// The timer period (reciprocal of the frequency.)
|
||||||
static const double timerPeriod = getTimerPeriod();
|
static const double timerPeriod = getTimerPeriod();
|
||||||
@@ -156,5 +156,11 @@ double Timer::getTime()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double Timer::getTime()
|
||||||
|
{
|
||||||
|
static const double start = getTimeAbsolute();
|
||||||
|
return getTimeAbsolute() - start;
|
||||||
|
}
|
||||||
|
|
||||||
} // timer
|
} // timer
|
||||||
} // love
|
} // love
|
||||||
|
|||||||
@@ -72,9 +72,10 @@ public:
|
|||||||
double getAverageDelta() const;
|
double getAverageDelta() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the amount of time passed since an unspecified time. Useful for
|
* Gets the amount of time in seconds passed since its first invocation
|
||||||
* profiling code or measuring intervals. The time is microsecond-precise,
|
* (which happens as part of Timer::step at the start of love.run).
|
||||||
* and increases monotonically.
|
* Useful for profiling code or measuring intervals.
|
||||||
|
* The time is microsecond-precise, and increases monotonically.
|
||||||
* @return The time (in seconds)
|
* @return The time (in seconds)
|
||||||
**/
|
**/
|
||||||
static double getTime();
|
static double getTime();
|
||||||
@@ -102,6 +103,9 @@ private:
|
|||||||
// Returns the timer period on some platforms.
|
// Returns the timer period on some platforms.
|
||||||
static double getTimerPeriod();
|
static double getTimerPeriod();
|
||||||
|
|
||||||
|
// Like getTime, but relative to an unspecified time.
|
||||||
|
static double getTimeAbsolute();
|
||||||
|
|
||||||
}; // Timer
|
}; // Timer
|
||||||
|
|
||||||
} // timer
|
} // timer
|
||||||
|
|||||||
Reference in New Issue
Block a user