目标是生成一个exe文件, 打开VR设备, 打开后, 这个exe就执行结束了, 但VR设备还处于运行状态git
并无指定哪一种VR设备, 但打开当前的SteamVR - HTC VIVEgithub
记录项目配置:shell
VS2010api
附加包含目录:app
C:\OSG64\openvr108\headers;ui
附加库目录:this
C:\OSG64\openvr108\lib\win64;spa
附加依赖项:code
openvr_api.lib
glu32.lib
opengl32.lib
kernel32.lib
user32.lib
gdi32.lib
winspool.lib
comdlg32.lib
advapi32.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
odbc32.lib
odbccp32.lib文档
代码:
#include "main.h"// 只不过为了VS2010不报错
#include<openvr.h>
int main()
{
vr::EVRApplicationType _type = vr::EVRApplicationType::VRApplication_Scene;
vr::HmdError *peError =new vr::HmdError;
vr::VR_Init(peError, _type );
}
相关文档的内容:
Because the OpenVR API causes the game to connect to any attached VR hardware, it is not initialized automatically. To initialize the API and get access to the vr::IVRSystem interface call the vr::VR_Init function. To close down your connection to the hardware and release your vr::IVRSystem interface, call vr::VR_Shutdown.
vr::IVRSystem *vr::VR_Init( vr::
HmdError
*peError, vr::EVRApplicationType eApplicationType )
eApplicationType must be one of:
VRApplication_Scene
- A 3D application that will be drawing an environment.VRApplication_Overlay
- An application that only interacts with overlays or the dashboard.VRApplication_Background
- The application will not start SteamVR. If it is not already running the call with VR_Init will fail with VRInitError_Init_NoServerForBackgroundApp
.VRApplication_Utility
- The application will start up even if no hardware is present. Only the IVRSettings and IVRApplications interfaces are guaranteed to work. This application type is appropriate for things like installers.The call will return a vr::IVRSystem pointer that allows the game to call other OpenVR API methods. If something fails the call will return NULL and peError will be set to an error code that indicates what the problem was. peError - The error code that occurred or vr::VRInitError_None if there was no error. See vr::HmdError
for possible error codes.
void vr::VR_Shutdown()
Shuts down the connection to the VR hardware and cleans up the OpenVR API. The vr::IVRSystem pointer returned by vr::VR_Init will be invalid after this call is made.