Horizon
marker.hpp
1 #pragma once
2 #include "common/common.hpp"
3 #include "util/uuid.hpp"
4 #include "util/uuid_vec.hpp"
5 #include <deque>
6 #include <epoxy/gl.h>
7 
8 namespace horizon {
9 
10 class Marker {
11 public:
12  float x;
13  float y;
14  float r;
15  float g;
16  float b;
17  uint8_t flags;
18  enum Flags { F_SMALL = (1 << 0) };
19 
20  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)
21  {
22  }
23 } __attribute__((packed));
24 
25 enum class MarkerDomain { CHECK, SEARCH, N_DOMAINS };
26 
27 class MarkerRef {
28 public:
29  Coordf position;
30  UUIDVec sheet;
31  Color color;
32  enum class Size { DEFAULT, SMALL };
33  Size size = Size::DEFAULT;
34  MarkerRef(const Coordf &pos, const Color &co, const UUIDVec &s = {}) : position(pos), sheet(s), color(co)
35  {
36  }
37 };
38 
39 class Markers {
40  friend class MarkerRenderer;
41 
42 public:
43  Markers(class CanvasGL &c);
44 
45  std::deque<MarkerRef> &get_domain(MarkerDomain dom);
46  void set_domain_visible(MarkerDomain dom, bool vis);
47  void update();
48  void set_sheet_filter(const UUIDVec &uu);
49 
50 private:
51  std::array<std::deque<MarkerRef>, static_cast<int>(MarkerDomain::N_DOMAINS)> domains;
52  UUIDVec sheet_filter;
53  std::array<bool, static_cast<int>(MarkerDomain::N_DOMAINS)> domains_visible;
54  CanvasGL &ca;
55 };
56 
58  friend class CanvasGL;
59 
60 public:
61  MarkerRenderer(const class CanvasGL &c, Markers &ma);
62  void realize();
63  void render();
64  void push();
65  void update();
66 
67 private:
68  const CanvasGL &ca;
69  std::vector<Marker> markers;
70  Markers &markers_ref;
71 
72  GLuint program;
73  GLuint vao;
74  GLuint vbo;
75 
76  GLuint screenmat_loc;
77  GLuint viewmat_loc;
78  GLuint scale_loc;
79  GLuint alpha_loc;
80  GLuint border_color_loc;
81 };
82 } // namespace horizon
Definition: canvas_gl.hpp:18
Definition: common.hpp:267
Definition: marker.hpp:27
Definition: marker.hpp:57
Definition: marker.hpp:10
Definition: marker.hpp:39
zip_uint8_t uint8_t
zip_uint8_t typedef.
Definition: zip.hpp:78