]> git.tdb.fi Git - libs/vr.git/blobdiff - source/openvr/openvrcombiner.cpp
Implement display mirroring in StereoCombiner
[libs/vr.git] / source / openvr / openvrcombiner.cpp
index 2272a1a3509dad7b4667b49fb4a6c348d2026078..9bdf4b01a8151755a7f1ca3fa715c6dd96de9045 100644 (file)
@@ -11,8 +11,9 @@ struct OpenVRCombiner::Private
 };
 
 
-OpenVRCombiner::OpenVRCombiner(OpenVRDevice &d):
-       device(d)
+OpenVRCombiner::OpenVRCombiner(OpenVRDevice &d, GL::View &v):
+       device(d),
+       view(v)
 {
        vr::IVRSystem *vr_sys = vr::VRSystem();
        uint32_t w, h;
@@ -23,6 +24,8 @@ OpenVRCombiner::OpenVRCombiner(OpenVRDevice &d):
        Frustum left_frustum = Private::get_projection(vr::Eye_Left);
        Frustum right_frustum = Private::get_projection(vr::Eye_Right);
        configure_eye_frustums(left_frustum, right_frustum);
+
+       set_mirroring(true);
 }
 
 void OpenVRCombiner::prepare() const
@@ -41,6 +44,13 @@ void OpenVRCombiner::render(const GL::Texture2D &left, const GL::Texture2D &righ
        compositor->Submit(vr::Eye_Left, &tex);
        tex.handle = reinterpret_cast<void *>(right.get_id());
        compositor->Submit(vr::Eye_Right, &tex);
+
+       if(mirror)
+       {
+               mirror->shdata.uniform("scale", view.get_aspect()/render_aspect/2, 0.5f);
+               render_mirror(left);
+               view.get_context().swap_buffers();
+       }
 }