-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathscene.h
54 lines (42 loc) · 1012 Bytes
/
scene.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
// scene.h
#ifndef SCENE_H
#define SCENE_H
#include "camera.h"
#include "grid.h"
#include "thread.h"
#include "utils.h"
class Scene
{
private:
static const int NB_GRIDS_X = 2;
static const int NB_GRIDS_Y = 2;
static const int NB_THREADS = NB_GRIDS_X * NB_GRIDS_Y;
Camera m_camera;
// Multithread update
struct ThreadData
{
Scene* p_scene;
Grid grid;
ThreadHandle thread_handle;
Event update_event;
Event main_event;
int index;
};
Color m_colors[NB_THREADS];
bool m_multithread;
ThreadData m_thread_data[NB_THREADS];
volatile bool m_shut;
volatile double m_elapsed_time;
volatile double m_update_time;
public:
bool init();
void shut();
void update(double elapsed, double t);
void draw(int win_w, int win_h);
void setMultithreaded(bool multithread) {m_multithread = multithread;}
bool isMultithreaded() const {return m_multithread;}
private:
void threadUpdate(ThreadData* data);
static void* threadUpdateWrapper(void* user_data);
};
#endif // SCENE_H