1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-11 13:10:58 +00:00

UWP: Simplify QueryPerformanceCounter usage

(cherry picked from commit 24fe82da63)
This commit is contained in:
Bartłomiej T. Listwon
2022-01-08 13:10:27 +01:00
committed by Rémi Verschelde
parent e1429dd80f
commit 2f92d5900a

View File

@@ -137,12 +137,8 @@ void OS_UWP::initialize_core() {
NetSocketPosix::make_default();
// We need to know how often the clock is updated
if (!QueryPerformanceFrequency((LARGE_INTEGER *)&ticks_per_second))
ticks_per_second = 1000;
// If timeAtGameStart is 0 then we get the time since
// the start of the computer when we call GetGameTime()
ticks_start = 0;
ticks_start = get_ticks_usec();
QueryPerformanceFrequency((LARGE_INTEGER *)&ticks_per_second);
QueryPerformanceCounter((LARGE_INTEGER *)&ticks_start);
IP_Unix::make_default();
@@ -564,6 +560,9 @@ uint64_t OS_UWP::get_ticks_usec() const {
// This is the number of clock ticks since start
QueryPerformanceCounter((LARGE_INTEGER *)&ticks);
// Subtract the ticks at game start to get
// the ticks since the game started
ticks -= ticks_start;
// Divide by frequency to get the time in seconds
// original calculation shown below is subject to overflow
@@ -583,9 +582,6 @@ uint64_t OS_UWP::get_ticks_usec() const {
// seconds
time += seconds * 1000000L;
// Subtract the time at game start to get
// the time since the game started
time -= ticks_start;
return time;
}