fix: use chrono for time

This commit is contained in:
Cat Flynn 2024-08-21 14:53:33 +01:00
parent ae3e5c201b
commit 6844f4454c
1 changed files with 13 additions and 3 deletions

View File

@ -49,6 +49,8 @@
#include <skein/particle.h>
#include <skein/particlemap.h>
#include <chrono>
// INPUT!
//
// what input do we even want in the first place?
@ -84,6 +86,12 @@ void clearInput()
input.cycleAnimation = false;
}
double getTime()
{
auto now = std::chrono::steady_clock::now().time_since_epoch();
return std::chrono::duration<double>(now).count();
}
int main()
{
GLFWwindow* window = nullptr;
@ -120,7 +128,8 @@ int main()
const int ANIM_ORBITING = 0;
const int ANIM_ECCENTRICITY = 1;
int animation = 0;
float time = glfwGetTime();
double time = getTime();
// Main loop
while (!glfwWindowShouldClose(window))
@ -141,13 +150,14 @@ int main()
}
// only update time if playing the orbiting animation
const double speed = 0.5;
if (animation == ANIM_ORBITING)
{
time = glfwGetTime();
time = getTime() * speed;
}
else
{
float e = .25 + .2 * sin(glfwGetTime());
double e = .25 + .2 * sin(getTime());
orbit.setEccentricity(e);
}