]> git.tdb.fi Git - libs/gl.git/blob - source/view.h
Add a convenience method to get the aspect ratio of View
[libs/gl.git] / source / view.h
1 #ifndef MSP_GL_VIEW_H_
2 #define MSP_GL_VIEW_H_
3
4 #include <list>
5 #include <sigc++/trackable.h>
6 #include <msp/graphics/glcontext.h>
7 #include <msp/graphics/window.h>
8
9 namespace Msp {
10 namespace GL {
11
12 class Camera;
13 class Framebuffer;
14 class Renderable;
15
16 /**
17 Manages the presentation of rendering results on the screen.
18 */
19 class View: public sigc::trackable
20 {
21 private:
22         Graphics::Window &window;
23         Graphics::GLContext &context;
24         Framebuffer &target;
25         const Renderable *content;
26         std::list<Camera *> synced_cameras;
27
28 public:
29         View(Graphics::Window &, Graphics::GLContext &);
30
31         Graphics::Window &get_window() { return window; }
32         Graphics::GLContext &get_context() { return context; }
33         unsigned get_width() const { return window.get_width(); }
34         unsigned get_height() const { return window.get_height(); }
35         float get_aspect() const { return static_cast<float>(get_width())/get_height(); }
36
37         void set_content(const Renderable *);
38         void synchronize_camera_aspect(Camera &);
39
40         void render();
41
42 private:
43         void window_resized(unsigned, unsigned);
44 };
45
46 } // namespace GL
47 } // namespace Msp
48
49 #endif