This website uses cookies to improve our services and deliver relevant ads.
By interacting with this site, you agree to this use. For more information, see our Cookies Policy
This topic describes how to support apps that can be launched in a non-VR desktop modes.
There are three methods for delivering apps that have both VR and desktop modes:
For apps that use the Select at Startup method:
For apps that use Multiple binaries:
For apps that use runtime mode switching, upload as a regular Rift build.
To support the Select at Startup method, ship a single executable file that toggles between VR and desktop mode at startup, based on the availability of a working VR headset and command line parameters.
Sample startup code and logic
The common logic for this startup method is as follows:
The following samples describe how to detect if a VR headset is available in Unity, Unreal, and native C++ applications.
In Unity, the command line option -vrmode none disables VR. The variable VRSettings.enabled indicates whether VR is running and the variable VRSettings.loadedDevice indicates whether the VR headset is available. Putting these components together gives us a way to check if the game should start in VR or desktop mode.
private static bool CheckForVRDevice()
{
bool isVR = false;
if (VRSettings.enabled)
{
// VR is enabled, make sure the device is available
if (VRSettings.loadedDevice == VRDeviceType.Oculus)
{
// VR is enabled and we have a connected VR device.
// go forward with VR!
isVR = true;
}
else
{
// no loaded device, so turn VR support off
VRSettings.enabled = false;
}
}
return isVR;
}In Unreal Engine apps, you can activate VR mode by passing the command line option -vr at launch, or by setting the value of the ConsoleVariables.ini variable vr.BStartInVR to 1. To activate desktop mode, use the command line option -nohmd. GEngine->HMDDevice->IsHMDConnected() indicates whether the VR headset is available. GEngine->HMDDevice.IsValid() indicates whether the app was started in VR mode.
bool CheckForVRDevice() }
In the Oculus PC SDK, the function ovr_Create() returns false if the VR headset is not available.
#include <OVR_CAPI.h>
void Application()
{
ovrResult result = ovr_Initialize(nullptr);
if (OVR_FAILURE(result))
{
return;
}
ovrSession session;
bool isVR = YourArgumentCheckHere("-vrmode", "none");
if (isVR)
{
// expecting VR mode, but need a valid device.
ovrGraphicsLuid luid;
result = ovr_Create(&session, &luid);
if (OVR_FAILURE(result))
{
// no headset connected, fall back to Desktop mode.
isVR = false;
}
}
// run game loop here
RunGameLoop(isVR);
if (isVR)
{
ovr_Destroy(session);
}
ovr_Shutdown();
}