track real and scaled time
This commit is contained in:
parent
2fd7797e7d
commit
b3c5440736
|
@ -1,6 +1,11 @@
|
||||||
#include "clock.h"
|
#include "clock.h"
|
||||||
|
|
||||||
float now(struct Epoch t)
|
float now()
|
||||||
{
|
{
|
||||||
return t.speed * (float)SDL_GetTicks() / 1000.0;
|
return (float)SDL_GetTicks() / 1000.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
float nowScaled(struct Epoch t)
|
||||||
|
{
|
||||||
|
return t.scale * now();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,10 @@
|
||||||
|
|
||||||
struct Epoch
|
struct Epoch
|
||||||
{
|
{
|
||||||
float speed;
|
float scale;
|
||||||
};
|
};
|
||||||
|
|
||||||
// seconds since program start
|
// real seconds since program start
|
||||||
float now(struct Epoch e);
|
float now();
|
||||||
|
// simulation seconds since program start
|
||||||
|
float nowScaled(struct Epoch e);
|
||||||
|
|
|
@ -41,7 +41,7 @@ void parseArgs(int argc, char* argv[], struct Epoch* e)
|
||||||
fprintf(stderr, "usage: oglc TIMESPEED\n");
|
fprintf(stderr, "usage: oglc TIMESPEED\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
sscanf(argv[1], "%f", &(e->speed));
|
sscanf(argv[1], "%f", &(e->scale));
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
|
@ -50,12 +50,12 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
initialise();
|
initialise();
|
||||||
|
|
||||||
float start = now(epoch);
|
float start = now();
|
||||||
int frames;
|
int frames;
|
||||||
for (frames = 0; !checkQuit(); frames++)
|
for (frames = 0; !checkQuit(); frames++)
|
||||||
{
|
{
|
||||||
GLuint shader;
|
GLuint shader;
|
||||||
float t = now(epoch);
|
float t = nowScaled(epoch);
|
||||||
|
|
||||||
// prepass
|
// prepass
|
||||||
// TODO: write output to different texture than main output
|
// TODO: write output to different texture than main output
|
||||||
|
@ -104,7 +104,7 @@ int main(int argc, char* argv[])
|
||||||
SDL_GL_SwapWindow(window);
|
SDL_GL_SwapWindow(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
float elapsed = now(epoch)-start;
|
float elapsed = now()-start;
|
||||||
printf("%d frames in %fs [%f fps]\n",
|
printf("%d frames in %fs [%f fps]\n",
|
||||||
frames,
|
frames,
|
||||||
elapsed,
|
elapsed,
|
||||||
|
|
Loading…
Reference in New Issue