]> git.tdb.fi Git - libs/gl.git/blob - source/render/windowview.cpp
bbc7bb00512ff549bf34c1b234c97fa815571af5
[libs/gl.git] / source / render / windowview.cpp
1 #include "camera.h"
2 #include "windowview.h"
3
4 using namespace std;
5
6 namespace Msp {
7 namespace GL {
8
9 WindowView::WindowView(Graphics::Window &w):
10         window(w),
11         device(Device::get_current())
12 {
13         window.signal_resize.connect(sigc::mem_fun(this, &WindowView::window_resized));
14         window_resized(window.get_width(), window.get_height());
15 }
16
17 void WindowView::render(Renderer &renderer)
18 {
19         View::render(renderer);
20         device.get_context().swap_buffers();
21 }
22
23 void WindowView::window_resized(unsigned w, unsigned h)
24 {
25         Framebuffer::system().resize(*this);
26         float aspect = static_cast<float>(w)/h;
27         if(camera)
28                 camera->set_aspect_ratio(aspect);
29 }
30
31 const Framebuffer &WindowView::get_target() const
32 {
33         return Framebuffer::system();
34 }
35
36 } // namespace GL
37 } // namespace Msp