Horizon
marker.hpp
1 #pragma once
2 #include "common/common.hpp"
3 #include "util/uuid.hpp"
4 #include <deque>
5 #include <epoxy/gl.h>
6 
7 namespace horizon {
8 
9 class Marker {
10 public:
11  float x;
12  float y;
13  float r;
14  float g;
15  float b;
16  uint8_t flags;
17 
18  Marker(const Coordf &p, const Color &co, uint8_t f = 0) : x(p.x), y(p.y), r(co.r), g(co.g), b(co.b), flags(f)
19  {
20  }
21 } __attribute__((packed));
22 
23 enum class MarkerDomain { CHECK, SEARCH, N_DOMAINS };
24 
25 class MarkerRef {
26 public:
27  Coordf position;
28  UUID sheet;
29  Color color;
30  MarkerRef(const Coordf &pos, const Color &co, const UUID &s = UUID()) : position(pos), sheet(s), color(co)
31  {
32  }
33 };
34 
35 class Markers {
36  friend class MarkerRenderer;
37 
38 public:
39  Markers(class CanvasGL *c);
40 
41  std::deque<MarkerRef> &get_domain(MarkerDomain dom);
42  void set_domain_visible(MarkerDomain dom, bool vis);
43  void update();
44 
45 private:
46  std::array<std::deque<MarkerRef>, static_cast<int>(MarkerDomain::N_DOMAINS)> domains;
47  std::array<bool, static_cast<int>(MarkerDomain::N_DOMAINS)> domains_visible;
48  CanvasGL *ca;
49 };
50 
52  friend class CanvasGL;
53 
54 public:
55  MarkerRenderer(class CanvasGL *c, Markers &ma);
56  void realize();
57  void render();
58  void push();
59  void update();
60 
61 private:
62  CanvasGL *ca;
63  std::vector<Marker> markers;
64  Markers &markers_ref;
65 
66  GLuint program;
67  GLuint vao;
68  GLuint vbo;
69 
70  GLuint screenmat_loc;
71  GLuint viewmat_loc;
72  GLuint scale_loc;
73  GLuint alpha_loc;
74  GLuint border_color_loc;
75 };
76 } // namespace horizon
Definition: marker.hpp:9
Definition: marker.hpp:25
Definition: canvas_gl.hpp:13
Definition: marker.hpp:35
Definition: marker.hpp:51
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
Definition: block.cpp:9
Definition: common.hpp:207