]> git.tdb.fi Git - libs/gl.git/blob - source/render/placeable.h
Check the flat qualifier from the correct member
[libs/gl.git] / source / render / placeable.h
1 #ifndef MSP_GL_PLACEABLE_H_
2 #define MSP_GL_PLACEABLE_H_
3
4 #include "matrix.h"
5 #include "renderable.h"
6
7 namespace Msp {
8 namespace GL {
9
10 /**
11 A base class for things that can be positioned and oriented in 3D space.
12 */
13 class Placeable
14 {
15 protected:
16         Matrix matrix;
17
18         Placeable() = default;
19 public:
20         virtual ~Placeable() = default;
21
22         virtual void set_matrix(const Matrix &);
23
24         /** Returns the Placeable's matrix.  This function returns a pointer for
25         compatibility with Renderable.  The returned pointer is never null. */
26         virtual const Matrix *get_matrix() const { return &matrix; }
27 };
28
29
30 /**
31 An intermediate base class combining the functionality of Renderable and
32 Placeable.
33 */
34 class PlacedRenderable: public Renderable, public Placeable
35 {
36 protected:
37         PlacedRenderable() = default;
38
39 public:
40         /* Reimplement to clear ambiguity between Renderable and Placeable.  This
41         overrides both base classes' implementations. */
42         virtual const Matrix *get_matrix() const { return &matrix; }
43 };
44
45 } // namespace GL
46 } // namespace Msp
47
48 #endif