Browse Source

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
Matthew Endsley 10 years ago
parent
commit
a8f715e279
3 changed files with 57 additions and 17 deletions
  1. 31 12
      scripts/genie.lua
  2. 3 1
      src/ovr.cpp
  3. 23 4
      src/ovr.h

+ 31 - 12
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

+ 3 - 1
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

+ 23 - 4
src/ovr.h

@@ -10,17 +10,28 @@
 
 #if BGFX_CONFIG_USE_OVR
 
-#	include <OVR.h>
+#	include <OVR_Version.h>
 
 #	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 <OVR.h>
+#	else
+#		include <OVR_CAPI.h>
+#	endif
 
 #	if BGFX_CONFIG_RENDERER_DIRECT3D9
 #		define OVR_D3D_VERSION 9
-#		include <OVR_D3D.h>
+#		if OVR_VERSION < OVR_VERSION_050
+#			include <OVR_D3D.h>
+#		else
+#			include <OVR_CAPI_D3D.h>
+#		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 <OVR_D3D.h>
+#		if OVR_VERSION < OVR_VERSION_050
+#			include <OVR_D3D.h>
+#		else
+#			include <OVR_CAPI_D3D.h>
+#		endif
 #	endif // BGFX_CONFIG_RENDERER_DIRECT3D11
 
 #	if BGFX_CONFIG_RENDERER_OPENGL
-#		include <OVR_GL.h>
+#		if OVR_VERSION < OVR_VERSION_050
+#			include <OVR_GL.h>
+#		else
+#			include <OVR_CAPI_GL.h>
+#		endif
 #	endif // BGFX_CONFIG_RENDERER_OPENGL
 
 namespace bgfx