]> git.tdb.fi Git - libs/gl.git/blob - source/view.cpp
Appease the compiler with some extra copy-ctor's and operator='s
[libs/gl.git] / source / view.cpp
1 #include "camera.h"
2 #include "renderable.h"
3 #include "renderer.h"
4 #include "view.h"
5
6 namespace Msp {
7 namespace GL {
8
9 View::View(Framebuffer &t):
10         target(t),
11         camera(0),
12         content(0)
13 { }
14
15 void View::set_camera(Camera *c)
16 {
17         camera = c;
18         if(camera)
19                 camera->set_aspect_ratio(get_aspect_ratio());
20 }
21
22 void View::set_content(Renderable *r)
23 {
24         content = r;
25 }
26
27 void View::synchronize_camera_aspect(Camera &c)
28 {
29         synced_cameras.push_back(&c);
30         c.set_aspect_ratio(get_aspect_ratio());
31 }
32
33 void View::render()
34 {
35         Bind bind_fbo(target);
36         target.clear(COLOR_BUFFER_BIT|DEPTH_BUFFER_BIT);
37         if(content)
38         {
39                 Renderer renderer(camera);
40                 content->setup_frame(renderer);
41                 content->render(renderer);
42                 content->finish_frame();
43         }
44 }
45
46 } // namespace GL
47 } // namespace Msp