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