mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-02-23 03:41:03 +00:00
- avoid killing timer precision when there's no time scale active.
# Conflicts: # src/i_time.cpp
This commit is contained in:
parent
13f4636387
commit
5828cad68d
2 changed files with 17 additions and 1 deletions
|
@ -75,7 +75,8 @@ CUSTOM_CVAR(Float, i_timescale, 1.0f, CVAR_NOINITCALL)
|
|||
static uint64_t GetClockTimeNS()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
return (uint64_t)((duration_cast<microseconds>(steady_clock::now().time_since_epoch()).count()) * (uint64_t)(TimeScale * 1000));
|
||||
if (TimeScale == 1.0) return (uint64_t)(duration_cast<nanoseconds>(steady_clock::now().time_since_epoch()).count());
|
||||
else return (uint64_t)((duration_cast<microseconds>(steady_clock::now().time_since_epoch()).count()) * (uint64_t)(TimeScale * 1000));
|
||||
}
|
||||
|
||||
static uint64_t MSToNS(unsigned int ms)
|
||||
|
@ -164,11 +165,21 @@ uint64_t I_msTime()
|
|||
return NSToMS(I_nsTime());
|
||||
}
|
||||
|
||||
double I_msTimeF(void)
|
||||
{
|
||||
return I_nsTime() / 1'000'000.;
|
||||
}
|
||||
|
||||
uint64_t I_msTimeFS() // from "start"
|
||||
{
|
||||
return (FirstFrameStartTime == 0) ? 0 : NSToMS(I_nsTime() - FirstFrameStartTime);
|
||||
}
|
||||
|
||||
uint64_t I_GetTimeNS()
|
||||
{
|
||||
return CurrentFrameStartTime - FirstFrameStartTime;
|
||||
}
|
||||
|
||||
int I_GetTime()
|
||||
{
|
||||
return NSToTic(CurrentFrameStartTime - FirstFrameStartTime);
|
||||
|
|
|
@ -7,6 +7,8 @@ void I_SetFrameTime();
|
|||
|
||||
// Called by D_DoomLoop, returns current time in tics.
|
||||
int I_GetTime();
|
||||
// same, but using nanoseconds
|
||||
uint64_t I_GetTimeNS();
|
||||
|
||||
double I_GetTimeFrac();
|
||||
|
||||
|
@ -22,6 +24,9 @@ void I_FreezeTime(bool frozen);
|
|||
// [RH] Returns millisecond-accurate time
|
||||
uint64_t I_msTime();
|
||||
|
||||
// [RH] Returns nanosecond-accurate time in milliseconds
|
||||
double I_msTimeF(void);
|
||||
|
||||
// [SP] Returns millisecond-accurate time from start
|
||||
uint64_t I_msTimeFS();
|
||||
|
||||
|
|
Loading…
Reference in a new issue