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  enum Flags { F_SMALL = (1 << 0) };
18 
19  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)
20  {
21  }
22 } __attribute__((packed));
23 
24 enum class MarkerDomain { CHECK, SEARCH, N_DOMAINS };
25 
26 class MarkerRef {
27 public:
28  Coordf position;
29  UUID sheet;
30  Color color;
31  enum class Size { DEFAULT, SMALL };
32  Size size = Size::DEFAULT;
33  MarkerRef(const Coordf &pos, const Color &co, const UUID &s = UUID()) : position(pos), sheet(s), color(co)
34  {
35  }
36 };
37 
38 class Markers {
39  friend class MarkerRenderer;
40 
41 public:
42  Markers(class CanvasGL *c);
43 
44  std::deque<MarkerRef> &get_domain(MarkerDomain dom);
45  void set_domain_visible(MarkerDomain dom, bool vis);
46  void update();
47 
48 private:
49  std::array<std::deque<MarkerRef>, static_cast<int>(MarkerDomain::N_DOMAINS)> domains;
50  std::array<bool, static_cast<int>(MarkerDomain::N_DOMAINS)> domains_visible;
51  CanvasGL *ca;
52 };
53 
55  friend class CanvasGL;
56 
57 public:
58  MarkerRenderer(class CanvasGL *c, Markers &ma);
59  void realize();
60  void render();
61  void push();
62  void update();
63 
64 private:
65  CanvasGL *ca;
66  std::vector<Marker> markers;
67  Markers &markers_ref;
68 
69  GLuint program;
70  GLuint vao;
71  GLuint vbo;
72 
73  GLuint screenmat_loc;
74  GLuint viewmat_loc;
75  GLuint scale_loc;
76  GLuint alpha_loc;
77  GLuint border_color_loc;
78 };
79 } // namespace horizon
horizon::MarkerRenderer
Definition: marker.hpp:54
libzip::uint8_t
zip_uint8_t uint8_t
zip_uint8_t typedef.
Definition: zip.hpp:78
horizon::CanvasGL
Definition: canvas_gl.hpp:15
horizon::Markers
Definition: marker.hpp:38
horizon::Color
Definition: common.hpp:213
horizon::Coord< float >
horizon::UUID
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
horizon::Marker
Definition: marker.hpp:9
horizon::MarkerRef
Definition: marker.hpp:26