fix: use chrono for time
This commit is contained in:
parent
ae3e5c201b
commit
6844f4454c
16
src/main.cpp
16
src/main.cpp
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue