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); }