-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathlooper.h
56 lines (52 loc) · 1.36 KB
/
looper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#pragma once
#include <Logging.h>
#include "animation.h"
#include "input.h"
#include "visualization.h"
namespace pixl {
/* The Looper is a singleton that is responsible for calling update() and
draw() on Inputs, Visualizations, and Animations */
class Looper {
public:
static Looper* instance() {
if (!looper_) {
looper_ = new Looper;
}
return looper_;
}
void loop();
void addAnimation(Animation* animation);
void addInput(Input* input);
void addVisualization(Visualization* visualization);
void clearAll();
void clearVisualizations();
void setUpdatesPerSecond(int updates);
void setFramesPerSecond(int frames);
private:
Looper()
: num_anim_(0),
num_input_(0),
num_viz_(0),
next_update_tick_(0),
next_draw_tick_(0),
draw_millis_per_tick_(0),
update_millis_per_tick_(0)
{
Log.Info("Looper instantiated\n");
}
void update_();
void draw_(float interpolation);
static Looper* looper_;
int updates_per_second_;
unsigned long next_update_tick_;
unsigned long next_draw_tick_;
float draw_millis_per_tick_;
float update_millis_per_tick_;
int num_anim_;
int num_input_;
int num_viz_;
Animation* animations_[10];
Visualization* visualizations_[10];
Input* inputs_[10];
};
} // end namespace pixl