diff --git a/applications/gui/src/camera.cpp b/applications/gui/src/camera.cpp index e8a0c80aa8cbe3e90619297a78d2fde7efa7e75b..0a9d04c044e70b615f24733380818ff1a46a1739 100644 --- a/applications/gui/src/camera.cpp +++ b/applications/gui/src/camera.cpp @@ -268,7 +268,6 @@ bool ftl::gui::Camera::setVR(bool on) { src_->set("focal", intrinsic(0, 0)); src_->set("centre_x", intrinsic(0, 2)); src_->set("centre_y", intrinsic(1, 2)); - LOG(INFO) << intrinsic; intrinsic = getCameraMatrix(screen_->getVR(), vr::Eye_Right); CHECK(intrinsic(0, 2) < 0 && intrinsic(1, 2) < 0); @@ -376,8 +375,9 @@ const GLTexture &ftl::gui::Camera::captureFrame() { if (src_ && src_->isReady()) { UNIQUE_LOCK(mutex_, lk); - if (isVR()) { + if (screen_->isVR()) { #ifdef HAVE_OPENVR + vr::VRCompositor()->WaitGetPoses(rTrackedDevicePose_, vr::k_unMaxTrackedDeviceCount, NULL, 0 ); if ((channel_ == Channel::Right) && rTrackedDevicePose_[vr::k_unTrackedDeviceIndex_Hmd].bPoseIsValid ) diff --git a/applications/gui/src/media_panel.cpp b/applications/gui/src/media_panel.cpp index c04552fcd2207971e12e9b8e49a04491629ea63f..142eb9c93a42c4b9403596c78fd31eedbd289bfe 100644 --- a/applications/gui/src/media_panel.cpp +++ b/applications/gui/src/media_panel.cpp @@ -145,11 +145,11 @@ MediaPanel::MediaPanel(ftl::gui::Screen *screen) : nanogui::Window(screen, ""), */ #ifdef HAVE_OPENVR - if (this->screen_->hasVR()) { + if (this->screen_->isHmdPresent()) { auto button_vr = new Button(this, "VR"); button_vr->setFlags(Button::ToggleButton); button_vr->setChangeCallback([this, button_vr](bool state) { - if (!screen_->useVR()) { + if (!screen_->isVR()) { if (screen_->switchVR(true) == true) { button_vr->setTextColor(nanogui::Color(0.5f,0.5f,1.0f,1.0f)); this->button_channels_->setEnabled(false); diff --git a/applications/gui/src/screen.cpp b/applications/gui/src/screen.cpp index 7d282501da7a445023b2e177925dd9903de5f92f..76665281fc1b9fcbb1b0b45609c509d02f88a69d 100644 --- a/applications/gui/src/screen.cpp +++ b/applications/gui/src/screen.cpp @@ -68,7 +68,6 @@ ftl::gui::Screen::Screen(ftl::Configurable *proot, ftl::net::Universe *pnet, ftl #ifdef HAVE_OPENVR HMD_ = nullptr; - has_vr_ = vr::VR_IsHmdPresent(); #endif zoom_ = root_->value("zoom", 1.0f); @@ -321,14 +320,14 @@ bool ftl::gui::Screen::initVR() { return true; } -bool ftl::gui::Screen::useVR() { +bool ftl::gui::Screen::isVR() { auto *cam = activeCamera(); if (HMD_ == nullptr || cam == nullptr) { return false; } return cam->isVR(); } bool ftl::gui::Screen::switchVR(bool on) { - if (useVR() == on) { return on; } + if (isVR() == on) { return on; } if (on && (HMD_ == nullptr) && !initVR()) { return false; @@ -340,8 +339,13 @@ bool ftl::gui::Screen::switchVR(bool on) { activeCamera()->setVR(false); } - return useVR(); + return isVR(); } + +bool ftl::gui::Screen::isHmdPresent() { + return vr::VR_IsHmdPresent(); +} + #endif ftl::gui::Screen::~Screen() { @@ -520,7 +524,7 @@ void ftl::gui::Screen::draw(NVGcontext *ctx) { if (camera_->getChannel() != ftl::codecs::Channel::Left) { mImageID = rightEye_; } #ifdef HAVE_OPENVR - if (useVR() && imageSize[0] > 0 && camera_->getLeft().isValid() && camera_->getRight().isValid()) { + if (isVR() && imageSize[0] > 0 && camera_->getLeft().isValid() && camera_->getRight().isValid()) { vr::Texture_t leftEyeTexture = {(void*)(uintptr_t)leftEye_, vr::TextureType_OpenGL, vr::ColorSpace_Gamma }; vr::VRCompositor()->Submit(vr::Eye_Left, &leftEyeTexture ); diff --git a/applications/gui/src/screen.hpp b/applications/gui/src/screen.hpp index 1a9ea2aa396958c328dc4ae9e309bd6346422fac..90cd519bb3681126f4dc4f0d258e342953562433 100644 --- a/applications/gui/src/screen.hpp +++ b/applications/gui/src/screen.hpp @@ -48,19 +48,18 @@ class Screen : public nanogui::Screen { // initialize OpenVR bool initVR(); - // is VR available (HMD was found at initialization) - bool hasVR() const { return has_vr_; } - // is VR mode on/off - bool useVR(); + bool isVR(); // toggle VR on/off bool switchVR(bool mode); + bool isHmdPresent(); + vr::IVRSystem* getVR() { return HMD_; } #else - bool hasVR() const { return false; } + bool isVR() { return false; } #endif nanogui::Theme *windowtheme; @@ -105,7 +104,6 @@ class Screen : public nanogui::Screen { ftl::Configurable *shortcuts_; #ifdef HAVE_OPENVR - bool has_vr_; vr::IVRSystem *HMD_; #endif };