aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorraysan5 <raysan5@gmail.com>2015-12-30 13:34:45 +0100
committerraysan5 <raysan5@gmail.com>2015-12-30 13:34:45 +0100
commitb894a78385249c68344cd74d9bc456e962467381 (patch)
tree5ec59bde9cbe6d52e879a11c66ace63b61b62d5e /src
parent3b453369296377826c20a6ed99c89ac052c4044c (diff)
downloadraylib-b894a78385249c68344cd74d9bc456e962467381.tar.gz
raylib-b894a78385249c68344cd74d9bc456e962467381.zip
Reviewed function GetCurrentTime() on WIN32
Diffstat (limited to 'src')
-rw-r--r--src/gestures.c41
1 files changed, 8 insertions, 33 deletions
diff --git a/src/gestures.c b/src/gestures.c
index f5e8c62f..77ea4262 100644
--- a/src/gestures.c
+++ b/src/gestures.c
@@ -35,10 +35,9 @@
#include <stdint.h> // Defines int32_t, int64_t
#if defined(_WIN32)
- //#define WIN32_LEAN_AND_MEAN
- //#include <Windows.h> // ISSUE: Rectangle redeclared, CloseWindow/ShowCursor conflicting types
-int __stdcall QueryPerformanceCounter(unsigned long long int *lpPerformanceCount);
-int __stdcall QueryPerformanceFrequency(unsigned long long int *lpFrequency);
+ // Functions required to query time on Windows
+ int __stdcall QueryPerformanceCounter(unsigned long long int *lpPerformanceCount);
+ int __stdcall QueryPerformanceFrequency(unsigned long long int *lpFrequency);
#elif defined(__linux)
#include <time.h> // Used for clock functions
#endif
@@ -500,38 +499,14 @@ static float VectorDotProduct(Vector2 v1, Vector2 v2)
static double GetCurrentTime()
{
double time = 0;
-#if defined(_WIN32)
-/*
- // NOTE: Requires Windows.h
- FILETIME tm;
- GetSystemTimePreciseAsFileTime(&tm);
- ULONGLONG nowTime = ((ULONGLONG)tm.dwHighDateTime << 32) | (ULONGLONG)tm.dwLowDateTime; // Time provided in 100-nanosecond intervals
-
- time = ((double)nowTime/10000000.0); // time in seconds
-*/
-/*
- double pcFreq = 0.0;
- __int64 counterStart = 0; // In C99 defined a standard 64-bit integer type named int64_t and unsigned version uint64_t in stdint.h.
- //int64_t or uint64_t is type defined as long long or unsigned long long in C99's stdint.h.
+#if defined(_WIN32)
+ unsigned long long int clockFrequency, currentTime;
- //LARGE_INTEGER li; // Represents a 64-bit signed integer value
- //li.QuadPart // A signed 64-bit integer
+ QueryPerformanceFrequency(&clockFrequency);
+ QueryPerformanceCounter(&currentTime);
- unsigned long long int li; // __int64, same as long long
- if(!QueryPerformanceFrequency(&li)) return 0;
-
- pcFreq = (double)(li)/1000.0;
-
- QueryPerformanceCounter(&li);
- counterStart = li;
-
- unsigned long long int tm;
- QueryPerformanceCounter(&tm);
- time = (double)(tm - counterStart)/pcFreq;
-*/
- unsigned long long int tm, tf;
- time = (double)(QueryPerformanceCounter(&tm)/QueryPerformanceFrequency(&tf)); // time in seconds
+ time = (double)currentTime/clockFrequency*1000.0f; // time in miliseconds
#endif
#if defined(__linux)