From fe05515f432cdceb84999d560f8be71172d35a11 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sat, 11 Jan 2014 22:13:03 +0100 Subject: [PATCH] Fixed uses of relative time for cnd_timedwait. --- examples/particles.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/particles.c b/examples/particles.c index 7a4725f8..49459e84 100644 --- a/examples/particles.c +++ b/examples/particles.c @@ -28,6 +28,7 @@ #include #include #include +#include #define GLFW_INCLUDE_GLU #include @@ -453,7 +454,9 @@ static void draw_particles(GLFWwindow* window, double t, float dt) while (!glfwWindowShouldClose(window) && thread_sync.p_frame <= thread_sync.d_frame) { - struct timespec ts = { 0, 100000000 }; + struct timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + ts.tv_nsec += 100000000; cnd_timedwait(&thread_sync.p_done, &thread_sync.particles_lock, &ts); } @@ -897,7 +900,9 @@ static int physics_thread_main(void* arg) while (!glfwWindowShouldClose(window) && thread_sync.p_frame > thread_sync.d_frame) { - struct timespec ts = { 0, 100000000 }; + struct timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + ts.tv_nsec += 100000000; cnd_timedwait(&thread_sync.d_done, &thread_sync.particles_lock, &ts); }