Don't crash on OpenVR activation when SteamVR isn't running

This commit is contained in:
Brad Davis 2016-10-12 23:57:42 -07:00
parent 90b283f83b
commit d4e83a7461

View file

@ -377,9 +377,6 @@ void OpenVrDisplayPlugin::init() {
}
bool OpenVrDisplayPlugin::internalActivate() {
_openVrDisplayActive = true;
_container->setIsOptionChecked(StandingHMDSensorMode, true);
if (!_system) {
_system = acquireOpenVrSystem();
}
@ -388,6 +385,18 @@ bool OpenVrDisplayPlugin::internalActivate() {
return false;
}
// If OpenVR isn't running, then the compositor won't be accessible
// FIXME find a way to launch the compositor?
if (!vr::VRCompositor()) {
qWarning() << "Failed to acquire OpenVR compositor";
releaseOpenVrSystem();
_system = nullptr;
return false;
}
_openVrDisplayActive = true;
_container->setIsOptionChecked(StandingHMDSensorMode, true);
_system->GetRecommendedRenderTargetSize(&_renderTargetSize.x, &_renderTargetSize.y);
// Recommended render target size is per-eye, so double the X size for
// left + right eyes