Skip to content
This repository has been archived by the owner on Jul 16, 2019. It is now read-only.

Commit

Permalink
Fix time
Browse files Browse the repository at this point in the history
  • Loading branch information
flyingrub committed Mar 21, 2019
1 parent 56ac8ca commit cb1fa2d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/api/Plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ FFResult Plugin::ProcessOpenGL(ProcessOpenGLStruct * pGL)
i += 1;
}
frame++;
float timeNow = getTicks() / 1000.0f;
auto t_now = std::chrono::high_resolution_clock::now();
float timeNow = std::chrono::duration<double, std::milli>(t_now - t_start).count() / 1000.0f;
float deltaTime = timeNow - lastUpdate;
lastUpdate = timeNow;
glUniform1f(shader.FindUniform("time"), timeNow);
Expand Down
2 changes: 2 additions & 0 deletions src/api/Plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <string>
#include "../helpers/Audio.h"
#include "../helpers/Utils.h"
#include <chrono>

typedef CFFGLPluginInfo PluginInstance;

Expand Down Expand Up @@ -98,6 +99,7 @@ class Plugin : public CFreeFrameGLPlugin
ffglex::FFGLScreenQuad quad;
float lastUpdate = 0;
int frame = 0;
std::chrono::time_point<std::chrono::high_resolution_clock> t_start = std::chrono::high_resolution_clock::now();
Audio audio;
utils::Random random;

Expand Down

0 comments on commit cb1fa2d

Please sign in to comment.