X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fview.cpp;h=7ab41912ef19d1be6251e279725a9fbfa7830bbe;hp=b4dcca99cc4a4f6b6bb6839df1ee39bf8f99fc23;hb=9e384cddaf641f25ce6714327e1b4fadfea4632d;hpb=4bd863e50d6ca102b2ddb4b33fd7632a1c195c8e diff --git a/source/view.cpp b/source/view.cpp index b4dcca99..7ab41912 100644 --- a/source/view.cpp +++ b/source/view.cpp @@ -1,30 +1,22 @@ #include "camera.h" -#include "framebuffer.h" #include "renderable.h" #include "renderer.h" #include "view.h" -using namespace std; - namespace Msp { namespace GL { -View::View(Graphics::Window &w, Graphics::GLContext &c): - window(w), - context(c), - target(Framebuffer::system()), +View::View(Framebuffer &t): + target(t), camera(0), content(0) -{ - window.signal_resize.connect(sigc::mem_fun(this, &View::window_resized)); - window_resized(window.get_width(), window.get_height()); -} +{ } void View::set_camera(Camera *c) { camera = c; if(camera) - camera->set_aspect(static_cast(window.get_width())/window.get_height()); + camera->set_aspect_ratio(get_aspect_ratio()); } void View::set_content(Renderable *r) @@ -35,11 +27,12 @@ void View::set_content(Renderable *r) void View::synchronize_camera_aspect(Camera &c) { synced_cameras.push_back(&c); - c.set_aspect(static_cast(window.get_width())/window.get_height()); + c.set_aspect_ratio(get_aspect_ratio()); } void View::render() { + Bind bind_fbo(target); target.clear(COLOR_BUFFER_BIT|DEPTH_BUFFER_BIT); if(content) { @@ -48,17 +41,6 @@ void View::render() content->render(renderer); content->finish_frame(); } - context.swap_buffers(); -} - -void View::window_resized(unsigned w, unsigned h) -{ - target.viewport(0, 0, w, h); - float aspect = static_cast(w)/h; - if(camera) - camera->set_aspect(aspect); - for(list::iterator i=synced_cameras.begin(); i!=synced_cameras.end(); ++i) - (*i)->set_aspect(aspect); } } // namespace GL