Horizon
triangle_renderer.hpp
1 #pragma once
2 #include "triangle.hpp"
3 #include "util/gl_inc.h"
4 #include <map>
5 #include <vector>
6 #include "util/vector_pair.hpp"
7 
8 namespace horizon {
10  friend class CanvasGL;
11 
12 public:
13  TriangleRenderer(const class CanvasGL &c, const std::map<int, vector_pair<Triangle, TriangleInfo>> &tris);
14  void realize();
15  void render();
16  void push();
17 
18 private:
19  const CanvasGL &ca;
20  enum class Type { TRIANGLE, LINE, LINE0, LINE_BUTT, GLYPH, CIRCLE };
21  const std::map<int, vector_pair<Triangle, TriangleInfo>> &triangles;
22  std::map<int, std::map<std::pair<Type, bool>, std::pair<size_t, size_t>>> layer_offsets;
23  size_t n_tris = 0;
24 
25  GLuint program_line0;
26  GLuint program_line;
27  GLuint program_line_butt;
28  GLuint program_triangle;
29  GLuint program_circle;
30  GLuint program_glyph;
31  GLuint vao;
32  GLuint vbo;
33  GLuint ubo;
34  GLuint ebo;
35  GLuint texture_glyph;
36 
37  enum class HighlightMode { SKIP, ONLY };
38  void render_layer(int layer, HighlightMode highlight_mode, bool ignore_flip = false);
39  void render_layer_with_overlay(int layer, HighlightMode highlight_mode);
40  void render_annotations(bool top);
41  std::array<float, 4> apply_highlight(const class Color &color, HighlightMode mode, int layer) const;
42  int stencil = 0;
43 };
44 } // namespace horizon
horizon::CanvasGL
Definition: canvas_gl.hpp:18
horizon::Color
Definition: common.hpp:220
horizon::vector_pair
Definition: vector_pair.hpp:8
horizon::TriangleRenderer
Definition: triangle_renderer.hpp:9