Don't crash when the Rift is turned off

This commit is contained in:
Bradley Austin Davis 2016-03-16 20:06:22 -07:00
parent 1240f144d4
commit 384351067e
2 changed files with 16 additions and 9 deletions

View file

@ -106,11 +106,19 @@ public:
if (_newPlugin != nullptr) {
// Deactivate the old plugin
if (currentPlugin != nullptr) {
currentPlugin->uncustomizeContext();
try {
currentPlugin->uncustomizeContext();
} catch (const oglplus::Error& error) {
qWarning() << "OpenGL error in uncustomizeContext: " << error.what();
}
currentPlugin->enableDeactivate();
}
_newPlugin->customizeContext();
try {
_newPlugin->customizeContext();
} catch (const oglplus::Error& error) {
qWarning() << "OpenGL error in customizeContext: " << error.what();
}
currentPlugin = _newPlugin;
_newPlugin = nullptr;
}
@ -127,7 +135,11 @@ public:
// take the latest texture and present it
_context->makeCurrent();
if (isCurrentContext(_context->contextHandle())) {
currentPlugin->present();
try {
currentPlugin->present();
} catch (const oglplus::Error& error) {
qWarning() << "OpenGL error in presentation: " << error.what();
}
_context->doneCurrent();
} else {
qWarning() << "Makecurrent failed";

View file

@ -74,7 +74,7 @@ void OculusBaseDisplayPlugin::activate() {
if (!OVR_SUCCESS(ovr_ConfigureTracking(_session,
ovrTrackingCap_Orientation | ovrTrackingCap_Position | ovrTrackingCap_MagYawCorrection, 0))) {
qFatal("Could not attach to sensor device");
qWarning() << "Could not attach to sensor device";
}
// Parent class relies on our _session intialization, so it must come after that.
@ -87,11 +87,6 @@ void OculusBaseDisplayPlugin::activate() {
_sceneLayer.Viewport[eye].Pos = { eye == ovrEye_Left ? 0 : size.w, 0 };
});
if (!OVR_SUCCESS(ovr_ConfigureTracking(_session,
ovrTrackingCap_Orientation | ovrTrackingCap_Position | ovrTrackingCap_MagYawCorrection, 0))) {
qFatal("Could not attach to sensor device");
}
// This must come after the initialization, so that the values calculated
// above are available during the customizeContext call (when not running
// in threaded present mode)