2 #include "framebuffer.h"
3 #include "renderable.h"
12 View::View(Graphics::Window &w, Graphics::GLContext &c):
15 target(Framebuffer::system()),
19 window.signal_resize.connect(sigc::mem_fun(this, &View::window_resized));
20 window_resized(window.get_width(), window.get_height());
23 void View::set_camera(Camera *c)
27 camera->set_aspect(static_cast<float>(window.get_width())/window.get_height());
30 void View::set_content(Renderable *r)
35 void View::synchronize_camera_aspect(Camera &c)
37 synced_cameras.push_back(&c);
38 c.set_aspect(static_cast<float>(window.get_width())/window.get_height());
43 target.clear(COLOR_BUFFER_BIT|DEPTH_BUFFER_BIT);
46 Renderer renderer(camera);
47 content->setup_frame(renderer);
48 content->render(renderer);
49 content->finish_frame();
51 context.swap_buffers();
54 void View::window_resized(unsigned w, unsigned h)
56 target.viewport(0, 0, w, h);
57 float aspect = static_cast<float>(w)/h;
59 camera->set_aspect(aspect);
60 for(list<Camera *>::iterator i=synced_cameras.begin(); i!=synced_cameras.end(); ++i)
61 (*i)->set_aspect(aspect);