From: Mikko Rasa Date: Fri, 16 Sep 2016 23:48:35 +0000 (+0300) Subject: Automatically configure the window to cover the Rift's monitor X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=a7cabd8db417583e7d31349ddecb0bee86d624cb;p=libs%2Fvr.git Automatically configure the window to cover the Rift's monitor --- diff --git a/source/displaydevice.h b/source/displaydevice.h index cc015a8..665ac85 100644 --- a/source/displaydevice.h +++ b/source/displaydevice.h @@ -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; diff --git a/source/ovr/oculusriftcombiner.cpp b/source/ovr/oculusriftcombiner.cpp index edbe08a..b9515ed 100644 --- a/source/ovr/oculusriftcombiner.cpp +++ b/source/ovr/oculusriftcombiner.cpp @@ -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 diff --git a/source/ovr/oculusriftdevice.cpp b/source/ovr/oculusriftdevice.cpp index 146f04a..efc0cfa 100644 --- a/source/ovr/oculusriftdevice.cpp +++ b/source/ovr/oculusriftdevice.cpp @@ -1,3 +1,4 @@ +#include #include #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 &monitors = window.get_display().get_monitors(); + string hmd_name = priv->ovr_hmd->ProductName; + for(list::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]); diff --git a/source/ovr/oculusriftdevice.h b/source/ovr/oculusriftdevice.h index 62cc047..02f8016 100644 --- a/source/ovr/oculusriftdevice.h +++ b/source/ovr/oculusriftdevice.h @@ -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 &);