From a8f715e2795d459cdccd71a009b7da30f2b78f26 Mon Sep 17 00:00:00 2001 From: Matthew Endsley Date: Sat, 28 Mar 2015 17:34:47 -0700 Subject: [PATCH] Support Oculus SDK versions through 0.5.0.1-beta Tested against the following SDKs: - 0.5.0-beta - 0.4.4-beta - 0.4.3-beta - 0.4.2-beta - 0.4.1-beta - 0.4.0-beta --- scripts/genie.lua | 43 +++++++++++++++++++++++++++++++------------ src/ovr.cpp | 4 +++- src/ovr.h | 27 +++++++++++++++++++++++---- 3 files changed, 57 insertions(+), 17 deletions(-) diff --git a/scripts/genie.lua b/scripts/genie.lua index 4784b4db..31ad5f3a 100644 --- a/scripts/genie.lua +++ b/scripts/genie.lua @@ -158,23 +158,42 @@ function exampleProject(_name) "ws2_32", } - configuration { "x32" } - libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Win32", _ACTION) } + -- Check for LibOVR 5.0+ + if os.isdir(path.join(os.getenv("OVR_DIR"), "LibOVR/Lib/Windows/Win32/Debug/VS2012")) then - configuration { "x64" } - libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/x64", _ACTION) } + configuration { "x32", "Debug" } + libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/Win32/Debug", _ACTION) } - configuration { "x32", "Debug" } - links { "libovrd" } + configuration { "x32", "Release" } + libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/Win32/Release", _ACTION) } - configuration { "x32", "Release" } - links { "libovr" } + configuration { "x64", "Debug" } + libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/x64/Debug", _ACTION) } - configuration { "x64", "Debug" } - links { "libovr64d" } + configuration { "x64", "Release" } + libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/x64/Release", _ACTION) } - configuration { "x64", "Release" } - links { "libovr64" } + configuration { "x32 or x64" } + links { "libovr" } + else + configuration { "x32" } + libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Win32", _ACTION) } + + configuration { "x64" } + libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/x64", _ACTION) } + + configuration { "x32", "Debug" } + links { "libovrd" } + + configuration { "x32", "Release" } + links { "libovr" } + + configuration { "x64", "Debug" } + links { "libovr64d" } + + configuration { "x64", "Release" } + links { "libovr64" } + end configuration {} end diff --git a/src/ovr.cpp b/src/ovr.cpp index 732f750c..f86d69a3 100644 --- a/src/ovr.cpp +++ b/src/ovr.cpp @@ -123,7 +123,9 @@ namespace bgfx result = ovrHmd_ConfigureRendering(m_hmd , _config , 0 - | ovrDistortionCap_Chromatic +#if OVR_VERSION < OVR_VERSION_050 + | ovrDistortionCap_Chromatic // permanently enabled >= v5.0 +#endif | ovrDistortionCap_Vignette | ovrDistortionCap_TimeWarp | ovrDistortionCap_Overdrive diff --git a/src/ovr.h b/src/ovr.h index 34373feb..cf8d1c82 100644 --- a/src/ovr.h +++ b/src/ovr.h @@ -10,17 +10,28 @@ #if BGFX_CONFIG_USE_OVR -# include +# include # define OVR_VERSION_(_a, _b, _c) (_a * 10000 + _b * 100 + _c) # define OVR_VERSION OVR_VERSION_(OVR_MAJOR_VERSION, OVR_MINOR_VERSION, OVR_BUILD_VERSION) # define OVR_VERSION_042 OVR_VERSION_(0, 4, 2) # define OVR_VERSION_043 OVR_VERSION_(0, 4, 3) # define OVR_VERSION_044 OVR_VERSION_(0, 4, 4) +# define OVR_VERSION_050 OVR_VERSION_(0, 5, 0) + +# if OVR_VERSION < OVR_VERSION_050 +# include +# else +# include +# endif # if BGFX_CONFIG_RENDERER_DIRECT3D9 # define OVR_D3D_VERSION 9 -# include +# if OVR_VERSION < OVR_VERSION_050 +# include +# else +# include +# endif # endif // BGFX_CONFIG_RENDERER_DIRECT3D9 # if BGFX_CONFIG_RENDERER_DIRECT3D11 @@ -29,11 +40,19 @@ # undef OVR_D3D_VERSION # endif // OVR_CAPI_D3D_h # define OVR_D3D_VERSION 11 -# include +# if OVR_VERSION < OVR_VERSION_050 +# include +# else +# include +# endif # endif // BGFX_CONFIG_RENDERER_DIRECT3D11 # if BGFX_CONFIG_RENDERER_OPENGL -# include +# if OVR_VERSION < OVR_VERSION_050 +# include +# else +# include +# endif # endif // BGFX_CONFIG_RENDERER_OPENGL namespace bgfx