#include "vr_base.h" #include "VrApi_Types.h" #if __ANDROID__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wstrict-prototypes" #include #pragma clang diagnostic pop #include #include static engine_t vr_engine; engine_t* VR_Init( ovrJava java ) { ovrInitParms initParams; ovrResult initResult; memset(&vr_engine, 0, sizeof(vr_engine)); initParams = vrapi_DefaultInitParms(&java); initResult = vrapi_Initialize(&initParams); assert(initResult == VRAPI_INITIALIZE_SUCCESS); return &vr_engine; } void VR_Destroy( engine_t* engine ) { if (engine == &vr_engine) { vrapi_Shutdown(); } } void VR_EnterVR( engine_t* engine, ovrJava java ) { if (!engine->ovr) { ovrModeParms modeParams = vrapi_DefaultModeParms(&java); modeParams.Display = (size_t)eglGetCurrentDisplay(); modeParams.WindowSurface = (size_t)eglGetCurrentSurface(EGL_DRAW); modeParams.ShareContext = (size_t)eglGetCurrentContext(); engine->ovr = vrapi_EnterVrMode(&modeParams); engine->frameIndex = 0; vrapi_SetTrackingSpace(engine->ovr, VRAPI_TRACKING_SPACE_LOCAL); } } void VR_LeaveVR( engine_t* engine ) { if (engine->ovr) { vrapi_LeaveVrMode(engine->ovr); engine->ovr = NULL; } } engine_t* VR_GetEngine( void ) { return &vr_engine; } #endif