diff options
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp index b63b610..e9a3301 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,8 +1,19 @@ #include "common.hpp" +#include <ctime> + +uint64_t nano_clock(void) +{ + struct timespec ts; + + clock_gettime(CLOCK_MONOTONIC_RAW, &ts); + return ts.tv_sec * 1000000000LLU + ts.tv_nsec; +} int main() { + uint64_t t0 = nano_clock(); sf::RenderWindow window(sf::VideoMode(800, 600), "Minitrem"); + render::state_t render(&window); game::state_t game; interface::state_t interface(&window, &game); @@ -11,15 +22,19 @@ int main() game.start(); while (1) { + double now = (nano_clock() - t0) * 1.0e-9; + game.tick(); interface.tick(); if (!window.isOpen()) break; - + window.clear(); - game.render(&window); + render.begin_frame(now); + render.render(&game); + //game.render(&render); interface.render(); - window.display(); + render.end_frame(); } return 0; |