2 #include "framebuffer.h"
3 #include "renderable.h"
12 View::View(Graphics::Window &w, Graphics::GLContext &c):
15 target(Framebuffer::system()),
18 window.signal_resize.connect(sigc::mem_fun(this, &View::window_resized));
21 void View::set_camera(Camera *c)
26 void View::set_content(Renderable *r)
31 void View::synchronize_camera_aspect(Camera &c)
33 synced_cameras.push_back(&c);
34 c.set_aspect(static_cast<float>(window.get_width())/window.get_height());
39 target.clear(COLOR_BUFFER_BIT|DEPTH_BUFFER_BIT);
42 Renderer renderer(camera);
43 content->setup_frame();
44 content->render(renderer);
45 content->finish_frame();
47 context.swap_buffers();
50 void View::window_resized(unsigned w, unsigned h)
52 target.viewport(0, 0, w, h);
53 float aspect = static_cast<float>(w)/h;
55 camera->set_aspect(aspect);
56 for(list<Camera *>::iterator i=synced_cameras.begin(); i!=synced_cameras.end(); ++i)
57 (*i)->set_aspect(aspect);