#include <SDL.h>
#include <unistd.h>
#include <stdio.h>
+#include <time.h>
#include "random.h"
#include "planet.h"
buf[i] = 0;
}
+/* Return time in microseconds */
+
+static unsigned long long gettime(void)
+{
+ struct timespec tp;
+ unsigned long long ret;
+
+ clock_gettime(CLOCK_MONOTONIC, &tp);
+
+ ret = tp.tv_sec * 1000 * 1000;
+ ret += tp.tv_nsec;
+
+ return ret;
+}
+
static int poll_events(SDL_Surface **screen, struct camera *cam,
double *time_scale, double time)
{
struct planet *planet, *pl1, *pl2;
struct camera camera;
int planets;
- int old_ticks, ticks, framecount = 0, last_fps_time = 0;
+ int framecount = 0, last_fps_time = 0;
int last_framecount = 0;
+ unsigned long long old_ticks, ticks;
double time = 0, last_fps = 0, time_scale = 1;
init_camera(&camera);
return;
old_ticks = ticks;
- ticks = SDL_GetTicks();
+ ticks = gettime();
time = (ticks - old_ticks) / 1000.0;
time = MIN(time, 0.02);