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));
22 void View::set_camera(Camera *c)
26 camera->set_aspect(static_cast<float>(window.get_width())/window.get_height());
29 void View::set_content(Renderable *r)
34 void View::synchronize_camera_aspect(Camera &c)
36 synced_cameras.push_back(&c);
37 c.set_aspect(static_cast<float>(window.get_width())/window.get_height());
42 target.clear(COLOR_BUFFER_BIT|DEPTH_BUFFER_BIT);
45 Renderer renderer(camera);
46 content->setup_frame(renderer);
47 content->render(renderer);
48 content->finish_frame();
50 context.swap_buffers();
53 void View::window_resized(unsigned w, unsigned h)
55 target.viewport(0, 0, w, h);
56 float aspect = static_cast<float>(w)/h;
58 camera->set_aspect(aspect);
59 for(list<Camera *>::iterator i=synced_cameras.begin(); i!=synced_cameras.end(); ++i)
60 (*i)->set_aspect(aspect);