]> git.tdb.fi Git - libs/gl.git/blob - source/render/view.h
Check the flat qualifier from the correct member
[libs/gl.git] / source / render / view.h
1 #ifndef MSP_GL_VIEW_H_
2 #define MSP_GL_VIEW_H_
3
4 #include <msp/core/noncopyable.h>
5 #include "framebuffer.h"
6
7 namespace Msp {
8 namespace GL {
9
10 class Camera;
11 class Renderable;
12 class Renderer;
13
14 /**
15 An ultimate render target, which is typically visible to the user of the
16 application in some way.
17
18 The content renderable's render() function is called with an empty tag.  A
19 Sequence can be used to specify other tags and add post-processing.
20 */
21 class View: public NonCopyable
22 {
23 protected:
24         Camera *camera = 0;
25         Renderable *content = 0;
26         Renderer *internal_renderer = 0;
27
28         View() = default;
29 public:
30         View(View &&);
31         virtual ~View();
32
33         virtual unsigned get_width() const { return get_target().get_width(); }
34         virtual unsigned get_height() const { return get_target().get_height(); }
35         float get_aspect_ratio() const { return static_cast<float>(get_width())/get_height(); }
36
37         /** Sets the camera to render with.  The camera's aspect ratio is set to
38         match that of the view. */
39         void set_camera(Camera *);
40
41         void set_content(Renderable *);
42
43         virtual void render();
44         virtual void render(Renderer &);
45 protected:
46         virtual const Framebuffer &get_target() const = 0;
47 };
48
49 } // namespace GL
50 } // namespace Msp
51
52 #endif