]> git.tdb.fi Git - libs/vr.git/blobdiff - source/ovr/oculusriftcombiner.cpp
Automatically configure the window to cover the Rift's monitor
[libs/vr.git] / source / ovr / oculusriftcombiner.cpp
index d71a93d2e1d6f61913a78887bfc2182741d04206..b9515edcddb9ff8b9161dac229b62d080862d983 100644 (file)
@@ -76,8 +76,9 @@ void create_distortion_mesh(Msp::GL::Mesh &mesh, ovrHmd hmd, ovrEyeType eye, con
 namespace Msp {
 namespace VR {
 
-OculusRiftCombiner::OculusRiftCombiner(const OculusRiftDevice &d):
+OculusRiftCombiner::OculusRiftCombiner(OculusRiftDevice &d, GL::View &v):
        device(d),
+       view(v),
        left_mesh((GL::VERTEX2, GL::TEXCOORD2,0, GL::TEXCOORD2,1, GL::TEXCOORD2,2, GL::TEXCOORD2,3)),
        right_mesh((GL::VERTEX2, GL::TEXCOORD2,0, GL::TEXCOORD2,1, GL::TEXCOORD2,2, GL::TEXCOORD2,3)),
        shprog(vs_source, fs_source)
@@ -120,6 +121,13 @@ OculusRiftCombiner::OculusRiftCombiner(const OculusRiftDevice &d):
        ovrHmd_GetRenderScaleAndOffset(right_fov, tex_size, view_rect, uv_scale_offset);
        right_shdata.uniform("uv_scale", uv_scale_offset[0].x, -uv_scale_offset[0].y);
        right_shdata.uniform("uv_offset", uv_scale_offset[1].x, 1-uv_scale_offset[1].y);
+
+       device.configure_window(view.get_window());
+}
+
+void OculusRiftCombiner::prepare() const
+{
+       device.begin_frame();
 }
 
 void OculusRiftCombiner::render(const GL::Texture2D &left, const GL::Texture2D &right) const
@@ -154,6 +162,9 @@ void OculusRiftCombiner::render(const GL::Texture2D &left, const GL::Texture2D &
        right.bind();
        right_shdata.apply();
        right_mesh.draw();
+
+       view.get_context().swap_buffers();
+       device.end_frame();
 }
 
 } // namespace VR