Exemplo n.º 1
0
	DLL_EXPORT_API int xnOvrGetError(char* errorString)
	{
		ovrErrorInfo errInfo;
		ovr_GetLastErrorInfo(&errInfo);
		strcpy(errorString, errInfo.ErrorString);
		return errInfo.Result;
	}
Exemplo n.º 2
0
bool OculusBaseDisplayPlugin::isSupported() const {
    if (!OVR_SUCCESS(ovr_Initialize(nullptr))) {
        return false;
    }

    ovrSession session { nullptr };
    ovrGraphicsLuid luid;
    auto result = ovr_Create(&session, &luid);
    if (!OVR_SUCCESS(result)) {
        ovrErrorInfo error;
        ovr_GetLastErrorInfo(&error);
        ovr_Shutdown();
        return false;
    }

    auto hmdDesc = ovr_GetHmdDesc(session);
    if (hmdDesc.Type == ovrHmd_None) {
        ovr_Destroy(session);
        ovr_Shutdown();
        return false;
    }

    ovr_Shutdown();
    return true;
}
Exemplo n.º 3
0
void OculusWindow::init_context() {

    WindowBase::init_context();

    auto const& glapi = ctx_.render_context->opengl_api();

    glapi.glGenFramebuffers(1, &blit_fbo_read_);
    glapi.glGenFramebuffers(1, &blit_fbo_write_);

    ovrSizei recommended_size_r = ovr_GetFovTextureSize(hmd_session_, ovrEye_Left, hmd_desc_.DefaultEyeFov[ovrEye_Left], 1.0f);
    ovrSizei recommended_size_l = ovr_GetFovTextureSize(hmd_session_, ovrEye_Right, hmd_desc_.DefaultEyeFov[ovrEye_Right], 1.0f);

    texture_swap_chain_desc_.Type = ovrTexture_2D;
    texture_swap_chain_desc_.ArraySize = 1;
    texture_swap_chain_desc_.Width = recommended_size_l.w + recommended_size_r.w;
    texture_swap_chain_desc_.Height = recommended_size_l.h;
    texture_swap_chain_desc_.MipLevels = 1;
    texture_swap_chain_desc_.Format = OVR_FORMAT_R8G8B8A8_UNORM_SRGB;
    texture_swap_chain_desc_.SampleCount = 1;
    texture_swap_chain_desc_.StaticImage = ovrFalse;

    auto result = ovr_CreateTextureSwapChainGL(hmd_session_, &texture_swap_chain_desc_, &texture_swap_chain_);
    if (result != ovrSuccess)
    {
        ovrErrorInfo info;
        ovr_GetLastErrorInfo(&info);
        gua::Logger::LOG_WARNING << "Failed to create swap textures for Oculus Rift.\n" << "Error Code: " << info.ErrorString << std::endl;
    }

    color_layer_.ColorTexture[0] = texture_swap_chain_;
    color_layer_.ColorTexture[1] = texture_swap_chain_;

}
Exemplo n.º 4
0
void VR::init()
{
#if defined(_OVR_)
	ovrInitParams initParams = { ovrInit_RequestVersion, OVR_MINOR_VERSION, NULL, 0, 0 };
	ovrResult result = ovr_Initialize(&initParams);
	if (OVR_FAILURE(result)) {
		ovrErrorInfo errorInfo;
		ovr_GetLastErrorInfo(&errorInfo);
		Log(L"ovr_Initialize failed: " << errorInfo.ErrorString << endl);
		Error(L"ovr_Initialize failed");
		return;
	}
	Log("LibOVR initialized ok!" << endl);
	result = ovr_Create(&session, &luid);
	if (OVR_FAILURE(result))
	{
		ovr_Shutdown();
		Error(L"No Oculus Rift detected. Cannot run in OVR mode without Oculus Rift device.");
		return;
	}

	desc = ovr_GetHmdDesc(session);
	resolution = desc.Resolution;
	// Start the sensor which provides the Rift’s pose and motion.
/*	result = ovr_ConfigureTracking(session, ovrTrackingCap_Orientation |
		ovrTrackingCap_MagYawCorrection |
		ovrTrackingCap_Position, 0);
	if (OVR_FAILURE(result)) Error(L"Could not enable Oculus Rift Tracking. Cannot run in OVR mode without Oculus Rift tracking.");
	*/
	// Setup VR components, filling out description
	eyeRenderDesc[0] = ovr_GetRenderDesc(session, ovrEye_Left, desc.DefaultEyeFov[0]);
	eyeRenderDesc[1] = ovr_GetRenderDesc(session, ovrEye_Right, desc.DefaultEyeFov[1]);

	nextTracking();

	// tracking setup complete, now init rendering:

	// Configure Stereo settings.
	Sizei recommenedTex0Size = ovr_GetFovTextureSize(session, ovrEye_Left, desc.DefaultEyeFov[0], 1.0f);
	Sizei recommenedTex1Size = ovr_GetFovTextureSize(session, ovrEye_Right, desc.DefaultEyeFov[1], 1.0f);
	buffersize_width = recommenedTex0Size.w + recommenedTex1Size.w;
	buffersize_height = max(recommenedTex0Size.h, recommenedTex1Size.h);
	result = ovr_RequestBoundaryVisible(session, ovrTrue);
	if (OVR_FAILURE(result)) {
		Log(L"Oculus Boundary system inactive.");
	}
	else {
		Log(L"Oculus Boundary system activated!!");
	}
#endif
}
Exemplo n.º 5
0
inline ovrErrorInfo getError() {
    ovrErrorInfo error;
    ovr_GetLastErrorInfo(&error);
    return error;
}