]> git.tdb.fi Git - r2c2.git/blob - source/3d/overlay.h
Make use of GL::Renderer in Overlay3D
[r2c2.git] / source / 3d / overlay.h
1 /* $Id$
2
3 This file is part of R²C²
4 Copyright © 2010 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
6 */
7
8 #ifndef R2C2_3D_OVERLAY_H_
9 #define R2C2_3D_OVERLAY_H_
10
11 #include <msp/gbase/window.h>
12 #include <msp/gl/camera.h>
13 #include <msp/gl/font.h>
14 #include <msp/gl/mesh.h>
15 #include <msp/gl/renderable.h>
16
17 namespace R2C2 {
18
19 class Object3D;
20
21 class Overlay3D: public Msp::GL::Renderable
22 {
23 private:        
24         struct Icon
25         {
26                 std::vector<const Msp::GL::Mesh *> graphics;
27                 std::string label;
28                 float width;
29                 Msp::GL::Mesh background;
30                 Msp::GL::Mesh text;
31
32                 Icon();
33         };
34
35         const Msp::GL::Font &font;
36         std::map<std::string, Msp::GL::Mesh *> graphics;
37         std::map<const Object3D *, Icon *> icons;
38
39 public:
40         Overlay3D(const Msp::GL::Font &);
41         ~Overlay3D();
42
43         void set_label(const Object3D &, const std::string &);
44         void add_graphic(const Object3D &, const std::string &);
45         void remove_graphic(const Object3D &, const std::string &);
46         void clear_graphics(const Object3D &);
47         void clear(const Object3D &);
48
49         virtual void render(Msp::GL::Renderer &, const Msp::GL::Tag &) const;
50
51 private:
52         Icon &get_icon(const Object3D &);
53         const Msp::GL::Mesh *get_graphic(const std::string &);
54         void update_icon(Icon &);
55 };
56
57 } // namespace R2C2
58
59 #endif