]> git.tdb.fi Git - libs/gl.git/blob - source/render/view.cpp
Remove support for array size specialization from the engine as well
[libs/gl.git] / source / render / 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         internal_renderer(0)
14 { }
15
16 View::~View()
17 {
18         delete internal_renderer;
19 }
20
21 void View::set_camera(Camera *c)
22 {
23         camera = c;
24         if(camera)
25                 camera->set_aspect_ratio(get_aspect_ratio());
26 }
27
28 void View::set_content(Renderable *r)
29 {
30         content = r;
31 }
32
33 void View::render()
34 {
35         if(!internal_renderer)
36                 internal_renderer = new Renderer;
37         render(*internal_renderer);
38         internal_renderer->end();
39 }
40
41 void View::render(Renderer &renderer)
42 {
43         Renderer::Push _push(renderer);
44         renderer.set_framebuffer(&target);
45         if(content)
46         {
47                 if(camera)
48                         renderer.set_camera(*camera);
49                 content->setup_frame(renderer);
50                 content->render(renderer);
51                 content->finish_frame();
52         }
53 }
54
55 } // namespace GL
56 } // namespace Msp