From 5b5304850514f76d9e3ace1280097d9d3c7beeb1 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Mon, 8 May 2023 13:10:39 +0200 Subject: [PATCH] add utils --- includes/animations.h | 1 + includes/utils.h | 9 +++++++++ src/utils.c | 9 +++++++++ 3 files changed, 19 insertions(+) create mode 100644 includes/utils.h create mode 100644 src/utils.c diff --git a/includes/animations.h b/includes/animations.h index 958dc9b..68659e3 100644 --- a/includes/animations.h +++ b/includes/animations.h @@ -5,6 +5,7 @@ #include "audio.h" #include "font.h" +#include "utils.h" // Dimensions de la fenêtre extern GLuint _dims[]; diff --git a/includes/utils.h b/includes/utils.h new file mode 100644 index 0000000..43f0afe --- /dev/null +++ b/includes/utils.h @@ -0,0 +1,9 @@ +#ifndef DEMO_UTILS_H +#define DEMO_UTILS_H 1 + +#include + +// Récupère un delta-temps +double get_dt(void); + +#endif diff --git a/src/utils.c b/src/utils.c new file mode 100644 index 0000000..e9c181c --- /dev/null +++ b/src/utils.c @@ -0,0 +1,9 @@ +#include "../includes/utils.h" + +double get_dt(void) { + static double t0 = 0.0f; + double t = gl4dGetElapsedTime(), dt = (t - t0) / 1000.0; + t0 = t; + + return dt; +}