From 7ad8d41683649816d3d162f614dc8bb585053311 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 3 Oct 2016 17:43:43 +0300 Subject: [PATCH] Add query functions for whether certain features are supported System::set_absolute_tracking now has a default implementation which throws an exception. --- source/libovr/libovrsystem.cpp | 6 ------ source/libovr/libovrsystem.h | 1 - source/openvr/openvrcombiner.h | 1 + source/openvr/openvrsystem.cpp | 5 +++++ source/openvr/openvrsystem.h | 2 ++ source/stereocombiner.cpp | 3 +++ source/stereocombiner.h | 2 ++ source/system.cpp | 6 ++++++ source/system.h | 4 +++- 9 files changed, 22 insertions(+), 8 deletions(-) diff --git a/source/libovr/libovrsystem.cpp b/source/libovr/libovrsystem.cpp index 0136d49..c8183b0 100644 --- a/source/libovr/libovrsystem.cpp +++ b/source/libovr/libovrsystem.cpp @@ -65,12 +65,6 @@ void LibOVRSystem::configure_view(StereoView &view) const view.set_eye_matrices(GL::Matrix::translation(GL::Vector3(l.x, l.y, l.z)), GL::Matrix::translation(GL::Vector3(r.x, r.y, r.z))); } -void LibOVRSystem::set_absolute_tracking(bool a) -{ - if(a) - throw invalid_argument("absolute tracking not supported"); -} - LibOVRCamera *LibOVRSystem::create_camera(const GL::Camera &bc) { return new LibOVRCamera(*this, bc); diff --git a/source/libovr/libovrsystem.h b/source/libovr/libovrsystem.h index a7978e4..d5623a0 100644 --- a/source/libovr/libovrsystem.h +++ b/source/libovr/libovrsystem.h @@ -28,7 +28,6 @@ public: virtual void configure_window(Graphics::Window &) const; virtual void configure_view(StereoView &) const; - virtual void set_absolute_tracking(bool); virtual LibOVRCamera *create_camera(const GL::Camera &); virtual LibOVRCombiner *create_combiner(GL::View &); diff --git a/source/openvr/openvrcombiner.h b/source/openvr/openvrcombiner.h index 94ccce3..5b9e3b4 100644 --- a/source/openvr/openvrcombiner.h +++ b/source/openvr/openvrcombiner.h @@ -20,6 +20,7 @@ private: public: OpenVRCombiner(OpenVRSystem &, GL::View &); + virtual bool is_mirroring_supported() const { return true; } virtual void prepare() const; virtual void render(const GL::Texture2D &, const GL::Texture2D &) const; }; diff --git a/source/openvr/openvrsystem.cpp b/source/openvr/openvrsystem.cpp index c137400..50d2ecf 100644 --- a/source/openvr/openvrsystem.cpp +++ b/source/openvr/openvrsystem.cpp @@ -79,6 +79,11 @@ void OpenVRSystem::set_absolute_tracking(bool a) vr::VRCompositor()->SetTrackingSpace(a ? vr::TrackingUniverseStanding : vr::TrackingUniverseSeated); } +bool OpenVRSystem::get_absolute_tracking() const +{ + return vr::VRCompositor()->GetTrackingSpace()==vr::TrackingUniverseStanding; +} + OpenVRCamera *OpenVRSystem::create_camera(const GL::Camera &bc) { return new OpenVRCamera(*this, bc); diff --git a/source/openvr/openvrsystem.h b/source/openvr/openvrsystem.h index 4988659..06881f8 100644 --- a/source/openvr/openvrsystem.h +++ b/source/openvr/openvrsystem.h @@ -24,7 +24,9 @@ public: virtual void configure_window(Graphics::Window &) const { } virtual void configure_view(StereoView &) const; + virtual bool is_absolute_tracking_supported() const { return true; } virtual void set_absolute_tracking(bool); + virtual bool get_absolute_tracking() const; virtual OpenVRCamera *create_camera(const GL::Camera &); virtual OpenVRCombiner *create_combiner(GL::View &); diff --git a/source/stereocombiner.cpp b/source/stereocombiner.cpp index ebb888e..34c13bd 100644 --- a/source/stereocombiner.cpp +++ b/source/stereocombiner.cpp @@ -51,6 +51,9 @@ void StereoCombiner::configure_eye_frustums(const Frustum &left_frustum, const F void StereoCombiner::set_mirroring(bool m) { + if(m && !is_mirroring_supported()) + throw runtime_error("mirroring not supported"); + if(m && !mirror) mirror = new MirrorView; else if(!m && mirror) diff --git a/source/stereocombiner.h b/source/stereocombiner.h index 2cfe3eb..88f979c 100644 --- a/source/stereocombiner.h +++ b/source/stereocombiner.h @@ -53,7 +53,9 @@ public: const Geometry::Angle &get_field_of_view() const { return fov; } float get_frustum_skew() const { return frustum_skew; } + virtual bool is_mirroring_supported() const { return false; } void set_mirroring(bool); + bool get_mirroring() const { return mirror; } virtual void prepare() const { } virtual void render(const GL::Texture2D &, const GL::Texture2D &) const = 0; diff --git a/source/system.cpp b/source/system.cpp index c835456..b4105b0 100644 --- a/source/system.cpp +++ b/source/system.cpp @@ -51,5 +51,11 @@ System *System::create_autodetect() return 0; } +void System::set_absolute_tracking(bool a) +{ + if(a) + throw invalid_argument("absolute tracking not supported"); +} + } // namespace VR } // namespace Msp diff --git a/source/system.h b/source/system.h index f7e28b5..69b93a1 100644 --- a/source/system.h +++ b/source/system.h @@ -24,7 +24,9 @@ public: virtual void configure_window(Graphics::Window &) const = 0; virtual void configure_view(StereoView &) const = 0; - virtual void set_absolute_tracking(bool) = 0; + virtual bool is_absolute_tracking_supported() const { return false; } + virtual void set_absolute_tracking(bool); + virtual bool get_absolute_tracking() const { return false; } virtual HeadTrackingCamera *create_camera(const GL::Camera &) = 0; virtual StereoCombiner *create_combiner(GL::View &) = 0; }; -- 2.45.2