cat3d
A tiny OpenGL 3D engine library written in and for C++.
timer.hpp
1 #pragma once
2 
3 #include <functional>
4 
5 #include "cat3d/scene.hpp"
6 #include "cat3d/util/clock.hpp"
7 
8 namespace cat3d::obj {
9 
14 class timer : public scene::node {
15 public:
23  timer(std::function<void(util::time dt)> fn, util::time interval = util::time(), int ct = -1);
24 
25 protected:
26  void update_self(window& win);
27 
28 private:
30  util::clock m_clock;
31 
33  std::function<void(util::time dt)> m_fn;
34 
36  util::time m_ivl;
37 
39  int m_ct;
40 };
41 
42 }
cat3d::window
Manages internal window api / state.
Definition: window.hpp:17
cat3d::util::clock
Class to measure the passage of time.
Definition: clock.hpp:92
cat3d::obj::timer::timer
timer(std::function< void(util::time dt)> fn, util::time interval=util::time(), int ct=-1)
Run a function on a timer.
cat3d::util::time
Class representing a duration of time.
Definition: clock.hpp:11
cat3d::obj::timer
cat3d node for timing the call of a function.
Definition: timer.hpp:14
cat3d::scene::node
Basic, semi-abstract scene node class. Can have children which are other scene nodes,...
Definition: node.hpp:28
cat3d::obj::timer::update_self
void update_self(window &win)
Overridden by child classes to implement custom behavior.