summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRay <[email protected]>2017-03-28 19:15:27 +0200
committerRay <[email protected]>2017-03-28 19:15:27 +0200
commitb5dd18a70c6c660c727fd1c18b13222678974a74 (patch)
tree33bc9be6180958d893d4e37954a3d39176f978ce /src
parent90b36bd274d523eb54700f71069558b15731adb0 (diff)
downloadraylib-b5dd18a70c6c660c727fd1c18b13222678974a74.tar.gz
raylib-b5dd18a70c6c660c727fd1c18b13222678974a74.zip
Review Sleep() usage, return to busy-wait-loop
Diffstat (limited to 'src')
-rw-r--r--src/core.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/core.c b/src/core.c
index 5a1ab77f..b8d822a8 100644
--- a/src/core.c
+++ b/src/core.c
@@ -2024,9 +2024,12 @@ static double GetTime(void)
}
// Wait for some milliseconds (stop program execution)
+// NOTE: Sleep() granularity could be around 10 ms, it means, Sleep() could
+// take longer than expected... for that reason we use the busy wait loop
+// http://stackoverflow.com/questions/43057578/c-programming-win32-games-sleep-taking-longer-than-expected
static void Wait(float ms)
{
-//#define SUPPORT_BUSY_WAIT_LOOP
+#define SUPPORT_BUSY_WAIT_LOOP
#if defined(SUPPORT_BUSY_WAIT_LOOP)
double prevTime = GetTime();
double nextTime = 0.0;
@@ -2035,7 +2038,7 @@ static void Wait(float ms)
while ((nextTime - prevTime) < ms/1000.0f) nextTime = GetTime();
#else
#if defined _WIN32
- Sleep(ms);
+ Sleep((unsigned int)ms);
#elif defined __linux__ || defined(PLATFORM_WEB)
struct timespec req = { 0 };
time_t sec = (int)(ms/1000.0f);