]> git.tdb.fi Git - libs/vr.git/commitdiff
Automatically configure the window to cover the Rift's monitor
authorMikko Rasa <tdb@tdb.fi>
Fri, 16 Sep 2016 23:48:35 +0000 (02:48 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 16 Sep 2016 23:48:35 +0000 (02:48 +0300)
source/displaydevice.h
source/ovr/oculusriftcombiner.cpp
source/ovr/oculusriftdevice.cpp
source/ovr/oculusriftdevice.h

index cc015a8f6136c3139cbc6df09b69317f661428db..665ac85697a2ac4f1aa350719bdc735c3ab8f634 100644 (file)
@@ -18,6 +18,7 @@ protected:
 public:
        virtual ~DisplayDevice() { }
 
+       virtual void configure_window(Graphics::Window &) const = 0;
        virtual void configure_view(StereoView &) const = 0;
        virtual HeadTrackingCamera *create_camera(const GL::Camera &) = 0;
        virtual StereoCombiner *create_combiner(GL::View &) = 0;
index edbe08ae56e4ce9b0dcc833df9109b65d9ce9b85..b9515edcddb9ff8b9161dac229b62d080862d983 100644 (file)
@@ -121,6 +121,8 @@ OculusRiftCombiner::OculusRiftCombiner(OculusRiftDevice &d, GL::View &v):
        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
index 146f04a7c0ad32a12c94dead97ea46265bec34fa..efc0cfaaf4d0baba5a43d64834c4b885ef70afc7 100644 (file)
@@ -1,3 +1,4 @@
+#include <msp/graphics/display.h>
 #include <msp/vr/stereoview.h>
 #include "oculusriftdevice.h"
 #include "oculusriftdevice_private.h"
@@ -35,6 +36,25 @@ OculusRiftDevice::~OculusRiftDevice()
                ovr_Shutdown();
 }
 
+void OculusRiftDevice::configure_window(Graphics::Window &window) const
+{
+       Graphics::WindowOptions win_opts = window.get_options();
+       win_opts.width = priv->ovr_hmd->Resolution.w;
+       win_opts.height = priv->ovr_hmd->Resolution.h;
+
+       const list<Graphics::Monitor> &monitors = window.get_display().get_monitors();
+       string hmd_name = priv->ovr_hmd->ProductName;
+       for(list<Graphics::Monitor>::const_iterator i=monitors.begin(); i!=monitors.end(); ++i)
+               if(hmd_name.find(i->name)!=string::npos)
+               {
+                       win_opts.fullscreen = true;
+                       win_opts.fullscreen_monitor = &*i;
+                       win_opts.fullscreen_exclusive = false;
+               }
+
+       window.reconfigure(win_opts);
+}
+
 void OculusRiftDevice::configure_view(StereoView &view) const
 {
        ovrEyeRenderDesc left_desc = ovrHmd_GetRenderDesc(priv->ovr_hmd, ovrEye_Left, priv->ovr_hmd->DefaultEyeFov[ovrEye_Left]);
index 62cc0473bb6748895eebd9baf96bdcff0bf0c881..02f8016be36b2a0ee785ed060ad1f298cdb7f3b4 100644 (file)
@@ -26,6 +26,7 @@ public:
 
        const Private &get_private() const { return *priv; }
 
+       virtual void configure_window(Graphics::Window &) const;
        virtual void configure_view(StereoView &) const;
        virtual OculusRiftCamera *create_camera(const GL::Camera &);
        virtual OculusRiftCombiner *create_combiner(GL::View &);