]> git.tdb.fi Git - libs/gl.git/blob - source/render/windowview.cpp
Replace the instance variables of exporters by function parameters
[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, Graphics::GLContext &c):
10         View(Framebuffer::system()),
11         window(w),
12         context(c)
13 {
14         window.signal_resize.connect(sigc::mem_fun(this, &WindowView::window_resized));
15         window_resized(window.get_width(), window.get_height());
16 }
17
18 void WindowView::render(Renderer &renderer)
19 {
20         View::render(renderer);
21         context.swap_buffers();
22 }
23
24 void WindowView::window_resized(unsigned w, unsigned h)
25 {
26         Framebuffer::system().resize(*this);
27         float aspect = static_cast<float>(w)/h;
28         if(camera)
29                 camera->set_aspect_ratio(aspect);
30 }
31
32 } // namespace GL
33 } // namespace Msp