bjornblissing / osgoculusviewer

An OsgViewer with support for the Oculus Rift
Other
106 stars 67 forks source link

Fix crash when no HMD plugged in. #75

Closed ChrisDenham closed 8 years ago

ChrisDenham commented 8 years ago

Since the 0.7.0.0 SDK no longer seems to support creating the debug emulated HMD when no device is present or detected, the viewer crashes because it proceeds without a valid device handle.

This change just allows the viewer to exit more cleanly when no HMD is plugged in.

bjornblissing commented 8 years ago

Well, this is probably the way to do it in pre 0.8.0.0.

But now I guess we should use the ovr_Detect function before even trying to initialize a OculusDevice object.

And then there is the ovr_GetSessionStatus function that could be used.

bjornblissing commented 8 years ago

And you can still use a debug device. But it is not possible to initialize it from code. Instead you have to use the Oculus Configuration Utility and go to the Tools -> Service -> Configure... menu. In this dialog you can choose you desired debug HMD type.

ChrisDenham commented 8 years ago

Ah, thanks, didn't know about the debug HUD config. Do you want me to change this pull request to use ovr_Detect? If ovr_Detect returned true but the ovr_Initialize or ovr_Create failed the viewer would still crash, so in a way, it seems safer the way I have done it?

bjornblissing commented 8 years ago

By using ovr_Detect we could spawn a standard osg viewer instead if no HMD or Debug-HMD are "connected". Your solution may still be valid. But should probably be modified to use the ovr_GetSessionStatus in the hmdDetected() function, instead of returning a value which only is set during initialization. By consequence the function should probably have a different name and possibly even a different return type.

I actually started working on a similar solution yesterday, but was unable to finish due to other work with higher priority.

ChrisDenham commented 8 years ago

OK, I'll wait for your fix. Closing this for now. Thanks.

bjornblissing commented 8 years ago

Fixed in #76