blob: 02c7eed611af161960131d553d928fe7b8ada73e (
plain)
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
|
#ifndef SYSTEM_LIGHT_HPP_
#define SYSTEM_LIGHT_HPP_
#include <color.hpp>
#include <render.hpp>
#include <vector2.hpp>
#include <entityx/entityx.h>
#include <vector>
struct Light {
vec2 pos;
float radius;
Color color;
Light(vec2 p = vec2(), float r = 0, Color c = Color())
: pos(p), radius(r), color(c) {}
};
class LightSystem : public entityx::System<LightSystem> {
private:
static std::vector<Light> lights;
static GLfloat *colorData;
static GLfloat *coordData;
static void resizeLights(void);
public:
void update(entityx::EntityManager& en, entityx::EventManager& ev, entityx::TimeDelta dt) override;
static void render(void);
static int addLight(vec2 pos, float radius, Color color = Color(1, 1, 1));
static void updateLight(int index, vec2 pos, float radius = -1);
static void removeLight(int index);
static inline void clear(void)
{ lights.clear(); }
};
#endif // SYSTEM_LIGHT_HPP_
|