X-Git-Url: http://git.tdb.fi/?p=libs%2Fvr.git;a=blobdiff_plain;f=source%2Fstereoview.cpp;h=efc54dd5f3a38e9158f9e10ec4de640b32eea2e5;hp=dd825ed1f276839cb76c614215ca15b1d4776a55;hb=0f239b07bc06bf26d0ee0f9c1ee1e3b636f6d1f6;hpb=b17410965e84e378c4cc85ffb732365552edc584 diff --git a/source/stereoview.cpp b/source/stereoview.cpp index dd825ed..efc54dd 100644 --- a/source/stereoview.cpp +++ b/source/stereoview.cpp @@ -15,7 +15,8 @@ StereoView::StereoView(unsigned w, unsigned h, const GL::Camera &c, const GL::Re combiner(0) { set_combiner(m); - set_eye_spacing(0.07); + set_eye_spacing(0.064); + set_strabismus(Geometry::Angle::zero()); } void StereoView::set_combiner(const StereoCombiner &c) @@ -33,9 +34,14 @@ void StereoView::set_eye_spacing(float s) eye_spacing = s; } +void StereoView::set_strabismus(const Geometry::Angle &s) +{ + strabismus = s; +} + void StereoView::setup_frame() const { - offset_axis = normalize(cross(base_camera.get_look_direction(), base_camera.get_up_direction()))*0.5f; + GL::Vector3 offset_axis = normalize(cross(base_camera.get_look_direction(), base_camera.get_up_direction()))*0.5f; EyeParams params; params.fov = combiner->get_field_of_view(); @@ -47,31 +53,21 @@ void StereoView::setup_frame() const params.far_clip = base_camera.get_far_clip(); float frustum_skew = combiner->get_frustum_skew(); + float halfw = tan(params.fov/2.0f)*params.aspect; + frustum_skew = tan(Geometry::atan(frustum_skew*halfw)+strabismus)/halfw; left.setup_frame(base_camera, offset_axis*-eye_spacing, frustum_skew, params); right.setup_frame(base_camera, offset_axis*eye_spacing, -frustum_skew, params); - - renderable.setup_frame(); -} - -void StereoView::finish_frame() const -{ - renderable.finish_frame(); } -void StereoView::render(const GL::Tag &tag) const +void StereoView::render() const { setup_frame(); - left.render(renderable, tag); - right.render(renderable, tag); + renderable.setup_frame(); + left.render(renderable); + right.render(renderable); + renderable.finish_frame(); combiner->render(left.target->color, right.target->color); - finish_frame(); -} - -void StereoView::render(GL::Renderer &renderer, const GL::Tag &tag) const -{ - renderer.escape(); - return render(tag); } @@ -109,12 +105,12 @@ void StereoView::Eye::setup_frame(const GL::Camera &base_camera, const GL::Vecto camera.set_frustum_axis(frustum_skew, 0); } -void StereoView::Eye::render(const GL::Renderable &renderable, const GL::Tag &tag) const +void StereoView::Eye::render(const GL::Renderable &renderable) const { 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); + renderable.render(renderer); } } // namespace VR