]> git.tdb.fi Git - libs/gl.git/blob - source/windowview.cpp
Support animations on Placeables
[libs/gl.git] / source / 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, Graphics::GLContext &c):
10         window(w),
11         context(c)
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()
18 {
19         View::render();
20         context.swap_buffers();
21 }
22
23 void WindowView::window_resized(unsigned w, unsigned h)
24 {
25         target.viewport(0, 0, w, h);
26         float aspect = static_cast<float>(w)/h;
27         if(camera)
28                 camera->set_aspect_ratio(aspect);
29         for(list<Camera *>::iterator i=synced_cameras.begin(); i!=synced_cameras.end(); ++i)
30                 (*i)->set_aspect_ratio(aspect);
31 }
32
33 } // namespace GL
34 } // namespace Msp