这是Oculus街景项目......我正在努力理解和运行,但我无法做到......请帮帮我
// dllmain.cpp:定义DLL应用程序的入口点。
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { 开关(ul_reason_for_call) { case DLL_PROCESS_ATTACH: 案例DLL_THREAD_ATTACH: 案例DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: 打破; } 返回TRUE; }
#include "libovrwrapper.h"
#include <OVR.h>
using namespace OVR;
// Ptr<> AddRef'ed, AutoCleaned
bool bInited = false;
Ptr<DeviceManager> pManager;
Ptr<HMDDevice> pHMD;
Ptr<SensorDevice> pSensor;
SensorFusion pSensorFusion;
LIBOVRWRAPPER_API int OVR_Init()
{
bInited = false;
System::Init(Log::ConfigureDefaultLog(LogMask_Regular));
if (System::IsInitialized())
{
int stage = -1;
while (++stage > -1 && !bInited)
{
switch (stage)
{
case 0:
pManager = *DeviceManager::Create();
if (pManager == NULL)
return bInited;
break;
case 1:
pHMD = *pManager->EnumerateDevices<HMDDevice>().CreateDevice();
if (pHMD == NULL)
return bInited;
break;
case 2:
pSensor = *pHMD->GetSensor();
if (pSensor == NULL)
return bInited;
break;
default:
bInited = true;
break;
};
}
}
pSensorFusion.AttachToSensor(pSensor);
return (bInited?1:0);
}
LIBOVRWRAPPER_API void OVR_Exit()
{
if (bInited)
{
System::Destroy();
}
}
LIBOVRWRAPPER_API int OVR_QueryHMD(OVR_HMDInfo* refHmdInfo)
{
if (!bInited)
{
return 0;
}
HMDInfo src;
if (pHMD->GetDeviceInfo(&src))
{
refHmdInfo->HResolution = src.HResolution;
refHmdInfo->VResolution = src.VResolution;
refHmdInfo->HScreenSize = src.HScreenSize;
refHmdInfo->VScreenSize = src.VScreenSize;
refHmdInfo->VScreenCenter = src.VScreenCenter;
refHmdInfo->EyeToScreenDistance = src.EyeToScreenDistance;
refHmdInfo->LensSeparationDistance = src.LensSeparationDistance;
refHmdInfo->InterpupillaryDistance = src.InterpupillaryDistance;
refHmdInfo->DistortionK[0] = src.DistortionK[0];
refHmdInfo->DistortionK[1] = src.DistortionK[1];
refHmdInfo->DistortionK[2] = src.DistortionK[2];
refHmdInfo->DistortionK[3] = src.DistortionK[3];
refHmdInfo->DesktopX = src.DesktopX;
refHmdInfo->DesktopY = src.DesktopY;
memcpy(refHmdInfo->DisplayDeviceName, src.DisplayDeviceName, sizeof(refHmdInfo->DisplayDeviceName));
}
return 1;
}
LIBOVRWRAPPER_API int OVR_PeekYPL(float* yaw, float* pitch, float* roll)
{
if (!bInited)
{
return 0;
}
Quatf hmdOrient = pSensorFusion.GetOrientation();
hmdOrient.GetEulerAngles<Axis_Y, Axis_X, Axis_Z>(yaw, pitch, roll);
return 1;
}
LIBOVRWRAPPER_API int OVR_Peek(float* w, float* x, float* y,float * z)
{
if (!bInited)
{
return 0;
}
Quatf hmdOrient = pSensorFusion.GetOrientation();
*w = hmdOrient.w;
*x = hmdOrient.x;
*y = hmdOrient.y;
*z = hmdOrient.z;
//hmdOrient.GetEulerAngles<Axis_Y, Axis_X, Axis_Z>(yaw, pitch, roll);
return 1;
}
#ifdef LIBOVRWRAPPER_EXPORTS
#if defined __cplusplus
#define LIBOVRWRAPPER_API extern "C" __declspec(dllexport)
#else
#define LIBOVRWRAPPER_API __declspec(dllexport)
#endif
#else
#if defined __cplusplus
#define LIBOVRWRAPPER_API extern "C" __declspec(dllimport)
#else
#define LIBOVRWRAPPER_API __declspec(dllimport)
#endif
#endif
struct OVR_HMDInfo
{
unsigned HResolution;
unsigned VResolution;
float HScreenSize;
float VScreenSize;
float VScreenCenter;
float EyeToScreenDistance;
float LensSeparationDistance;
float InterpupillaryDistance;
float DistortionK[4];
int DesktopX;
int DesktopY;
char DisplayDeviceName[32];
};
LIBOVRWRAPPER_API int OVR_Init();
LIBOVRWRAPPER_API void OVR_Exit();
LIBOVRWRAPPER_API int OVR_QueryHMD(struct OVR_HMDInfo* refHmdInfo);
LIBOVRWRAPPER_API int OVR_Peek(float* w, float* x, float* y,float * z);
LIBOVRWRAPPER_API int OVR_PeekYPL(float* yaw, float* pitch, float* roll);
答案 0 :(得分:0)
您的问题很难理解,因为它没有任何关于您尝试过的内容,哪些内容不起作用的真实细节等。
看起来你正试图“运行”一个DLL,这是不可能的。 DLL必须由另一个应用程序加载。所以你会有一个可加载这个DLL的可执行文件,并调用它的OVR_Init和OVR_Exit函数。