X-Git-Url: http://git.tdb.fi/?p=libs%2Fvr.git;a=blobdiff_plain;f=source%2Fstereoview.cpp;h=c52802309ef5119677e2451ddc81c9a63717a1cb;hp=9a4b0e0c49dad965c6100d2847605bd54663bd55;hb=3e6a0a2a12f6b269f3157d6a9d56d34b5ab59e4c;hpb=43579020c5709b589b2404414c489b0e6be3227d diff --git a/source/stereoview.cpp b/source/stereoview.cpp index 9a4b0e0..c528023 100644 --- a/source/stereoview.cpp +++ b/source/stereoview.cpp @@ -1,13 +1,13 @@ -#include "renderer.h" +#include #include "stereocombiner.h" #include "stereoview.h" using namespace std; namespace Msp { -namespace GL { +namespace VR { -StereoView::StereoView(unsigned w, unsigned h, const Camera &c, const Renderable &r, const StereoCombiner &m): +StereoView::StereoView(unsigned w, unsigned h, const GL::Camera &c, const GL::Renderable &r, const StereoCombiner &m): width(w), height(h), base_camera(c), @@ -22,8 +22,8 @@ void StereoView::set_combiner(const StereoCombiner &c) { combiner = &c; - unsigned w = width/combiner->get_width_divisor(); - unsigned h = height/combiner->get_height_divisor(); + unsigned w = width/combiner->get_width_divisor()*combiner->get_oversize(); + unsigned h = height/combiner->get_height_divisor()*combiner->get_oversize(); left.create_target(w, h); right.create_target(w, h); } @@ -39,7 +39,7 @@ void StereoView::setup_frame() const EyeParams params; params.fov = combiner->get_field_of_view(); - if(!params.fov) + if(params.fov==Geometry::Angle::zero()) params.fov = base_camera.get_field_of_view(); params.aspect = base_camera.get_aspect(); @@ -60,7 +60,7 @@ void StereoView::finish_frame() const renderable.finish_frame(); } -void StereoView::render(const Tag &tag) const +void StereoView::render(const GL::Tag &tag) const { setup_frame(); left.render(renderable, tag); @@ -69,7 +69,7 @@ void StereoView::render(const Tag &tag) const finish_frame(); } -void StereoView::render(Renderer &renderer, const Tag &tag) const +void StereoView::render(GL::Renderer &renderer, const GL::Tag &tag) const { renderer.escape(); return render(tag); @@ -78,13 +78,13 @@ void StereoView::render(Renderer &renderer, const Tag &tag) const StereoView::RenderTarget::RenderTarget(unsigned width, unsigned height) { - color.set_min_filter(LINEAR); - color.set_wrap(CLAMP_TO_EDGE); - color.storage(RGB, width, height); - fbo.attach(COLOR_ATTACHMENT0, color); + color.set_min_filter(GL::LINEAR); + color.set_wrap(GL::CLAMP_TO_EDGE); + color.storage(GL::RGB, width, height); + fbo.attach(GL::COLOR_ATTACHMENT0, color); - depth.storage(DEPTH_COMPONENT, width, height); - fbo.attach(DEPTH_ATTACHMENT, depth); + depth.storage(GL::DEPTH_COMPONENT, width, height); + fbo.attach(GL::DEPTH_ATTACHMENT, depth); } @@ -98,7 +98,7 @@ void StereoView::Eye::create_target(unsigned w, unsigned h) target = new RenderTarget(w, h); } -void StereoView::Eye::setup_frame(const Camera &base_camera, const Vector3 &offset, const EyeParams ¶ms) const +void StereoView::Eye::setup_frame(const GL::Camera &base_camera, const GL::Vector3 &offset, const EyeParams ¶ms) const { camera.set_position(base_camera.get_position()+offset); camera.set_up_direction(base_camera.get_up_direction()); @@ -109,12 +109,13 @@ void StereoView::Eye::setup_frame(const Camera &base_camera, const Vector3 &offs camera.set_depth_clip(params.near_clip, params.far_clip); } -void StereoView::Eye::render(const Renderable &renderable, const Tag &tag) const +void StereoView::Eye::render(const GL::Renderable &renderable, const GL::Tag &tag) const { - Bind bind_fbo(target->fbo); - Renderer renderer(&camera); + GL::Bind bind_fbo(target->fbo); + target->fbo.clear(GL::COLOR_BUFFER_BIT|GL::DEPTH_BUFFER_BIT); + GL::Renderer renderer(&camera); renderable.render(renderer, tag); } -} // namespace GL +} // namespace VR } // namespace Msp