├── .gitignore
├── README.md
├── example-OculusRiftRendering
├── Makefile
├── OculusRenderingBasic.sln
├── OculusRenderingBasic.vcxproj
├── OculusRenderingBasic.vcxproj.filters
├── OculusRenderingBasic.vcxproj.user
├── OculusRenderingBasic.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── andreasmuller.xcuserdatad
│ │ │ ├── UserInterfaceState.xcuserstate
│ │ │ └── WorkspaceSettings.xcsettings
│ └── xcuserdata
│ │ └── andreasmuller.xcuserdatad
│ │ └── xcschemes
│ │ ├── OculusRiftBasic.xcscheme
│ │ └── xcschememanagement.plist
├── Project.xcconfig
├── addons.make
├── bin
│ └── data
│ │ ├── .gitkeep
│ │ ├── Fonts
│ │ └── DIN.otf
│ │ └── Shaders
│ │ ├── HmdWarpDK2.frag
│ │ ├── HmdWarpDK2.vert
│ │ └── HmdWarpDK2_simple.vert
├── icon.aps
├── icon.rc
├── openFrameworks-Info.plist
└── src
│ ├── main.cpp
│ ├── testApp.cpp
│ └── testApp.h
├── libs
├── 3rdParty
│ └── TinyXml
│ │ ├── tinyxml2.cpp
│ │ └── tinyxml2.h
└── LibOVR
│ ├── Include
│ ├── OVR.h
│ ├── OVR_Kernel.h
│ └── OVR_Version.h
│ ├── Lib
│ ├── MacOS
│ │ ├── Debug
│ │ │ └── libovr.a
│ │ ├── Debug32
│ │ │ └── libovr.a
│ │ ├── Release
│ │ │ └── libovr.a
│ │ └── Release32
│ │ │ └── libovr.a
│ └── x64
│ │ ├── VS2010
│ │ ├── libovr64.lib
│ │ └── libovr64d.lib
│ │ ├── VS2012
│ │ ├── libovr64.lib
│ │ └── libovr64d.lib
│ │ └── VS2013
│ │ ├── libovr64.lib
│ │ └── libovr64d.lib
│ └── Src
│ ├── CAPI
│ ├── CAPI_DistortionRenderer.cpp
│ ├── CAPI_DistortionRenderer.h
│ ├── CAPI_FrameTimeManager.cpp
│ ├── CAPI_FrameTimeManager.h
│ ├── CAPI_HMDRenderState.cpp
│ ├── CAPI_HMDRenderState.h
│ ├── CAPI_HMDState.cpp
│ ├── CAPI_HMDState.h
│ ├── CAPI_HSWDisplay.cpp
│ ├── CAPI_HSWDisplay.h
│ ├── D3D1X
│ │ ├── CAPI_D3D10_DistortionRenderer.cpp
│ │ ├── CAPI_D3D10_DistortionRenderer.h
│ │ ├── CAPI_D3D10_HSWDisplay.cpp
│ │ ├── CAPI_D3D10_HSWDisplay.h
│ │ ├── CAPI_D3D11_DistortionRenderer.cpp
│ │ ├── CAPI_D3D11_DistortionRenderer.h
│ │ ├── CAPI_D3D11_HSWDisplay.cpp
│ │ ├── CAPI_D3D11_HSWDisplay.h
│ │ ├── CAPI_D3D1X_DistortionRenderer.cpp
│ │ ├── CAPI_D3D1X_DistortionRenderer.h
│ │ ├── CAPI_D3D1X_HSWDisplay.cpp
│ │ ├── CAPI_D3D1X_HSWDisplay.h
│ │ ├── CAPI_D3D1X_Util.cpp
│ │ ├── CAPI_D3D1X_Util.h
│ │ ├── CAPI_D3D9_DistortionRenderer.cpp
│ │ ├── CAPI_D3D9_DistortionRenderer.h
│ │ ├── CAPI_D3D9_HSWDisplay.cpp
│ │ ├── CAPI_D3D9_HSWDisplay.h
│ │ └── CAPI_D3D9_Util.cpp
│ ├── GL
│ │ ├── CAPI_GL_DistortionRenderer.cpp
│ │ ├── CAPI_GL_DistortionRenderer.h
│ │ ├── CAPI_GL_DistortionShaders.h
│ │ ├── CAPI_GL_HSWDisplay.cpp
│ │ ├── CAPI_GL_HSWDisplay.h
│ │ ├── CAPI_GL_Util.cpp
│ │ └── CAPI_GL_Util.h
│ ├── Shaders
│ │ ├── DistortionChroma_ps.h
│ │ ├── DistortionChroma_ps.psh
│ │ ├── DistortionChroma_ps_refl.h
│ │ ├── DistortionChroma_vs.h
│ │ ├── DistortionChroma_vs.vsh
│ │ ├── DistortionChroma_vs_refl.h
│ │ ├── DistortionTimewarpChroma_vs.h
│ │ ├── DistortionTimewarpChroma_vs.vsh
│ │ ├── DistortionTimewarpChroma_vs_refl.h
│ │ ├── DistortionTimewarp_vs.h
│ │ ├── DistortionTimewarp_vs.vsh
│ │ ├── DistortionTimewarp_vs_refl.h
│ │ ├── Distortion_ps.h
│ │ ├── Distortion_ps.psh
│ │ ├── Distortion_ps_refl.h
│ │ ├── Distortion_vs.h
│ │ ├── Distortion_vs.vsh
│ │ ├── Distortion_vs_refl.h
│ │ ├── SimpleQuad_ps.h
│ │ ├── SimpleQuad_ps.psh
│ │ ├── SimpleQuad_ps_refl.h
│ │ ├── SimpleQuad_vs.h
│ │ ├── SimpleQuad_vs.vsh
│ │ ├── SimpleQuad_vs_refl.h
│ │ ├── SimpleTexturedQuad_ps.h
│ │ ├── SimpleTexturedQuad_ps.psh
│ │ ├── SimpleTexturedQuad_ps_refl.h
│ │ ├── SimpleTexturedQuad_vs.h
│ │ ├── SimpleTexturedQuad_vs.vsh
│ │ ├── SimpleTexturedQuad_vs_refl.h
│ │ ├── genPixelShaderHeader.bat
│ │ └── genVertexShaderHeader.bat
│ └── Textures
│ │ └── healthAndSafety.tga.h
│ ├── Displays
│ ├── OVR_Display.cpp
│ ├── OVR_Display.h
│ ├── OVR_OSX_Display.cpp
│ ├── OVR_OSX_Display.h
│ ├── OVR_Win32_Display.cpp
│ ├── OVR_Win32_Display.h
│ ├── OVR_Win32_Dxgi_Display.h
│ ├── OVR_Win32_FocusReader.cpp
│ ├── OVR_Win32_FocusReader.h
│ ├── OVR_Win32_RenderShim.cpp
│ ├── OVR_Win32_ShimFunctions.cpp
│ └── OVR_Win32_ShimFunctions.h
│ ├── Kernel
│ ├── OVR_Alg.cpp
│ ├── OVR_Alg.h
│ ├── OVR_Allocator.cpp
│ ├── OVR_Allocator.h
│ ├── OVR_Array.h
│ ├── OVR_Atomic.cpp
│ ├── OVR_Atomic.h
│ ├── OVR_CRC32.cpp
│ ├── OVR_CRC32.h
│ ├── OVR_Color.h
│ ├── OVR_Compiler.h
│ ├── OVR_ContainerAllocator.h
│ ├── OVR_Delegates.h
│ ├── OVR_Deque.h
│ ├── OVR_File.cpp
│ ├── OVR_File.h
│ ├── OVR_FileFILE.cpp
│ ├── OVR_Hash.h
│ ├── OVR_KeyCodes.h
│ ├── OVR_List.h
│ ├── OVR_Lockless.cpp
│ ├── OVR_Lockless.h
│ ├── OVR_Log.cpp
│ ├── OVR_Log.h
│ ├── OVR_Math.cpp
│ ├── OVR_Math.h
│ ├── OVR_Nullptr.h
│ ├── OVR_Observer.h
│ ├── OVR_RefCount.cpp
│ ├── OVR_RefCount.h
│ ├── OVR_SharedMemory.cpp
│ ├── OVR_SharedMemory.h
│ ├── OVR_Std.cpp
│ ├── OVR_Std.h
│ ├── OVR_String.cpp
│ ├── OVR_String.h
│ ├── OVR_StringHash.h
│ ├── OVR_String_FormatUtil.cpp
│ ├── OVR_String_PathUtil.cpp
│ ├── OVR_SysFile.cpp
│ ├── OVR_SysFile.h
│ ├── OVR_System.cpp
│ ├── OVR_System.h
│ ├── OVR_ThreadCommandQueue.cpp
│ ├── OVR_ThreadCommandQueue.h
│ ├── OVR_Threads.h
│ ├── OVR_ThreadsPthread.cpp
│ ├── OVR_ThreadsWinAPI.cpp
│ ├── OVR_Timer.cpp
│ ├── OVR_Timer.h
│ ├── OVR_Types.h
│ ├── OVR_UTF8Util.cpp
│ └── OVR_UTF8Util.h
│ ├── Net
│ ├── OVR_BitStream.cpp
│ ├── OVR_BitStream.h
│ ├── OVR_MessageIDTypes.h
│ ├── OVR_NetworkPlugin.cpp
│ ├── OVR_NetworkPlugin.h
│ ├── OVR_NetworkTypes.h
│ ├── OVR_PacketizedTCPSocket.cpp
│ ├── OVR_PacketizedTCPSocket.h
│ ├── OVR_RPC1.cpp
│ ├── OVR_RPC1.h
│ ├── OVR_Session.cpp
│ ├── OVR_Session.h
│ ├── OVR_Socket.cpp
│ ├── OVR_Socket.h
│ ├── OVR_Unix_Socket.cpp
│ ├── OVR_Unix_Socket.h
│ ├── OVR_Win32_Socket.cpp
│ └── OVR_Win32_Socket.h
│ ├── OVR_CAPI.cpp
│ ├── OVR_CAPI.h
│ ├── OVR_CAPI_D3D.h
│ ├── OVR_CAPI_GL.h
│ ├── OVR_JSON.cpp
│ ├── OVR_JSON.h
│ ├── OVR_Profile.cpp
│ ├── OVR_Profile.h
│ ├── OVR_SerialFormat.cpp
│ ├── OVR_SerialFormat.h
│ ├── OVR_Stereo.cpp
│ ├── OVR_Stereo.h
│ ├── Sensors
│ └── OVR_DeviceConstants.h
│ ├── Service
│ ├── Service_NetClient.cpp
│ ├── Service_NetClient.h
│ ├── Service_NetSessionCommon.cpp
│ └── Service_NetSessionCommon.h
│ ├── Tracking
│ ├── Tracking_PoseState.h
│ ├── Tracking_SensorState.h
│ ├── Tracking_SensorStateReader.cpp
│ └── Tracking_SensorStateReader.h
│ └── Util
│ ├── Util_ImageWindow.cpp
│ ├── Util_ImageWindow.h
│ ├── Util_Interface.cpp
│ ├── Util_Interface.h
│ ├── Util_LatencyTest2Reader.cpp
│ ├── Util_LatencyTest2Reader.h
│ ├── Util_LatencyTest2State.h
│ ├── Util_Render_Stereo.cpp
│ └── Util_Render_Stereo.h
├── license.md
├── ofxOculusDK2Lib
├── .gitignore
├── ofxOculusDK2.props
├── ofxOculusDK2Lib.sln
├── ofxOculusDK2Lib.vcxproj
└── ofxOculusDK2Lib.vcxproj.filters
└── src
├── ofxOculusDK2.cpp
└── ofxOculusDK2.h
/.gitignore:
--------------------------------------------------------------------------------
1 | *.mode*
2 | *.pbxuser
3 | *.xcworkspace
4 | xcuserdata/
5 | *.build
6 |
7 | build/
8 | obj/
9 | *.o
10 | openFrameworks.a
11 | openFrameworksDebug.a
12 | openFrameworksUniversal.a
13 | *.app
14 |
15 | #rule to avoid non-official addons going into git
16 | #see addons/.gitignore
17 | #addons/**
18 |
19 | #NMM:
20 | apps/*/*/bin/data/img_cache
21 |
22 | #codeblocks files
23 | apps/*/*/*.layout
24 | apps/*/*/*.depend
25 | apps/*/*/bin/clickToLaunch*
26 | apps/*/*/bin/libs
27 | apps/*/*/obj
28 |
29 | #rule to avoid non-official apps going into git
30 | #see apps/.gitignore
31 | #apps
32 |
33 | #codeblocks OF lib files
34 | libs/openFrameworksCompiled/project/*/*.depend
35 | libs/openFrameworksCompiled/project/*/*.layout
36 |
37 | #linux temporary files
38 | *~
39 |
40 | #eclipse build folders
41 | #Mac OS X
42 | addons/Debug Mac OS X
43 | addons/Release Mac OS X
44 | libs/openFrameworks/Debug Mac OS X
45 | libs/openFrameworks/Release Mac OS X
46 | apps/*/*/Debug Mac OS X
47 | apps/*/*/Release Mac OS X
48 | .DS_Store
49 |
50 | #xcode
51 | *.perspectivev3
52 | *.pbxuser
53 |
54 |
55 | #Linux
56 | addons/Debug Linux
57 | addons/Release Linux
58 | libs/openFrameworks/Debug Linux
59 | libs/openFrameworks/Release Linux
60 | apps/*/*/Debug Linux
61 | apps/*/*/Release Linux
62 | apps/*/*/Debug Linux64
63 | apps/*/*/Release Linux64
64 |
65 | */bin/*.dll
66 | */x64
67 | *.exe
68 | *.ilk
69 | *.pdb
70 | *.sdf
71 | *.suo
72 |
73 | #Android
74 | addons/Debug Android
75 | addons/Release Android
76 | libs/openFrameworks/Debug Android
77 | libs/openFrameworks/Release Android
78 | libs/openFrameworks/Release
79 | libs/openFrameworks/Debug
80 | libs/openFrameworks/Release_arm7
81 | apps/*/*/Debug Android
82 | apps/*/*/Release Android
83 | apps/*/*/Debug
84 | apps/*/*/Release
85 | apps/*/*/Release_arm7
86 | apps/*/*/test link
87 | apps/*/*/obj
88 | #apps/*/*/bin
89 |
90 | .csettings
91 | *.lib
92 | *.opensdf
93 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ofxOculusRift
2 | ================
3 |
4 | Oculus Rift addon for openFrameworks lets you attach the rift rendering and headtracking pipeline to any existing ofCamera.
5 |
6 | Originally by Andreas Muller
7 | Refactored by James George
8 |
9 | void testApp::setup(){
10 | oculusRift.baseCamera = &cam; //attach to your camera
11 | //opens the device, an Oculus must be plugged in
12 | //as it uses the params returned from the head set to configure
13 | //the resolution settings
14 | oculusRift.setup();
15 |
16 | //must run in full screen mode
17 | ofToggleFullScreen();
18 | }
19 |
20 | void testApp::draw(){
21 |
22 | //move your camera wherever you'd like, this becomes the base
23 | //position of the view
24 |
25 | //now render using oculus flow
26 | oculusRift.beginLeftEye();
27 | drawScene();
28 | oculusRift.endLeftEye();
29 |
30 | oculusRift.beginRightEye();
31 | drawScene();
32 | oculusRift.endRightEye();
33 |
34 | //pushes the render texture to the viewer
35 | oculusRift.draw();
36 | }
37 |
38 |
39 | void testApp::drawScene(){
40 | //draw anything here in 3d, will be rendered once for each eye
41 | }
42 |
--------------------------------------------------------------------------------
/example-OculusRiftRendering/OculusRenderingBasic.sln:
--------------------------------------------------------------------------------
1 | Microsoft Visual Studio Solution File, Format Version 12.00
2 | # Visual Studio 2012
3 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openframeworksLib", "..\..\..\libs\openFrameworksCompiled\project\vs\openframeworksLib.vcxproj", "{5837595D-ACA9-485C-8E76-729040CE4B0B}"
4 | EndProject
5 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OculusRenderingBasic", "OculusRenderingBasic.vcxproj", "{7FD42DF7-442E-479A-BA76-D0022F99702A}"
6 | EndProject
7 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ofxOculusDK2Lib", "..\ofxOculusDK2Lib\ofxOculusDK2Lib.vcxproj", "{06DF4A39-7102-462B-8F20-FC26E9A93826}"
8 | EndProject
9 | Global
10 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
11 | Debug|Win32 = Debug|Win32
12 | Debug|x64 = Debug|x64
13 | Release|Win32 = Release|Win32
14 | Release|x64 = Release|x64
15 | EndGlobalSection
16 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
17 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug|Win32.ActiveCfg = Debug|Win32
18 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug|Win32.Build.0 = Debug|Win32
19 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug|x64.ActiveCfg = Debug|x64
20 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug|x64.Build.0 = Debug|x64
21 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Release|Win32.ActiveCfg = Release|Win32
22 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Release|Win32.Build.0 = Release|Win32
23 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Release|x64.ActiveCfg = Release|x64
24 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Release|x64.Build.0 = Release|x64
25 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Debug|Win32.ActiveCfg = Debug|Win32
26 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Debug|Win32.Build.0 = Debug|Win32
27 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Debug|x64.ActiveCfg = Debug|x64
28 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Debug|x64.Build.0 = Debug|x64
29 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Release|Win32.ActiveCfg = Release|Win32
30 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Release|Win32.Build.0 = Release|Win32
31 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Release|x64.ActiveCfg = Release|x64
32 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Release|x64.Build.0 = Release|x64
33 | {06DF4A39-7102-462B-8F20-FC26E9A93826}.Debug|Win32.ActiveCfg = Debug|Win32
34 | {06DF4A39-7102-462B-8F20-FC26E9A93826}.Debug|Win32.Build.0 = Debug|Win32
35 | {06DF4A39-7102-462B-8F20-FC26E9A93826}.Debug|x64.ActiveCfg = Debug|x64
36 | {06DF4A39-7102-462B-8F20-FC26E9A93826}.Debug|x64.Build.0 = Debug|x64
37 | {06DF4A39-7102-462B-8F20-FC26E9A93826}.Release|Win32.ActiveCfg = Release|Win32
38 | {06DF4A39-7102-462B-8F20-FC26E9A93826}.Release|Win32.Build.0 = Release|Win32
39 | {06DF4A39-7102-462B-8F20-FC26E9A93826}.Release|x64.ActiveCfg = Release|x64
40 | {06DF4A39-7102-462B-8F20-FC26E9A93826}.Release|x64.Build.0 = Release|x64
41 | EndGlobalSection
42 | GlobalSection(SolutionProperties) = preSolution
43 | HideSolutionNode = FALSE
44 | EndGlobalSection
45 | EndGlobal
46 |
--------------------------------------------------------------------------------
/example-OculusRiftRendering/OculusRenderingBasic.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | src
6 |
7 |
8 | src
9 |
10 |
11 | src
12 |
13 |
14 |
15 |
16 | {d8376475-7454-4a24-b08a-aac121d3ad6f}
17 |
18 |
19 | {1fdbdf30-aa97-4eef-a39b-2c96ca06558b}
20 |
21 |
22 |
23 |
24 | src
25 |
26 |
27 |
--------------------------------------------------------------------------------
/example-OculusRiftRendering/OculusRenderingBasic.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(ProjectDir)/bin
5 | WindowsLocalDebugger
6 |
7 |
8 | $(ProjectDir)/bin
9 | WindowsLocalDebugger
10 |
11 |
--------------------------------------------------------------------------------
/example-OculusRiftRendering/OculusRenderingBasic.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example-OculusRiftRendering/OculusRenderingBasic.xcodeproj/project.xcworkspace/xcuserdata/andreasmuller.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/obviousjim/ofxOculusDK2/849a3e96d6b409d176e5ee05d74765b36b775886/example-OculusRiftRendering/OculusRenderingBasic.xcodeproj/project.xcworkspace/xcuserdata/andreasmuller.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/example-OculusRiftRendering/OculusRenderingBasic.xcodeproj/project.xcworkspace/xcuserdata/andreasmuller.xcuserdatad/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges
6 |
7 | SnapshotAutomaticallyBeforeSignificantChanges
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/example-OculusRiftRendering/OculusRenderingBasic.xcodeproj/xcuserdata/andreasmuller.xcuserdatad/xcschemes/OculusRiftBasic.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
51 |
52 |
58 |
59 |
60 |
61 |
62 |
63 |
69 |
70 |
76 |
77 |
78 |
79 |
81 |
82 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/example-OculusRiftRendering/OculusRenderingBasic.xcodeproj/xcuserdata/andreasmuller.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | OculusRiftBasic.xcscheme
8 |
9 | orderHint
10 | 1
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | E4B69B5A0A3A1756003C02F2
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/example-OculusRiftRendering/Project.xcconfig:
--------------------------------------------------------------------------------
1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT.
2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED
3 | OF_PATH = ../../..
4 |
5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE
6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig"
7 |
8 | ///////////////////////////////////////////
9 | // ADDONS
10 |
11 | // path to the addons dir
12 | ADDONS_PATH = $(OF_PATH)/addons
13 |
14 | // ofxOculusRift
15 | OFX_OCULUSRIFT_HEADERS = $(ADDONS_PATH)/ofxOculusDK2/src $(ADDONS_PATH)/ofxOculusDK2/libs/LibOVR/Include $(ADDONS_PATH)/ofxOculusDK2/libs/LibOVR/Src
16 |
17 | OFX_OCULUSRIFT_LIBS = "$(ADDONS_PATH)/ofxOculusDK2/libs/LibOVR/Lib/MacOS/Release/libovr.a"
18 |
19 |
20 | // all addons
21 | OF_ADDON_HEADERS = $(OFX_OCULUSRIFT_HEADERS)
22 | OF_ADDON_LIBS = $(OFX_OCULUSRIFT_LIBS)
23 |
24 | ///////////////////////////////////////////
25 | // MAIN
26 |
27 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) $(OF_ADDON_HEADERS)
28 | OTHER_LDFLAGS = $(OF_CORE_LIBS) $(OF_ADDON_LIBS)
29 |
--------------------------------------------------------------------------------
/example-OculusRiftRendering/addons.make:
--------------------------------------------------------------------------------
1 | #This file is currently only for linux users!
2 | #Add your addon and all other necessary ones here (without '#')
3 | #put every addon in one line, for example
4 | #myAddon
5 | #ofxXmlSettings
6 | #ofxOpenCv
7 |
--------------------------------------------------------------------------------
/example-OculusRiftRendering/bin/data/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/obviousjim/ofxOculusDK2/849a3e96d6b409d176e5ee05d74765b36b775886/example-OculusRiftRendering/bin/data/.gitkeep
--------------------------------------------------------------------------------
/example-OculusRiftRendering/bin/data/Fonts/DIN.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/obviousjim/ofxOculusDK2/849a3e96d6b409d176e5ee05d74765b36b775886/example-OculusRiftRendering/bin/data/Fonts/DIN.otf
--------------------------------------------------------------------------------
/example-OculusRiftRendering/bin/data/Shaders/HmdWarpDK2.frag:
--------------------------------------------------------------------------------
1 | #version 120
2 | #extension GL_ARB_texture_rectangle : enable
3 |
4 | uniform sampler2DRect Texture;
5 | uniform vec2 TextureScale;
6 |
7 | varying vec4 oColor;
8 | varying vec2 oTexCoord0;
9 | varying vec2 oTexCoord1;
10 | varying vec2 oTexCoord2;
11 |
12 | void main()
13 | {
14 | gl_FragColor.r = oColor.r * texture2DRect(Texture, oTexCoord0 * TextureScale).r;
15 | gl_FragColor.g = oColor.g * texture2DRect(Texture, oTexCoord1 * TextureScale).g;
16 | gl_FragColor.b = oColor.b * texture2DRect(Texture, oTexCoord2 * TextureScale).b;
17 | gl_FragColor.a = 1.0;
18 | }
--------------------------------------------------------------------------------
/example-OculusRiftRendering/bin/data/Shaders/HmdWarpDK2.vert:
--------------------------------------------------------------------------------
1 | #version 120
2 | #extension GL_ARB_texture_rectangle : enable
3 |
4 | uniform vec2 EyeToSourceUVScale;
5 | uniform vec2 EyeToSourceUVOffset;
6 | uniform mat4 EyeRotationStart;
7 | uniform mat4 EyeRotationEnd;
8 |
9 | varying vec4 oColor;
10 | varying vec2 oTexCoord0;
11 | varying vec2 oTexCoord1;
12 | varying vec2 oTexCoord2;
13 |
14 | void main()
15 | {
16 | gl_Position.x = gl_Vertex.x;
17 | gl_Position.y = gl_Vertex.y;
18 | gl_Position.z = .0;
19 | gl_Position.w = 1.0;
20 |
21 | // Vertex inputs are in TanEyeAngle space for the R,G,B channels (i.e. after chromatic aberration and distortion).
22 | // These are now "real world" vectors in direction (x,y,1) relative to the eye of the HMD.
23 | vec3 TanEyeAngleR = vec3 ( gl_Normal.x, gl_Normal.y, 1.0 );
24 | vec3 TanEyeAngleG = vec3 ( gl_Color.r, gl_Color.g, 1.0 );
25 | vec3 TanEyeAngleB = vec3 ( gl_Color.b, gl_Color.a, 1.0 );
26 |
27 | mat3 EyeRotation;
28 | EyeRotation[0] = mix ( EyeRotationStart[0], EyeRotationEnd[0], gl_Vertex.z ).xyz;
29 | EyeRotation[1] = mix ( EyeRotationStart[1], EyeRotationEnd[1], gl_Vertex.z ).xyz;
30 | EyeRotation[2] = mix ( EyeRotationStart[2], EyeRotationEnd[2], gl_Vertex.z ).xyz;
31 |
32 | vec3 TransformedR = EyeRotation * TanEyeAngleR;
33 | vec3 TransformedG = EyeRotation * TanEyeAngleG;
34 | vec3 TransformedB = EyeRotation * TanEyeAngleB;
35 |
36 | // Project them back onto the Z=1 plane of the rendered images.
37 | float RecipZR = 1.0 / TransformedR.z;
38 | float RecipZG = 1.0 / TransformedG.z;
39 | float RecipZB = 1.0 / TransformedB.z;
40 | vec2 FlattenedR = vec2 ( TransformedR.x * RecipZR, TransformedR.y * RecipZR );
41 | vec2 FlattenedG = vec2 ( TransformedG.x * RecipZG, TransformedG.y * RecipZG );
42 | vec2 FlattenedB = vec2 ( TransformedB.x * RecipZB, TransformedB.y * RecipZB );
43 |
44 | // These are now still in TanEyeAngle space.
45 | // Scale them into the correct [0-1],[0-1] UV lookup space (depending on eye)
46 | vec2 SrcCoordR = FlattenedR * EyeToSourceUVScale + EyeToSourceUVOffset;
47 | vec2 SrcCoordG = FlattenedG * EyeToSourceUVScale + EyeToSourceUVOffset;
48 | vec2 SrcCoordB = FlattenedB * EyeToSourceUVScale + EyeToSourceUVOffset;
49 |
50 | oTexCoord0 = SrcCoordR;
51 | oTexCoord0.y = 1.0-oTexCoord0.y;
52 | oTexCoord1 = SrcCoordG;
53 | oTexCoord1.y = 1.0-oTexCoord1.y;
54 | oTexCoord2 = SrcCoordB;
55 | oTexCoord2.y = 1.0-oTexCoord2.y;
56 |
57 | oColor = vec4(gl_Normal.z, gl_Normal.z, gl_Normal.z, gl_Normal.z);
58 |
59 | }
--------------------------------------------------------------------------------
/example-OculusRiftRendering/bin/data/Shaders/HmdWarpDK2_simple.vert:
--------------------------------------------------------------------------------
1 | #version 120
2 | #extension GL_ARB_texture_rectangle : enable
3 |
4 | uniform vec2 EyeToSourceUVScale;
5 | uniform vec2 EyeToSourceUVOffset;
6 |
7 |
8 | varying vec4 oColor;
9 | varying vec2 oTexCoord0;
10 | varying vec2 oTexCoord1;
11 | varying vec2 oTexCoord2;
12 |
13 | void main()
14 | {
15 | gl_Position.x = gl_Vertex.x;
16 | gl_Position.y = gl_Vertex.y;
17 | gl_Position.z = 0.5;
18 | gl_Position.w = 1.0;
19 |
20 | // Vertex inputs are in TanEyeAngle space for the R,G,B channels (i.e. after chromatic aberration and distortion).
21 | // Scale them into the correct [0-1],[0-1] UV lookup space (depending on eye)
22 | vec2 TexCoord0 = vec2(gl_Normal.x, gl_Normal.y);
23 | vec2 TexCoord1 = vec2( gl_Color.r, gl_Color.g);
24 | vec2 TexCoord2 = vec2( gl_Color.b, gl_Color.a);
25 |
26 | oTexCoord0 = TexCoord0 * EyeToSourceUVScale + EyeToSourceUVOffset;
27 | oTexCoord0.y = 1.0-oTexCoord0.y;
28 | oTexCoord1 = TexCoord1 * EyeToSourceUVScale + EyeToSourceUVOffset;
29 | oTexCoord1.y = 1.0-oTexCoord1.y;
30 | oTexCoord2 = TexCoord2 * EyeToSourceUVScale + EyeToSourceUVOffset;
31 | oTexCoord2.y = 1.0-oTexCoord2.y;
32 |
33 | oColor = vec4(gl_Normal.z, gl_Normal.z, gl_Normal.z, gl_Normal.z); // Used for vignette fade.
34 | }
--------------------------------------------------------------------------------
/example-OculusRiftRendering/icon.aps:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/obviousjim/ofxOculusDK2/849a3e96d6b409d176e5ee05d74765b36b775886/example-OculusRiftRendering/icon.aps
--------------------------------------------------------------------------------
/example-OculusRiftRendering/icon.rc:
--------------------------------------------------------------------------------
1 | // Icon Resource Definition
2 | #define MAIN_ICON 102
3 |
4 | #if defined(_DEBUG)
5 | MAIN_ICON ICON "..\..\..\libs\openFrameworksCompiled\project\vs\icon_debug.ico"
6 | #else
7 | MAIN_ICON ICON "..\..\..\libs\openFrameworksCompiled\project\vs\icon.ico"
8 | #endif
9 |
--------------------------------------------------------------------------------
/example-OculusRiftRendering/openFrameworks-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | com.yourcompany.openFrameworks
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundlePackageType
14 | APPL
15 | CFBundleSignature
16 | ????
17 | CFBundleVersion
18 | 1.0
19 |
20 |
21 |
--------------------------------------------------------------------------------
/example-OculusRiftRendering/src/main.cpp:
--------------------------------------------------------------------------------
1 | #include "testApp.h"
2 |
3 | //--------------------------------------------------------------
4 | int main(){
5 | // set width, height, mode (OF_WINDOW or OF_FULLSCREEN)
6 | ofSetupOpenGL(1024, 768, OF_WINDOW);
7 | ofRunApp(new testApp()); // start the app
8 | }
9 |
--------------------------------------------------------------------------------
/example-OculusRiftRendering/src/testApp.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "ofMain.h"
4 | #include "ofxOculusDK2.h"
5 |
6 | typedef struct{
7 | ofColor color;
8 | ofVec3f pos;
9 | ofVec3f floatPos;
10 | float radius;
11 | bool bMouseOver;
12 | bool bGazeOver;
13 | } DemoSphere;
14 |
15 | class testApp : public ofBaseApp
16 | {
17 | public:
18 |
19 | void setup();
20 | void update();
21 | void draw();
22 |
23 | void drawScene();
24 |
25 | void keyPressed(int key);
26 | void keyReleased(int key);
27 | void mouseMoved(int x, int y);
28 | void mouseDragged(int x, int y, int button);
29 | void mousePressed(int x, int y, int button);
30 | void mouseReleased(int x, int y, int button);
31 | void windowResized(int w, int h);
32 | void dragEvent(ofDragInfo dragInfo);
33 | void gotMessage(ofMessage msg);
34 |
35 | ofxOculusDK2 oculusRift;
36 |
37 | ofLight light;
38 | ofEasyCam cam;
39 | bool showOverlay;
40 | bool predictive;
41 | vector demos;
42 |
43 | ofVec3f cursor2D;
44 | ofVec3f cursor3D;
45 |
46 | ofVec3f cursorRift;
47 | ofVec3f demoRift;
48 |
49 | ofVec3f cursorGaze;
50 | };
51 |
--------------------------------------------------------------------------------
/libs/LibOVR/Include/OVR.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : OVR.h
4 | Content : The main public interface to Oculus for C++ Developers.
5 | Includes C API and helper classes.
6 |
7 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
8 |
9 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
10 | you may not use the Oculus VR Rift SDK except in compliance with the License,
11 | which is provided at the time of installation or download, or which
12 | otherwise accompanies this software in either electronic or hard copy form.
13 |
14 | You may obtain a copy of the License at
15 |
16 | http://www.oculusvr.com/licenses/LICENSE-3.1
17 |
18 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
19 | distributed under the License is distributed on an "AS IS" BASIS,
20 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | See the License for the specific language governing permissions and
22 | limitations under the License.
23 |
24 | *************************************************************************************/
25 |
26 | #ifndef OVR_h
27 | #define OVR_h
28 |
29 | #include "OVR_Version.h"
30 |
31 | #include "../Src/Kernel/OVR_Math.h"
32 |
33 | #include "../Src/OVR_CAPI.h"
34 |
35 | #endif
36 |
37 |
--------------------------------------------------------------------------------
/libs/LibOVR/Include/OVR_Kernel.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : OVRKernel.h
4 | Content : This contains references to all OVR Kernel headers in Src folder.
5 | Should be generated automatically based on PublicHeader tags.
6 |
7 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
8 |
9 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
10 | you may not use the Oculus VR Rift SDK except in compliance with the License,
11 | which is provided at the time of installation or download, or which
12 | otherwise accompanies this software in either electronic or hard copy form.
13 |
14 | You may obtain a copy of the License at
15 |
16 | http://www.oculusvr.com/licenses/LICENSE-3.1
17 |
18 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
19 | distributed under the License is distributed on an "AS IS" BASIS,
20 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | See the License for the specific language governing permissions and
22 | limitations under the License.
23 |
24 | *************************************************************************************/
25 |
26 | #ifndef OVR_h
27 | #define OVR_h
28 |
29 | #include "../Src/Kernel/OVR_Types.h"
30 | #include "../Src/Kernel/OVR_Allocator.h"
31 | #include "../Src/Kernel/OVR_RefCount.h"
32 | #include "../Src/Kernel/OVR_Log.h"
33 | #include "../Src/Kernel/OVR_Math.h"
34 | #include "../Src/Kernel/OVR_System.h"
35 | #include "../Src/Kernel/OVR_Nullptr.h"
36 | #include "../Src/Kernel/OVR_String.h"
37 | #include "../Src/Kernel/OVR_Array.h"
38 | #include "../Src/Kernel/OVR_Timer.h"
39 | #include "../Src/Kernel/OVR_SysFile.h"
40 |
41 | #endif
42 |
43 |
--------------------------------------------------------------------------------
/libs/LibOVR/Include/OVR_Version.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : OVRVersion.h
4 | Content :
5 |
6 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
7 |
8 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
9 | you may not use the Oculus VR Rift SDK except in compliance with the License,
10 | which is provided at the time of installation or download, or which
11 | otherwise accompanies this software in either electronic or hard copy form.
12 |
13 | You may obtain a copy of the License at
14 |
15 | http://www.oculusvr.com/licenses/LICENSE-3.1
16 |
17 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
18 | distributed under the License is distributed on an "AS IS" BASIS,
19 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | See the License for the specific language governing permissions and
21 | limitations under the License.
22 |
23 | *************************************************************************************/
24 |
25 | #ifndef _OVR_VERSION_H
26 | #define _OVR_VERSION_H
27 |
28 | #define OVR_MAJOR_VERSION 0
29 | #define OVR_MINOR_VERSION 4
30 | #define OVR_BUILD_VERSION 1
31 | #define OVR_VERSION_STRING "0.4.1"
32 |
33 | #endif
34 |
--------------------------------------------------------------------------------
/libs/LibOVR/Lib/MacOS/Debug/libovr.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/obviousjim/ofxOculusDK2/849a3e96d6b409d176e5ee05d74765b36b775886/libs/LibOVR/Lib/MacOS/Debug/libovr.a
--------------------------------------------------------------------------------
/libs/LibOVR/Lib/MacOS/Debug32/libovr.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/obviousjim/ofxOculusDK2/849a3e96d6b409d176e5ee05d74765b36b775886/libs/LibOVR/Lib/MacOS/Debug32/libovr.a
--------------------------------------------------------------------------------
/libs/LibOVR/Lib/MacOS/Release/libovr.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/obviousjim/ofxOculusDK2/849a3e96d6b409d176e5ee05d74765b36b775886/libs/LibOVR/Lib/MacOS/Release/libovr.a
--------------------------------------------------------------------------------
/libs/LibOVR/Lib/MacOS/Release32/libovr.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/obviousjim/ofxOculusDK2/849a3e96d6b409d176e5ee05d74765b36b775886/libs/LibOVR/Lib/MacOS/Release32/libovr.a
--------------------------------------------------------------------------------
/libs/LibOVR/Lib/x64/VS2010/libovr64.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/obviousjim/ofxOculusDK2/849a3e96d6b409d176e5ee05d74765b36b775886/libs/LibOVR/Lib/x64/VS2010/libovr64.lib
--------------------------------------------------------------------------------
/libs/LibOVR/Lib/x64/VS2010/libovr64d.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/obviousjim/ofxOculusDK2/849a3e96d6b409d176e5ee05d74765b36b775886/libs/LibOVR/Lib/x64/VS2010/libovr64d.lib
--------------------------------------------------------------------------------
/libs/LibOVR/Lib/x64/VS2012/libovr64.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/obviousjim/ofxOculusDK2/849a3e96d6b409d176e5ee05d74765b36b775886/libs/LibOVR/Lib/x64/VS2012/libovr64.lib
--------------------------------------------------------------------------------
/libs/LibOVR/Lib/x64/VS2012/libovr64d.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/obviousjim/ofxOculusDK2/849a3e96d6b409d176e5ee05d74765b36b775886/libs/LibOVR/Lib/x64/VS2012/libovr64d.lib
--------------------------------------------------------------------------------
/libs/LibOVR/Lib/x64/VS2013/libovr64.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/obviousjim/ofxOculusDK2/849a3e96d6b409d176e5ee05d74765b36b775886/libs/LibOVR/Lib/x64/VS2013/libovr64.lib
--------------------------------------------------------------------------------
/libs/LibOVR/Lib/x64/VS2013/libovr64d.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/obviousjim/ofxOculusDK2/849a3e96d6b409d176e5ee05d74765b36b775886/libs/LibOVR/Lib/x64/VS2013/libovr64d.lib
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/CAPI_HMDRenderState.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : CAPI_HMDRenderState.h
4 | Content : Combines all of the rendering state associated with the HMD
5 | Created : February 2, 2014
6 | Authors : Michael Antonov
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | ************************************************************************************/
26 |
27 | #ifndef OVR_CAPI_HMDRenderState_h
28 | #define OVR_CAPI_HMDRenderState_h
29 |
30 | #include "../OVR_CAPI.h"
31 | #include "../Kernel/OVR_Math.h"
32 | #include "../Util/Util_Render_Stereo.h"
33 | #include "../Service/Service_NetSessionCommon.h"
34 |
35 | namespace OVR { namespace CAPI {
36 |
37 | using namespace OVR::Util::Render;
38 |
39 |
40 | //-------------------------------------------------------------------------------------
41 | // ***** HMDRenderState
42 |
43 | // Combines all of the rendering setup information about one HMD.
44 | // This structure only ever exists inside HMDState, but this
45 | // declaration is in a separate file to reduce #include dependencies.
46 | // All actual lifetime and update control is done by the surrounding HMDState.
47 | struct HMDRenderState
48 | {
49 | // Utility query functions.
50 | ovrHmdDesc GetDesc() const;
51 | ovrSizei GetFOVTextureSize(int eye, ovrFovPort fov, float pixelsPerDisplayPixel) const;
52 | ovrEyeRenderDesc CalcRenderDesc(ovrEyeType eyeType, const ovrFovPort& fov) const;
53 |
54 | HMDInfo OurHMDInfo;
55 |
56 | HmdRenderInfo RenderInfo;
57 | DistortionRenderDesc Distortion[2];
58 | ovrEyeRenderDesc EyeRenderDesc[2];
59 |
60 | // Clear color used for distortion
61 | float ClearColor[4];
62 |
63 | // Pose at which last time the eye was rendered, as submitted by EndEyeRender.
64 | ovrPosef EyeRenderPoses[2];
65 |
66 | // Capabilities passed to Configure.
67 | unsigned EnabledHmdCaps;
68 | unsigned DistortionCaps;
69 | };
70 |
71 |
72 | }} // namespace OVR::CAPI
73 |
74 | #endif // OVR_CAPI_HMDState_h
75 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/D3D1X/CAPI_D3D10_DistortionRenderer.cpp:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : CAPI_D3D10_DistortionRenderer.cpp
4 | Content : Distortion renderer instantiation for D3D10
5 | Created : November 11, 2013
6 | Authors : Volga Aksoy, Michael Antonov
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | ************************************************************************************/
26 |
27 | #define OVR_D3D_VERSION 10
28 | #include "CAPI_D3D1X_Util.cpp"
29 | #include "CAPI_D3D1X_DistortionRenderer.cpp"
30 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/D3D1X/CAPI_D3D10_DistortionRenderer.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : CAPI_D3D10_DistortionRenderer.h
4 | Content : Distortion renderer header for D3D10
5 | Created : November 11, 2013
6 | Authors : Michael Antonov
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | ************************************************************************************/
26 |
27 | #ifndef INC_CAPI_D3D10_DistortionRenderer_h
28 | #define INC_CAPI_D3D10_DistortionRenderer_h
29 |
30 | #define OVR_D3D_VERSION 10
31 | #include "CAPI_D3D1X_DistortionRenderer.h"
32 | #undef OVR_D3D_VERSION
33 |
34 | #endif
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/D3D1X/CAPI_D3D10_HSWDisplay.cpp:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : CAPI_D3D10_HSWDisplay.cpp
4 | Content : Implements Health and Safety Warning system.
5 | Created : July 7, 2014
6 | Authors : Paul Pedriana
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | ************************************************************************************/
26 |
27 | #define OVR_D3D_VERSION 10
28 | #include "CAPI_D3D1X_HSWDisplay.cpp"
29 | #undef OVR_D3D_VERSION
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/D3D1X/CAPI_D3D10_HSWDisplay.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : CAPI_D3D10_HSWDisplay.h
4 | Content : Implements Health and Safety Warning system.
5 | Created : July 7, 2014
6 | Authors : Paul Pedriana
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | ************************************************************************************/
26 |
27 | #ifndef OVR_CAPI_D3D10_HSWDisplay_h
28 | #define OVR_CAPI_D3D10_HSWDisplay_h
29 |
30 | #if !defined(OVR_D3D_VERSION) || ((OVR_D3D_VERSION != 10) && (OVR_D3D_VERSION != 11))
31 | #error This header expects OVR_D3D_VERSION to be defined, to 10 or 11.
32 | #endif
33 |
34 | // Due to the similarities between DX10 and DX11, there is a shared implementation of the headers and source
35 | // which is differentiated only by the OVR_D3D_VERSION define. This define causes D3D_NS (D3D namespace) to
36 | // be defined to either D3D10 or D3D11, as well as other similar effects.
37 | #include "CAPI_D3D1X_HSWDisplay.h"
38 |
39 |
40 | #endif // OVR_CAPI_D3D10_HSWDisplay_h
41 |
42 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/D3D1X/CAPI_D3D11_DistortionRenderer.cpp:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : CAPI_D3D11_DistortionRenderer.cpp
4 | Content : Distortion renderer instantiation for D3D11
5 | Created : November 11, 2013
6 | Authors : Volga Aksoy, Michael Antonov
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | ************************************************************************************/
26 |
27 | #define OVR_D3D_VERSION 11
28 | #include "CAPI_D3D1X_Util.cpp"
29 | #include "CAPI_D3D1X_DistortionRenderer.cpp"
30 |
31 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/D3D1X/CAPI_D3D11_DistortionRenderer.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : CAPI_D3D11_DistortionRenderer.h
4 | Content : Distortion renderer header for D3D11
5 | Created : November 11, 2013
6 | Authors : Michael Antonov
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | ************************************************************************************/
26 |
27 | #ifndef INC_CAPI_D3D11_DistortionRenderer_h
28 | #define INC_CAPI_D3D11_DistortionRenderer_h
29 |
30 | #define OVR_D3D_VERSION 11
31 | #include "CAPI_D3D1X_DistortionRenderer.h"
32 | #undef OVR_D3D_VERSION
33 |
34 | #endif
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/D3D1X/CAPI_D3D11_HSWDisplay.cpp:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : CAPI_D3D11_HSWDisplay.cpp
4 | Content : Implements Health and Safety Warning system.
5 | Created : July 7, 2014
6 | Authors : Paul Pedriana
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | ************************************************************************************/
26 |
27 | #define OVR_D3D_VERSION 11
28 | #include "CAPI_D3D1X_HSWDisplay.cpp"
29 | #undef OVR_D3D_VERSION
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/D3D1X/CAPI_D3D11_HSWDisplay.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : CAPI_D3D11_HSWDisplay.h
4 | Content : Implements Health and Safety Warning system.
5 | Created : July 7, 2014
6 | Authors : Paul Pedriana
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | ************************************************************************************/
26 |
27 | #ifndef OVR_CAPI_D3D11_HSWDisplay_h
28 | #define OVR_CAPI_D3D11_HSWDisplay_h
29 |
30 | #if !defined(OVR_D3D_VERSION) || ((OVR_D3D_VERSION != 10) && (OVR_D3D_VERSION != 11))
31 | #error This header expects OVR_D3D_VERSION to be defined, to 10 or 11.
32 | #endif
33 |
34 | // Due to the similarities between DX10 and DX11, there is a shared implementation of the headers and source
35 | // which is differentiated only by the OVR_D3D_VERSION define. This define causes D3D_NS (D3D namespace) to
36 | // be defined to either D3D10 or D3D11, as well as other similar effects.
37 | #include "CAPI_D3D1X_HSWDisplay.h"
38 |
39 |
40 | #endif // OVR_CAPI_D3D11_HSWDisplay_h
41 |
42 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/D3D1X/CAPI_D3D1X_HSWDisplay.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : CAPI_D3D1X_HSWDisplay.h
4 | Content : Implements Health and Safety Warning system.
5 | Created : July 7, 2014
6 | Authors : Paul Pedriana
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | ************************************************************************************/
26 |
27 | // Do not use include guards, as this file is #included separately by both
28 | // CAPI_D3D10_HSWDisplay.h and CAPI_D3D11_HSWDisplay.h with OVR_D3D_VERSION defined
29 | // to either 10 or 11. Only those two headers should #include this one.
30 | //#ifndef OVR_CAPI_D3D1X_HSWDisplay_h
31 | //#define OVR_CAPI_D3D1X_HSWDisplay_h
32 |
33 | //#if !defined(OVR_CAPI_D3D10_HSWDisplay_h) && !defined(OVR_CAPI_D3D11_HSWDisplay_h)
34 | // #error This header is expected to be compiled only by these two headers.
35 | //#endif
36 | #if !defined(OVR_D3D_VERSION) || ((OVR_D3D_VERSION != 10) && (OVR_D3D_VERSION != 11))
37 | #error This header expects OVR_D3D_VERSION to be defined, to 10 or 11.
38 | #endif
39 |
40 | #include "../CAPI_HSWDisplay.h"
41 | #include "CAPI_D3D1X_Util.h"
42 |
43 |
44 | namespace OVR { namespace CAPI { namespace D3D_NS {
45 |
46 | class HSWDisplay : public CAPI::HSWDisplay
47 | {
48 | public:
49 | HSWDisplay(ovrRenderAPIType api, ovrHmd hmd, const HMDRenderState& renderState);
50 |
51 | // Must be called before use. apiConfig is such that:
52 | // const ovrD3D11Config* config = (const ovrD3D11Config*)apiConfig; or
53 | bool Initialize(const ovrRenderAPIConfig* apiConfig);
54 | void Shutdown();
55 | void DisplayInternal();
56 | void DismissInternal();
57 |
58 | // Draws the warning to the eye texture(s). This must be done at the end of a
59 | // frame but prior to executing the distortion rendering of the eye textures.
60 | void RenderInternal(ovrEyeType eye, const ovrTexture* eyeTexture);
61 |
62 | protected:
63 | void LoadGraphics();
64 | void UnloadGraphics();
65 |
66 | OVR::CAPI::D3D_NS::RenderParams RenderParams;
67 | Ptr pSamplerState;
68 | Ptr pTexture;
69 | Ptr pVB;
70 | Ptr UniformBufferArray[OVR::CAPI::D3D_NS::Shader_Count];
71 | Ptr pShaderSet;
72 | Ptr pVertexInputLayout;
73 | Ptr pBlendState;
74 | Ptr pRasterizerState;
75 | Matrix4f OrthoProjection[ovrEye_Count];
76 |
77 | private:
78 | OVR_NON_COPYABLE(HSWDisplay)
79 | };
80 |
81 | }}} // namespace OVR::CAPI::D3D_NS
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/D3D1X/CAPI_D3D9_DistortionRenderer.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : CAPI_D3D1X_DistortionRenderer.h
4 | Content : Experimental distortion renderer
5 | Created : March 7, 2014
6 | Authors : Tom Heath
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | ************************************************************************************/
26 |
27 | #include "../../Kernel/OVR_Types.h"
28 |
29 | #undef new
30 |
31 | #if defined (OVR_OS_WIN32)
32 | #define WIN32_LEAN_AND_MEAN
33 | #if _MSC_VER < 1700
34 | #include
35 | #else
36 | #include
37 | #endif
38 | #endif
39 |
40 | #if defined(OVR_DEFINE_NEW)
41 | #define new OVR_DEFINE_NEW
42 | #endif
43 |
44 | #include "../CAPI_DistortionRenderer.h"
45 |
46 |
47 | namespace OVR { namespace CAPI { namespace D3D9 {
48 |
49 |
50 | //Implementation of DistortionRenderer for D3D9.
51 | /***************************************************/
52 | class DistortionRenderer : public CAPI::DistortionRenderer
53 | {
54 | public:
55 | DistortionRenderer(ovrHmd hmd, FrameTimeManager& timeManager, const HMDRenderState& renderState);
56 | ~DistortionRenderer();
57 |
58 | // Creation function for the device.
59 | static CAPI::DistortionRenderer* Create(ovrHmd hmd,
60 | FrameTimeManager& timeManager,
61 | const HMDRenderState& renderState);
62 |
63 | // ***** Public DistortionRenderer interface
64 | virtual bool Initialize(const ovrRenderAPIConfig* apiConfig,
65 | unsigned distortionCaps);
66 |
67 | virtual void SubmitEye(int eyeId, const ovrTexture* eyeTexture);
68 |
69 | virtual void EndFrame(bool swapBuffers);
70 |
71 | // TBD: Make public?
72 | void WaitUntilGpuIdle();
73 |
74 | // Similar to ovr_WaitTillTime but it also flushes GPU.
75 | // Note, it exits when time expires, even if GPU is not in idle state yet.
76 | double FlushGpuAndWaitTillTime(double absTime);
77 |
78 | protected:
79 |
80 | class GraphicsState : public CAPI::DistortionRenderer::GraphicsState
81 | {
82 | public:
83 | GraphicsState(IDirect3DDevice9* d, unsigned arg_distortionCaps);
84 | virtual void Save();
85 | virtual void Restore();
86 |
87 | protected:
88 | void RecordAndSetState(int which, int type, DWORD newValue);
89 |
90 | //Structure to store our state changes
91 | static const int MAX_SAVED_STATES=100;
92 | struct SavedStateType
93 | {
94 | int which; //0 for samplerstate, 1 for renderstate
95 | int type;
96 | DWORD valueToRevertTo;
97 | } savedState[MAX_SAVED_STATES];
98 |
99 | //Keep track of how many we've done, for reverting
100 | int numSavedStates;
101 | IDirect3DDevice9* device;
102 | unsigned distortionCaps;
103 | };
104 |
105 | private:
106 |
107 | //Functions
108 | void CreateDistortionShaders(void);
109 | void Create_Distortion_Models(void);
110 | void CreateVertexDeclaration(void);
111 | void RenderBothDistortionMeshes();
112 | void RecordAndSetState(int which, int type, DWORD newValue);
113 | void RevertAllStates(void);
114 |
115 | void renderEndFrame();
116 |
117 | //Data, structures and pointers
118 | IDirect3DDevice9 * device;
119 | IDirect3DSwapChain9 * swapChain;
120 | IDirect3DVertexDeclaration9 * vertexDecl;
121 | IDirect3DPixelShader9 * pixelShader;
122 | IDirect3DVertexShader9 * vertexShader;
123 | IDirect3DVertexShader9 * vertexShaderTimewarp;
124 | ovrSizei screenSize;
125 | unsigned distortionCaps;
126 |
127 | struct FOR_EACH_EYE
128 | {
129 | FOR_EACH_EYE() : TextureSize(0), RenderViewport(Sizei(0)) { }
130 |
131 | IDirect3DVertexBuffer9 * dxVerts;
132 | IDirect3DIndexBuffer9 * dxIndices;
133 | int numVerts;
134 | int numIndices;
135 | IDirect3DTexture9 * texture;
136 | ovrVector2f UVScaleOffset[2];
137 | Sizei TextureSize;
138 | Recti RenderViewport;
139 | } eachEye[2];
140 | };
141 |
142 | }}} // OVR::CAPI::D3D9
143 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/D3D1X/CAPI_D3D9_HSWDisplay.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : CAPI_D3D9_HSWDisplay.h
4 | Content : Implements Health and Safety Warning system.
5 | Created : July 7, 2014
6 | Authors : Paul Pedriana
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | ************************************************************************************/
26 |
27 | #ifndef OVR_CAPI_D3D9_HSWDisplay_h
28 | #define OVR_CAPI_D3D9_HSWDisplay_h
29 |
30 | #if !defined(OVR_D3D_VERSION) || (OVR_D3D_VERSION != 9)
31 | #error This header expects OVR_D3D_VERSION to be defined, to 9.
32 | #endif
33 |
34 | #include "../CAPI_HSWDisplay.h"
35 | #include "CAPI_D3D1X_Util.h"
36 | #include
37 |
38 |
39 | namespace OVR { namespace CAPI { namespace D3D9 {
40 |
41 | // There currently isn't a D3D9::RenderParams, as D3D9 support is currently only very basic.
42 | struct HSWRenderParams
43 | {
44 | IDirect3DDevice9* Device;
45 | IDirect3DSwapChain9* SwapChain;
46 | ovrSizei ScreenSize;
47 | };
48 |
49 | class HSWDisplay : public CAPI::HSWDisplay
50 | {
51 | public:
52 | HSWDisplay(ovrRenderAPIType api, ovrHmd hmd, const HMDRenderState& renderState);
53 |
54 | // Must be called before use. apiConfig is such that:
55 | // const ovrD3D9Config* config = (const ovrD3D9Config*)apiConfig; or
56 | bool Initialize(const ovrRenderAPIConfig* apiConfig);
57 | void Shutdown();
58 | void DisplayInternal();
59 | void DismissInternal();
60 |
61 | // Draws the warning to the eye texture(s). This must be done at the end of a
62 | // frame but prior to executing the distortion rendering of the eye textures.
63 | void RenderInternal(ovrEyeType eye, const ovrTexture* eyeTexture);
64 |
65 | protected:
66 | void LoadGraphics();
67 | void UnloadGraphics();
68 |
69 | D3D9::HSWRenderParams RenderParams;
70 | Ptr pTexture;
71 | Ptr pVB;
72 | Matrix4f OrthoProjection[2]; // Projection for 2D.
73 |
74 | private:
75 | OVR_NON_COPYABLE(HSWDisplay)
76 | };
77 |
78 | }}} // namespace OVR::CAPI::D3D9
79 |
80 |
81 | #endif // OVR_CAPI_D3D9_HSWDisplay_h
82 |
83 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/GL/CAPI_GL_HSWDisplay.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : CAPI_GL_HSWDisplay.h
4 | Content : Implements Health and Safety Warning system.
5 | Created : July 7, 2014
6 | Authors : Paul Pedriana
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | ************************************************************************************/
26 |
27 | #ifndef OVR_CAPI_GL_HSWDisplay_h
28 | #define OVR_CAPI_GL_HSWDisplay_h
29 |
30 |
31 | #include "../CAPI_HSWDisplay.h"
32 | #include "CAPI_GL_Util.h"
33 |
34 |
35 | namespace OVR { namespace CAPI { namespace GL {
36 |
37 | class HSWDisplay : public CAPI::HSWDisplay
38 | {
39 | public:
40 | HSWDisplay(ovrRenderAPIType api, ovrHmd hmd, const HMDRenderState& renderState);
41 |
42 | // Must be called before use. apiConfig is such that:
43 | // const ovrGLConfig* config = (const ovrGLConfig*)apiConfig; or
44 | bool Initialize(const ovrRenderAPIConfig* apiConfig);
45 | void Shutdown();
46 | void DisplayInternal();
47 | void DismissInternal();
48 |
49 | // Draws the warning to the eye texture(s). This must be done at the end of a
50 | // frame but prior to executing the distortion rendering of the eye textures.
51 | void RenderInternal(ovrEyeType eye, const ovrTexture* eyeTexture);
52 |
53 | protected:
54 | void UnloadGraphics();
55 | void LoadGraphics();
56 |
57 | OVR::CAPI::GL::RenderParams RenderParams;
58 | int GLMajorVersion; // Derived from glGetString(GL_VERSION). To consider: Move this into GL::RenderParams.
59 | int GLMinorVersion; //
60 | bool SupportsVao; // True if Vertex Array Objects are supported by the OpenGL version.
61 | GLuint FrameBuffer; // This is a container for a texture, depth buffer, stencil buffer to be rendered to. To consider: Make a wrapper class, like the OculusWorldDemo RBuffer class.
62 | Ptr pTexture;
63 | Ptr pShaderSet;
64 | Ptr pVertexShader;
65 | Ptr pFragmentShader;
66 | Ptr pVB;
67 | GLuint VAO; // Vertex Array Object.
68 | bool VAOInitialized; // True if the VAO was initialized with vertex buffer data.
69 | Matrix4f OrthoProjection[2]; // Projection for 2D.
70 |
71 | private:
72 | OVR_NON_COPYABLE(HSWDisplay)
73 | };
74 |
75 | }}} // namespace OVR::CAPI::GL
76 |
77 |
78 | #endif // OVR_CAPI_GL_HSWDisplay_h
79 |
80 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/Shaders/DistortionChroma_ps.psh:
--------------------------------------------------------------------------------
1 | Texture2D Texture : register(t0);
2 | Texture2D LastTexture : register(t1);
3 | SamplerState Linear : register(s0);
4 |
5 | float2 OverdriveInvRTSize;
6 | float2 OverdriveScales;
7 |
8 | void main(in float4 oPosition : SV_Position,
9 | in float1 oColor : COLOR,
10 | in float2 oTexCoord0 : TEXCOORD0,
11 | in float2 oTexCoord1 : TEXCOORD1,
12 | in float2 oTexCoord2 : TEXCOORD2,
13 | out float4 outColor0 : SV_Target0,
14 | out float4 outColor1 : SV_Target1)
15 | {
16 | float ResultR = Texture.SampleLevel(Linear, oTexCoord0, 0.0).r;
17 | float ResultG = Texture.SampleLevel(Linear, oTexCoord1, 0.0).g;
18 | float ResultB = Texture.SampleLevel(Linear, oTexCoord2, 0.0).b;
19 | float3 newColor = float3(ResultR * oColor, ResultG * oColor, ResultB * oColor);
20 |
21 | outColor0 = float4(newColor, 1.0);
22 | outColor1 = outColor0;
23 |
24 | // pixel luminance overdrive
25 | if(OverdriveInvRTSize.x > 0)
26 | {
27 | float3 oldColor = LastTexture.SampleLevel(Linear, oPosition.xy * OverdriveInvRTSize.xy, 0.0).rgb;
28 |
29 | float3 adjustedScales;
30 | adjustedScales.x = newColor.x > oldColor.x ? OverdriveScales.x : OverdriveScales.y;
31 | adjustedScales.y = newColor.y > oldColor.y ? OverdriveScales.x : OverdriveScales.y;
32 | adjustedScales.z = newColor.z > oldColor.z ? OverdriveScales.x : OverdriveScales.y;
33 |
34 | float3 overdriveColor = saturate(newColor + (newColor - oldColor) * adjustedScales);
35 | outColor1 = float4(overdriveColor, 1.0);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/Shaders/DistortionChroma_ps_refl.h:
--------------------------------------------------------------------------------
1 | #ifndef DistortionChroma_ps_refl
2 |
3 | const OVR::CAPI::D3D_NS::ShaderBase::Uniform DistortionChroma_ps_refl[] =
4 | {
5 | { "OverdriveInvRTSize", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 0, 8 },
6 | { "OverdriveScales", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 8, 8 },
7 | };
8 |
9 | #endif
10 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/Shaders/DistortionChroma_vs.vsh:
--------------------------------------------------------------------------------
1 | float2 EyeToSourceUVScale;
2 | float2 EyeToSourceUVOffset;
3 |
4 | void main(in float2 Position : POSITION,
5 | in float4 Color : COLOR0,
6 | in float2 TexCoord0 : TEXCOORD0,
7 | in float2 TexCoord1 : TEXCOORD1,
8 | in float2 TexCoord2 : TEXCOORD2,
9 | out float4 oPosition : SV_Position,
10 | out float1 oColor : COLOR,
11 | out float2 oTexCoord0 : TEXCOORD0,
12 | out float2 oTexCoord1 : TEXCOORD1,
13 | out float2 oTexCoord2 : TEXCOORD2)
14 | {
15 | oPosition.x = Position.x;
16 | oPosition.y = Position.y;
17 | oPosition.z = 0.5;
18 | oPosition.w = 1.0;
19 |
20 | // Scale them into UV lookup space
21 | float2 tc0scaled = EyeToSourceUVScale * TexCoord0 + EyeToSourceUVOffset;
22 | float2 tc1scaled = EyeToSourceUVScale * TexCoord1 + EyeToSourceUVOffset;
23 | float2 tc2scaled = EyeToSourceUVScale * TexCoord2 + EyeToSourceUVOffset;
24 |
25 | oTexCoord0 = tc0scaled; // R sample.
26 | oTexCoord1 = tc1scaled; // G sample.
27 | oTexCoord2 = tc2scaled; // B sample.
28 | oColor = Color.r; // Used for vignette fade.
29 | }
30 |
31 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/Shaders/DistortionChroma_vs_refl.h:
--------------------------------------------------------------------------------
1 | #ifndef DistortionChroma_vs_refl
2 |
3 | const OVR::CAPI::D3D_NS::ShaderBase::Uniform DistortionChroma_vs_refl[] =
4 | {
5 | { "EyeToSourceUVScale", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 0, 8 },
6 | { "EyeToSourceUVOffset", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 8, 8 },
7 | };
8 |
9 | #endif
10 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/Shaders/DistortionTimewarpChroma_vs.vsh:
--------------------------------------------------------------------------------
1 | float2 EyeToSourceUVScale;
2 | float2 EyeToSourceUVOffset;
3 | float4x4 EyeRotationStart;
4 | float4x4 EyeRotationEnd;
5 |
6 | float2 TimewarpTexCoordToWarpedPos(float2 inTexCoord, float4x4 rotMat)
7 | {
8 | // Vertex inputs are in TanEyeAngle space for the R,G,B channels (i.e. after chromatic aberration and distortion).
9 | // These are now "real world" vectors in direction (x,y,1) relative to the eye of the HMD.
10 | // Apply the 3x3 timewarp rotation to these vectors.
11 | float3 transformed = float3( mul ( rotMat, float4(inTexCoord.xy, 1, 1) ).xyz);
12 | // Project them back onto the Z=1 plane of the rendered images.
13 | float2 flattened = transformed.xy / transformed.z;
14 | // Scale them into ([0,0.5],[0,1]) or ([0.5,0],[0,1]) UV lookup space (depending on eye)
15 | return flattened * EyeToSourceUVScale + EyeToSourceUVOffset;
16 | }
17 |
18 | void main(in float2 Position : POSITION,
19 | in float4 Color : COLOR0,
20 | in float2 TexCoord0 : TEXCOORD0,
21 | in float2 TexCoord1 : TEXCOORD1,
22 | in float2 TexCoord2 : TEXCOORD2,
23 | out float4 oPosition : SV_Position,
24 | out float1 oColor : COLOR,
25 | out float2 oTexCoord0 : TEXCOORD0,
26 | out float2 oTexCoord1 : TEXCOORD1,
27 | out float2 oTexCoord2 : TEXCOORD2)
28 | {
29 | oPosition.x = Position.x;
30 | oPosition.y = Position.y;
31 | oPosition.z = 0.5;
32 | oPosition.w = 1.0;
33 |
34 | float timewarpLerpFactor = Color.a;
35 | float4x4 lerpedEyeRot = lerp(EyeRotationStart, EyeRotationEnd, timewarpLerpFactor);
36 |
37 | // warped positions are a bit more involved, hence a separate function
38 | oTexCoord0 = TimewarpTexCoordToWarpedPos(TexCoord0, lerpedEyeRot);
39 | oTexCoord1 = TimewarpTexCoordToWarpedPos(TexCoord1, lerpedEyeRot);
40 | oTexCoord2 = TimewarpTexCoordToWarpedPos(TexCoord2, lerpedEyeRot);
41 |
42 | oColor = Color.r; // Used for vignette fade.
43 | }
44 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/Shaders/DistortionTimewarpChroma_vs_refl.h:
--------------------------------------------------------------------------------
1 | #ifndef DistortionTimewarpChroma_vs_refl
2 |
3 | const OVR::CAPI::D3D_NS::ShaderBase::Uniform DistortionTimewarpChroma_vs_refl[] =
4 | {
5 | { "EyeToSourceUVScale", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 0, 8 },
6 | { "EyeToSourceUVOffset", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 8, 8 },
7 | { "EyeRotationStart", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 16, 64 },
8 | { "EyeRotationEnd", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 80, 64 },
9 | };
10 |
11 | #endif
12 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/Shaders/DistortionTimewarp_vs.vsh:
--------------------------------------------------------------------------------
1 | float2 EyeToSourceUVScale;
2 | float2 EyeToSourceUVOffset;
3 | float4x4 EyeRotationStart;
4 | float4x4 EyeRotationEnd;
5 |
6 | float2 TimewarpTexCoordToWarpedPos(float2 inTexCoord, float4x4 rotMat)
7 | {
8 | // Vertex inputs are in TanEyeAngle space for the R,G,B channels (i.e. after chromatic aberration and distortion).
9 | // These are now "real world" vectors in direction (x,y,1) relative to the eye of the HMD.
10 | // Apply the 3x3 timewarp rotation to these vectors.
11 | float3 transformed = float3( mul ( rotMat, float4(inTexCoord,1,1) ).xyz);
12 | // Project them back onto the Z=1 plane of the rendered images.
13 | float2 flattened = transformed.xy / transformed.z;
14 | // Scale them into ([0,0.5],[0,1]) or ([0.5,0],[0,1]) UV lookup space (depending on eye)
15 | return flattened * EyeToSourceUVScale + EyeToSourceUVOffset;
16 |
17 | }
18 |
19 | void main(in float2 Position : POSITION,
20 | in float4 Color : COLOR0,
21 | in float2 TexCoord0 : TEXCOORD0,
22 | out float4 oPosition : SV_Position,
23 | out float1 oColor : COLOR,
24 | out float2 oTexCoord0 : TEXCOORD0)
25 | {
26 |
27 | oPosition.x = Position.x;
28 | oPosition.y = Position.y;
29 | oPosition.z = 0.5;
30 | oPosition.w = 1.0;
31 |
32 | float timewarpLerpFactor = Color.a;
33 | float4x4 lerpedEyeRot = lerp(EyeRotationStart, EyeRotationEnd, timewarpLerpFactor);
34 |
35 | // Warped positions are a bit more involved, hence a separate function
36 | oTexCoord0 = TimewarpTexCoordToWarpedPos(TexCoord0, lerpedEyeRot);
37 | oColor = Color.r; // Used for vignette fade.
38 | }
39 |
40 |
41 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/Shaders/DistortionTimewarp_vs_refl.h:
--------------------------------------------------------------------------------
1 | #ifndef DistortionTimewarp_vs_refl
2 |
3 | const OVR::CAPI::D3D_NS::ShaderBase::Uniform DistortionTimewarp_vs_refl[] =
4 | {
5 | { "EyeToSourceUVScale", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 0, 8 },
6 | { "EyeToSourceUVOffset", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 8, 8 },
7 | { "EyeRotationStart", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 16, 64 },
8 | { "EyeRotationEnd", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 80, 64 },
9 | };
10 |
11 | #endif
12 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/Shaders/Distortion_ps.h:
--------------------------------------------------------------------------------
1 | #ifndef DISTORTION_PS_H
2 | #define DISTORTION_PS_H
3 |
4 | static const unsigned char Distortion_ps[] = {
5 | 0x44, 0x58, 0x42, 0x43, 0x7c, 0x85, 0xba, 0x67, 0x3a, 0xd7, 0x3f, 0x92,
6 | 0xa7, 0x4b, 0x33, 0x10, 0x5b, 0x1b, 0x09, 0x5d, 0x01, 0x00, 0x00, 0x00,
7 | 0xb4, 0x02, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,
8 | 0xd8, 0x00, 0x00, 0x00, 0x4c, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00,
9 | 0x38, 0x02, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0x9c, 0x00, 0x00, 0x00,
10 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
11 | 0x1c, 0x00, 0x00, 0x00, 0x00, 0x04, 0xff, 0xff, 0x00, 0x01, 0x00, 0x00,
12 | 0x6b, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
13 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14 | 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
15 | 0x63, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
16 | 0x04, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
17 | 0x01, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x4c, 0x69, 0x6e, 0x65,
18 | 0x61, 0x72, 0x00, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x00, 0x4d,
19 | 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29,
20 | 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72,
21 | 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39, 0x2e,
22 | 0x32, 0x39, 0x2e, 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00,
23 | 0x49, 0x53, 0x47, 0x4e, 0x6c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
24 | 0x08, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25 | 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26 | 0x0f, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27 | 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
28 | 0x01, 0x01, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29 | 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
30 | 0x06, 0x06, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74,
31 | 0x69, 0x6f, 0x6e, 0x00, 0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x00, 0x54, 0x45,
32 | 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0xab, 0x4f, 0x53, 0x47, 0x4e,
33 | 0x2c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
34 | 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35 | 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
36 | 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x00, 0xab, 0xab,
37 | 0x53, 0x48, 0x44, 0x52, 0xb0, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
38 | 0x2c, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x03, 0x00, 0x60, 0x10, 0x00,
39 | 0x00, 0x00, 0x00, 0x00, 0x58, 0x18, 0x00, 0x04, 0x00, 0x70, 0x10, 0x00,
40 | 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x62, 0x10, 0x00, 0x03,
41 | 0x12, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x62, 0x10, 0x00, 0x03,
42 | 0x62, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03,
43 | 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x02,
44 | 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x0b, 0xf2, 0x00, 0x10, 0x00,
45 | 0x00, 0x00, 0x00, 0x00, 0x96, 0x15, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
46 | 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x10, 0x00,
47 | 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48 | 0x38, 0x00, 0x00, 0x07, 0x72, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
49 | 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x10, 0x00,
50 | 0x01, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x82, 0x20, 0x10, 0x00,
51 | 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f,
52 | 0x3e, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, 0x54, 0x74, 0x00, 0x00, 0x00,
53 | 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
54 | 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
55 | 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
56 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
57 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
58 | 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
59 | 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
60 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
61 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
62 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
63 | };
64 |
65 | #endif
66 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/Shaders/Distortion_ps.psh:
--------------------------------------------------------------------------------
1 | Texture2D Texture : register(t0);
2 | SamplerState Linear : register(s0);
3 |
4 | float4 main(in float4 oPosition : SV_Position,
5 | in float1 oColor : COLOR,
6 | in float2 oTexCoord0 : TEXCOORD0) : SV_Target
7 | {
8 | float3 Result = Texture.SampleLevel(Linear, oTexCoord0, 0.0).rgb;
9 | return float4(Result * oColor, 1.0 );
10 | }
11 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/Shaders/Distortion_ps_refl.h:
--------------------------------------------------------------------------------
1 | // No data available for shader reflection Distortion_ps_refl
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/Shaders/Distortion_vs.vsh:
--------------------------------------------------------------------------------
1 | float2 EyeToSourceUVScale;
2 | float2 EyeToSourceUVOffset;
3 |
4 | void main(in float2 Position : POSITION,
5 | in float4 Color : COLOR0,
6 | in float2 TexCoord0 : TEXCOORD0,
7 | out float4 oPosition : SV_Position,
8 | out float1 oColor : COLOR,
9 | out float2 oTexCoord0 : TEXCOORD0)
10 | {
11 | oPosition.x = Position.x;
12 | oPosition.y = Position.y;
13 | oPosition.z = 0.5;
14 | oPosition.w = 1.0;
15 | oTexCoord0 = EyeToSourceUVScale * TexCoord0 + EyeToSourceUVOffset;
16 | oColor = Color.r; // Used for vignette fade.
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/Shaders/Distortion_vs_refl.h:
--------------------------------------------------------------------------------
1 | #ifndef Distortion_vs_refl
2 |
3 | const OVR::CAPI::D3D_NS::ShaderBase::Uniform Distortion_vs_refl[] =
4 | {
5 | { "EyeToSourceUVScale", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 0, 8 },
6 | { "EyeToSourceUVOffset", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 8, 8 },
7 | };
8 |
9 | #endif
10 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/Shaders/SimpleQuad_ps.h:
--------------------------------------------------------------------------------
1 | #ifndef SIMPLEQUAD_PS_H
2 | #define SIMPLEQUAD_PS_H
3 |
4 | static const unsigned char SimpleQuad_ps[] = {
5 | 0x44, 0x58, 0x42, 0x43, 0x8c, 0x53, 0x2f, 0x7c, 0x3d, 0xea, 0xa5, 0xb6,
6 | 0x05, 0xb7, 0xe0, 0x83, 0x67, 0x16, 0x9c, 0x93, 0x01, 0x00, 0x00, 0x00,
7 | 0x08, 0x02, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,
8 | 0x00, 0x01, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x44, 0x01, 0x00, 0x00,
9 | 0x8c, 0x01, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0xc4, 0x00, 0x00, 0x00,
10 | 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
11 | 0x1c, 0x00, 0x00, 0x00, 0x00, 0x04, 0xff, 0xff, 0x00, 0x01, 0x00, 0x00,
12 | 0x90, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14 | 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15 | 0x24, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x73, 0x00, 0xab, 0xab, 0xab,
16 | 0x3c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00,
17 | 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18 | 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
19 | 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20 | 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0xab, 0xab, 0x01, 0x00, 0x03, 0x00,
21 | 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22 | 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52,
23 | 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65,
24 | 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39,
25 | 0x2e, 0x32, 0x39, 0x2e, 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31,
26 | 0x00, 0xab, 0xab, 0xab, 0x49, 0x53, 0x47, 0x4e, 0x08, 0x00, 0x00, 0x00,
27 | 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x4f, 0x53, 0x47, 0x4e,
28 | 0x2c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
29 | 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30 | 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
31 | 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x00, 0xab, 0xab,
32 | 0x53, 0x48, 0x44, 0x52, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
33 | 0x10, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x04, 0x46, 0x8e, 0x20, 0x00,
34 | 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03,
35 | 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x06,
36 | 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00,
37 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x01,
38 | 0x53, 0x54, 0x41, 0x54, 0x74, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
39 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
40 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41 | 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45 | 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48 | 0x00, 0x00, 0x00, 0x00
49 | };
50 |
51 | #endif
52 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/Shaders/SimpleQuad_ps.psh:
--------------------------------------------------------------------------------
1 | float4 Color;
2 |
3 | float4 main() : SV_Target
4 | {
5 | return Color;
6 | }
7 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/Shaders/SimpleQuad_ps_refl.h:
--------------------------------------------------------------------------------
1 | #ifndef SimpleQuad_ps_refl
2 |
3 | const OVR::CAPI::D3D_NS::ShaderBase::Uniform SimpleQuad_ps_refl[] =
4 | {
5 | { "Color", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 0, 16 },
6 | };
7 |
8 | #endif
9 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/Shaders/SimpleQuad_vs.h:
--------------------------------------------------------------------------------
1 | #ifndef SIMPLEQUAD_VS_H
2 | #define SIMPLEQUAD_VS_H
3 |
4 | static const unsigned char SimpleQuad_vs[] = {
5 | 0x44, 0x58, 0x42, 0x43, 0xd5, 0x40, 0x5f, 0xa6, 0x2d, 0x0a, 0xd9, 0x2a,
6 | 0x84, 0x41, 0x9e, 0x1f, 0xab, 0xa5, 0xa9, 0x2c, 0x01, 0x00, 0x00, 0x00,
7 | 0xa8, 0x02, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,
8 | 0x38, 0x01, 0x00, 0x00, 0x6c, 0x01, 0x00, 0x00, 0xa0, 0x01, 0x00, 0x00,
9 | 0x2c, 0x02, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0xfc, 0x00, 0x00, 0x00,
10 | 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
11 | 0x1c, 0x00, 0x00, 0x00, 0x00, 0x04, 0xfe, 0xff, 0x00, 0x01, 0x00, 0x00,
12 | 0xc8, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
13 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
14 | 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15 | 0x24, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x73, 0x00, 0xab, 0xab, 0xab,
16 | 0x3c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00,
17 | 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
18 | 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
19 | 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0xb0, 0x00, 0x00, 0x00,
20 | 0xb8, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
21 | 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00,
22 | 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x66, 0x66, 0x73,
23 | 0x65, 0x74, 0x00, 0xab, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00,
24 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25 | 0x00, 0x00, 0x00, 0x00, 0x53, 0x63, 0x61, 0x6c, 0x65, 0x00, 0xab, 0xab,
26 | 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0x3f, 0x4d, 0x69, 0x63, 0x72,
27 | 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c,
28 | 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f,
29 | 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39, 0x2e, 0x32, 0x39, 0x2e,
30 | 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0xab, 0xab, 0xab,
31 | 0x49, 0x53, 0x47, 0x4e, 0x2c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
32 | 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33 | 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34 | 0x07, 0x03, 0x00, 0x00, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e,
35 | 0x00, 0xab, 0xab, 0xab, 0x4f, 0x53, 0x47, 0x4e, 0x2c, 0x00, 0x00, 0x00,
36 | 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
37 | 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
38 | 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x50,
39 | 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x53, 0x48, 0x44, 0x52,
40 | 0x84, 0x00, 0x00, 0x00, 0x40, 0x00, 0x01, 0x00, 0x21, 0x00, 0x00, 0x00,
41 | 0x59, 0x00, 0x00, 0x04, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
42 | 0x01, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00,
43 | 0x00, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x04, 0xf2, 0x20, 0x10, 0x00,
44 | 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0b,
45 | 0x32, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00,
46 | 0x00, 0x00, 0x00, 0x00, 0xe6, 0x8a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
47 | 0x00, 0x00, 0x00, 0x00, 0x46, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
48 | 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x08, 0xc2, 0x20, 0x10, 0x00,
49 | 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x80, 0x3f,
51 | 0x3e, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, 0x54, 0x74, 0x00, 0x00, 0x00,
52 | 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53 | 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
54 | 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
55 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
56 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
57 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
58 | 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
59 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
60 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
61 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
62 | };
63 |
64 | #endif
65 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/Shaders/SimpleQuad_vs.vsh:
--------------------------------------------------------------------------------
1 | float2 PositionOffset = float2(0, 0);
2 | float2 Scale = float2(1, 1);
3 |
4 | void main( in float3 Position : POSITION,
5 | out float4 oPosition : SV_Position)
6 | {
7 | oPosition = float4(Position.xy * Scale + PositionOffset, 0.5, 1.0);
8 | }
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/Shaders/SimpleQuad_vs_refl.h:
--------------------------------------------------------------------------------
1 | #ifndef SimpleQuad_vs_refl
2 |
3 | const OVR::CAPI::D3D_NS::ShaderBase::Uniform SimpleQuad_vs_refl[] =
4 | {
5 | { "PositionOffset", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 0, 8 },
6 | { "Scale", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 8, 8 },
7 | };
8 |
9 | #endif
10 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/Shaders/SimpleTexturedQuad_ps.psh:
--------------------------------------------------------------------------------
1 | float4 Color;
2 |
3 | SamplerState LinearSampler : register(s0);
4 | Texture2D Texture : register(t0);
5 |
6 | struct Values
7 | {
8 | float4 Position : SV_Position;
9 | float4 Color : COLOR0;
10 | float2 TexCoord : TEXCOORD0;
11 | };
12 |
13 | float4 main(in Values inputValues) : SV_Target
14 | {
15 | return Color * inputValues.Color * Texture.Sample(LinearSampler, inputValues.TexCoord);
16 | }
17 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/Shaders/SimpleTexturedQuad_ps_refl.h:
--------------------------------------------------------------------------------
1 | #ifndef SimpleTexturedQuad_ps_refl
2 |
3 | const OVR::CAPI::D3D_NS::ShaderBase::Uniform SimpleTexturedQuad_ps_refl[] =
4 | {
5 | { "Color", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 0, 16 },
6 | };
7 |
8 | #endif
9 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/Shaders/SimpleTexturedQuad_vs.vsh:
--------------------------------------------------------------------------------
1 | struct Values
2 | {
3 | float4 Position : SV_Position;
4 | float4 Color : COLOR0;
5 | float2 TexCoord : TEXCOORD0;
6 | };
7 |
8 | float2 PositionOffset = float2(0, 0);
9 | float2 Scale = float2(1, 1);
10 |
11 | void main(in float3 Position : POSITION, in float4 Color : COLOR0, in float2 TexCoord : TEXCOORD0, out Values outputValues)
12 | {
13 | outputValues.Position = float4(Position.xy * Scale + PositionOffset, 0.5, 1.0);
14 | outputValues.Color = Color;
15 | outputValues.TexCoord = TexCoord;
16 | }
17 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/Shaders/SimpleTexturedQuad_vs_refl.h:
--------------------------------------------------------------------------------
1 | #ifndef SimpleTexturedQuad_vs_refl
2 |
3 | const OVR::CAPI::D3D_NS::ShaderBase::Uniform SimpleTexturedQuad_vs_refl[] =
4 | {
5 | { "PositionOffset", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 0, 8 },
6 | { "Scale", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 8, 8 },
7 | };
8 |
9 | #endif
10 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/Shaders/genPixelShaderHeader.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | pushd %~dp0
3 | echo Compiling shader and packing into header: %~2
4 | setlocal
5 |
6 | set PATH=%PATH%;"%DXSDK_DIR%Utilities\bin\x86\"
7 | fxc.exe /nologo /E main /T ps_4_0 /Fo "%1" %2
8 | bin2header.exe "%1"
9 |
10 | echo Generating shader reflection data for %1
11 | ShaderReflector "%1" "%1_refl.h"
12 |
13 | del "%1"
14 | endlocal
15 | popd
16 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/CAPI/Shaders/genVertexShaderHeader.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | pushd %~dp0
3 | echo Compiling shader and packing into header: %~2
4 | setlocal
5 |
6 | set PATH=%PATH%;"%DXSDK_DIR%Utilities\bin\x86\"
7 | fxc.exe /nologo /E main /T vs_4_0 /Fo "%1" %2
8 | bin2header.exe "%1"
9 |
10 | echo Generating shader reflection data for %1
11 | ShaderReflector "%1" "%1_refl.h"
12 |
13 | del "%1"
14 | endlocal
15 | popd
16 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Displays/OVR_Display.cpp:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | PublicHeader: None
4 | Filename : OVR_Display.cpp
5 | Content : Common implementation for display device
6 | Created : May 6, 2014
7 | Notes :
8 |
9 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
10 |
11 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
12 | you may not use the Oculus VR Rift SDK except in compliance with the License,
13 | which is provided at the time of installation or download, or which
14 | otherwise accompanies this software in either electronic or hard copy form.
15 |
16 | You may obtain a copy of the License at
17 |
18 | http://www.oculusvr.com/licenses/LICENSE-3.1
19 |
20 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
21 | distributed under the License is distributed on an "AS IS" BASIS,
22 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 | See the License for the specific language governing permissions and
24 | limitations under the License.
25 |
26 | ************************************************************************************/
27 |
28 | #include "OVR_Display.h"
29 |
30 | namespace OVR {
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Displays/OVR_OSX_Display.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
Filename : OVR_OSX_Display.h
Content : OSX-specific Display declarations
Created : July 2, 2014
Authors : James Hughes
Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
you may not use the Oculus VR Rift SDK except in compliance with the License,
which is provided at the time of installation or download, or which
otherwise accompanies this software in either electronic or hard copy form.
You may obtain a copy of the License at
http://www.oculusvr.com/licenses/LICENSE-3.1
Unless required by applicable law or agreed to in writing, the Oculus VR SDK
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*************************************************************************************/
#ifndef OVR_OSX_Display_h
#define OVR_OSX_Display_h
#include "OVR_Display.h"
namespace OVR { namespace OSX {
//-------------------------------------------------------------------------------------
// DisplayDesc
// Display information enumerable through OS .
// TBD: Should we just move this to public header, so it's a const member of Display?
struct DisplayDesc
{
DisplayDesc() :
DeviceTypeGuess(HmdType_None),
DisplayID(0),
LogicalResolutionInPixels(0),
NativeResolutionInPixels(0)
{}
HmdTypeEnum DeviceTypeGuess;
uint32_t DisplayID; // This is the device identifier string from MONITORINFO (for app usage)
String ModelName; // This is a "DK2" type string
String EdidSerialNumber;
Sizei LogicalResolutionInPixels;
Sizei NativeResolutionInPixels;
Vector2i DesktopDisplayOffset;
};
//-------------------------------------------------------------------------------------
// DisplayEDID
// Describes EDID information as reported from our display driver.
struct DisplayEDID
{
DisplayEDID() :
ModelNumber(0)
{}
String MonitorName;
UInt16 ModelNumber;
String VendorName;
String SerialNumber;
};
//-------------------------------------------------------------------------------------
// OSX Display Search Handle
class OSXDisplaySearchHandle : public DisplaySearchHandle
{
public:
OSXDisplaySearchHandle() :
extended(false),
application(false),
extendedDisplayCount(0),
applicationDisplayCount(0),
displayCount(0)
{}
virtual ~OSXDisplaySearchHandle() {}
static const int DescArraySize = 16;
OSX::DisplayDesc cachedDescriptorArray[DescArraySize];
bool extended;
bool application;
int extendedDisplayCount;
int applicationDisplayCount;
int displayCount;
};
//-------------------------------------------------------------------------------------
// OSXDisplayGeneric
// Describes OSX display in Compatibility mode, containing basic data
class OSXDisplayGeneric : public Display
{
public:
OSXDisplayGeneric( const DisplayDesc& dd ) :
Display(dd.DeviceTypeGuess,
dd.DisplayID,
dd.ModelName,
dd.EdidSerialNumber,
dd.LogicalResolutionInPixels,
dd.NativeResolutionInPixels,
dd.DesktopDisplayOffset,
0,
0,
false)
{
}
virtual ~OSXDisplayGeneric()
{
}
virtual bool InCompatibilityMode() const
{
return true;
}
// Generic displays are not capable of mirroring
virtual MirrorMode SetMirrorMode( MirrorMode newMode )
{
OVR_UNUSED( newMode );
return MirrorDisabled;
}
};
}} // namespace OVR::OSX
#endif // OVR_OSX_Display_h
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Displays/OVR_Win32_FocusReader.cpp:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : OVR_Win32_FocusReader.cpp
4 | Content : Reader for current app with focus on Windows
5 | Created : July 2, 2014
6 | Authors : Chris Taylor
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | *************************************************************************************/
26 |
27 | #include "OVR_Win32_FocusReader.h"
28 | #include "../Kernel/OVR_Log.h"
29 | #include "../Service/Service_NetClient.h"
30 |
31 | OVR_DEFINE_SINGLETON(OVR::Win32::RenderFocusReader);
32 |
33 | namespace OVR { namespace Win32 {
34 |
35 |
36 | HWND RenderFocusReader::ReadActiveWindow()
37 | {
38 | FocusState = Reader.Get();
39 | if (!FocusState || NoSharedMemory)
40 | {
41 | if (!Reader.Open(OVR_FOCUS_OBSERVER_SHARE_NAME))
42 | {
43 | OVR_DEBUG_LOG(("[Win32ShimFunctions] Unable to open the shared memory space"));
44 | // Note: This should only warn and not assert because it is normal behavior when the server is not running.
45 | NoSharedMemory = true;
46 | return 0;
47 | }
48 |
49 | FocusState = Reader.Get();
50 | if (!FocusState)
51 | {
52 | OVR_DEBUG_LOG(("[Win32ShimFunctions] Unable to get the shared memory space"));
53 | NoSharedMemory = true;
54 | return 0;
55 | }
56 | }
57 |
58 | return (HWND)Ptr64ToPtr(FocusState->ActiveWindowHandle);
59 | }
60 |
61 | RenderFocusReader::RenderFocusReader()
62 | {
63 | NoSharedMemory = false;
64 |
65 | PushDestroyCallbacks();
66 | }
67 |
68 | RenderFocusReader::~RenderFocusReader()
69 | {
70 | }
71 |
72 | void RenderFocusReader::OnSystemDestroy()
73 | {
74 | delete this;
75 | }
76 |
77 |
78 |
79 |
80 | }} // namespace OVR::Win32
81 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Displays/OVR_Win32_FocusReader.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : OVR_Win32_FocusReader.h
4 | Content : Reader for current app with focus on Windows
5 | Created : July 2, 2014
6 | Authors : Chris Taylor
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | *************************************************************************************/
26 |
27 | #ifndef OVR_Win32_FocusReader_h
28 | #define OVR_Win32_FocusReader_h
29 |
30 | #include "../Kernel/OVR_System.h"
31 | #include "../Kernel/OVR_Lockless.h"
32 | #include "../Kernel/OVR_Array.h"
33 | #include "../Kernel/OVR_SharedMemory.h"
34 |
35 | namespace OVR { namespace Win32 {
36 |
37 |
38 | #define OVR_FOCUS_OBSERVER_SHARE_NAME "OVRAppFocus"
39 |
40 | //-----------------------------------------------------------------------------
41 | // LocklessFocusState
42 |
43 | #pragma pack(push, 8)
44 |
45 | // Focus state data
46 | struct LocklessFocusState
47 | {
48 | LocklessFocusState(DWORD pid = 0) :
49 | ActiveProcessId(pid),
50 | ActiveWindowHandle(NULL)
51 | {
52 | }
53 |
54 | DWORD ActiveProcessId;
55 | void * POINTER_64 ActiveWindowHandle;
56 | };
57 |
58 | #pragma pack(pop)
59 |
60 | typedef SharedObjectWriter< LocklessFocusState > SharedFocusWriter;
61 | typedef SharedObjectReader< LocklessFocusState > SharedFocusReader;
62 |
63 |
64 | //-----------------------------------------------------------------------------
65 | // RenderFocusReader
66 |
67 | class RenderFocusReader : public OVR::SystemSingletonBase
68 | {
69 | OVR_DECLARE_SINGLETON(RenderFocusReader);
70 |
71 | SharedFocusReader Reader; // Shared memory reader
72 | const LocklessFocusState* FocusState; // Pointer to the current focus state
73 | bool NoSharedMemory; // Flag reporting that no shared memory has been detected;
74 |
75 | public:
76 | HWND ReadActiveWindow();
77 | };
78 |
79 |
80 | }} // namespace OVR::Win32
81 |
82 | #endif // OVR_Win32_FocusReader_h
83 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Displays/OVR_Win32_ShimFunctions.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : OVR_Win32_ShimFunctions.h
4 | Content : Client-side shim callbacks for usermode/rt hooks
5 | Created : May 6, 2014
6 | Authors : Dean Beeler
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | *************************************************************************************/
26 |
27 | #ifndef OVR_Win32_ShimFunctions_h
28 | #define OVR_Win32_ShimFunctions_h
29 |
30 | #include "OVR_Win32_Display.h"
31 |
32 | namespace OVR {
33 |
34 | struct Win32ShimInfo;
35 |
36 | namespace Win32 {
37 |
38 |
39 | class DisplayShim
40 | {
41 | public:
42 |
43 | public:
44 | static DisplayShim& GetInstance()
45 | {
46 | static DisplayShim instance;
47 | return instance;
48 | }
49 |
50 | bool Initialize( bool inCompatibility );
51 | bool Shutdown();
52 |
53 | bool Update( Win32ShimInfo* shimInfo );
54 |
55 | void* GetDX11SwapChain();
56 |
57 | ULONG ChildUid;
58 | int ExpectedWidth;
59 | int ExpectedHeight;
60 | int Rotation;
61 | HWND hWindow;
62 | bool UseMirroring;
63 | bool Active;
64 |
65 | private:
66 |
67 | DisplayShim();
68 |
69 | virtual ~DisplayShim();
70 |
71 | DisplayShim(DisplayShim const&); // Don't Implement
72 | void operator=(DisplayShim const&); // Don't implement
73 |
74 | };
75 |
76 |
77 | }} // namespace OVR::Win32
78 |
79 | #endif
80 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Kernel/OVR_Alg.cpp:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : OVR_Alg.cpp
4 | Content : Static lookup tables for Alg functions
5 | Created : September 19, 2012
6 | Notes :
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | ************************************************************************************/
26 |
27 | #include "OVR_Types.h"
28 |
29 | namespace OVR { namespace Alg {
30 |
31 | //------------------------------------------------------------------------
32 | extern const uint8_t UpperBitTable[256] =
33 | {
34 | 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
35 | 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
36 | 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
37 | 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
38 | 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
39 | 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
40 | 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
41 | 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
42 | };
43 |
44 | extern const uint8_t LowerBitTable[256] =
45 | {
46 | 8,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
47 | 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
48 | 6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
49 | 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
50 | 7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
51 | 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
52 | 6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
53 | 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0
54 | };
55 |
56 |
57 | }} // OVE::Alg
58 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Kernel/OVR_Allocator.cpp:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : OVR_Allocator.cpp
4 | Content : Installable memory allocator implementation
5 | Created : September 19, 2012
6 | Notes :
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | ************************************************************************************/
26 |
27 | #include "OVR_Allocator.h"
28 | #ifdef OVR_OS_MAC
29 | #include
30 | #else
31 | #include
32 | #endif
33 |
34 | namespace OVR {
35 |
36 | //-----------------------------------------------------------------------------------
37 | // ***** Allocator
38 |
39 | Allocator* Allocator::pInstance = 0;
40 |
41 | // Default AlignedAlloc implementation will delegate to Alloc/Free after doing rounding.
42 | void* Allocator::AllocAligned(size_t size, size_t align)
43 | {
44 | OVR_ASSERT((align & (align-1)) == 0);
45 | align = (align > sizeof(size_t)) ? align : sizeof(size_t);
46 | size_t p = (size_t)Alloc(size+align);
47 | size_t aligned = 0;
48 | if (p)
49 | {
50 | aligned = (size_t(p) + align-1) & ~(align-1);
51 | if (aligned == p)
52 | aligned += align;
53 | *(((size_t*)aligned)-1) = aligned-p;
54 | }
55 | return (void*)aligned;
56 | }
57 |
58 | void Allocator::FreeAligned(void* p)
59 | {
60 | size_t src = size_t(p) - *(((size_t*)p)-1);
61 | Free((void*)src);
62 | }
63 |
64 |
65 | //------------------------------------------------------------------------
66 | // ***** Default Allocator
67 |
68 | // This allocator is created and used if no other allocator is installed.
69 | // Default allocator delegates to system malloc.
70 |
71 | void* DefaultAllocator::Alloc(size_t size)
72 | {
73 | return malloc(size);
74 | }
75 | void* DefaultAllocator::AllocDebug(size_t size, const char* file, unsigned line)
76 | {
77 | #if defined(OVR_CC_MSVC) && defined(_CRTDBG_MAP_ALLOC)
78 | return _malloc_dbg(size, _NORMAL_BLOCK, file, line);
79 | #else
80 | OVR_UNUSED2(file, line);
81 | return malloc(size);
82 | #endif
83 | }
84 |
85 | void* DefaultAllocator::Realloc(void* p, size_t newSize)
86 | {
87 | return realloc(p, newSize);
88 | }
89 | void DefaultAllocator::Free(void *p)
90 | {
91 | return free(p);
92 | }
93 |
94 |
95 | } // OVR
96 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Kernel/OVR_CRC32.cpp:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : OVR_CRC32.cpp
4 | Content : CRC-32 with polynomial used for sensor devices
5 | Created : June 20, 2014
6 | Author : Chris Taylor
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | ************************************************************************************/
26 |
27 | #include "OVR_CRC32.h"
28 |
29 | namespace OVR {
30 |
31 |
32 | static const uint32_t CRC_Table[256] = {
33 | 0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005,
34 | 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd,
35 | 0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9, 0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75,
36 | 0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3, 0x709f7b7a, 0x745e66cd,
37 | 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039, 0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5,
38 | 0xbe2b5b58, 0xbaea46ef, 0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d,
39 | 0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49, 0xc7361b4c, 0xc3f706fb, 0xceb42022, 0xca753d95,
40 | 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, 0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d,
41 | 0x34867077, 0x30476dc0, 0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072,
42 | 0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, 0x018aeb13, 0x054bf6a4, 0x0808d07d, 0x0cc9cdca,
43 | 0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde, 0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02,
44 | 0x5e9f46bf, 0x5a5e5b08, 0x571d7dd1, 0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba,
45 | 0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b, 0xbb60adfc, 0xb6238b25, 0xb2e29692,
46 | 0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6, 0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a,
47 | 0xe0b41de7, 0xe4750050, 0xe9362689, 0xedf73b3e, 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2,
48 | 0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34, 0xdc3abded, 0xd8fba05a,
49 | 0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637, 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb,
50 | 0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f, 0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53,
51 | 0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5, 0x3f9b762c, 0x3b5a6b9b,
52 | 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff, 0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623,
53 | 0xf12f560e, 0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b,
54 | 0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f, 0xc423cd6a, 0xc0e2d0dd, 0xcda1f604, 0xc960ebb3,
55 | 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, 0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b,
56 | 0x9b3660c6, 0x9ff77d71, 0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3,
57 | 0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640, 0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c,
58 | 0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8, 0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24,
59 | 0x119b4be9, 0x155a565e, 0x18197087, 0x1cd86d30, 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec,
60 | 0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d, 0x2056cd3a, 0x2d15ebe3, 0x29d4f654,
61 | 0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0, 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c,
62 | 0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18, 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4,
63 | 0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662, 0x933eb0bb, 0x97ffad0c,
64 | 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
65 | };
66 |
67 |
68 | //// CRC-32
69 |
70 | uint32_t CRC32_Calculate(const void* data, int bytes, uint32_t accumulator)
71 | {
72 | const uint8_t* inputBytes = reinterpret_cast( data );
73 |
74 | for (int j = 0; j < bytes; ++j)
75 | {
76 | int i = ((uint32_t)(accumulator >> 24) ^ *inputBytes++) & 0xFF;
77 |
78 | accumulator = (accumulator << 8) ^ CRC_Table[i];
79 | }
80 |
81 | return ~accumulator;
82 | }
83 |
84 |
85 | } // OVR
86 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Kernel/OVR_CRC32.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | PublicHeader: OVR
4 | Filename : OVR_CRC32.h
5 | Content : CRC-32 with polynomial used for sensor devices
6 | Created : June 20, 2014
7 | Author : Chris Taylor
8 |
9 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
10 |
11 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
12 | you may not use the Oculus VR Rift SDK except in compliance with the License,
13 | which is provided at the time of installation or download, or which
14 | otherwise accompanies this software in either electronic or hard copy form.
15 |
16 | You may obtain a copy of the License at
17 |
18 | http://www.oculusvr.com/licenses/LICENSE-3.1
19 |
20 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
21 | distributed under the License is distributed on an "AS IS" BASIS,
22 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 | See the License for the specific language governing permissions and
24 | limitations under the License.
25 |
26 | ************************************************************************************/
27 |
28 | #ifndef OVR_CRC32_h
29 | #define OVR_CRC32_h
30 |
31 | #include "OVR_Types.h"
32 |
33 | namespace OVR {
34 |
35 |
36 | //-----------------------------------------------------------------------------------
37 | // ***** CRC-32
38 |
39 | // Polynomial used and algorithm details are proprietary to our sensor board
40 | uint32_t CRC32_Calculate(const void* data, int bytes, uint32_t prevCRC = 0);
41 |
42 |
43 | } // namespace OVR
44 |
45 | #endif
46 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Kernel/OVR_Color.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | PublicHeader: OVR_Kernel.h
4 | Filename : OVR_Color.h
5 | Content : Contains color struct.
6 | Created : February 7, 2013
7 | Notes :
8 |
9 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
10 |
11 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
12 | you may not use the Oculus VR Rift SDK except in compliance with the License,
13 | which is provided at the time of installation or download, or which
14 | otherwise accompanies this software in either electronic or hard copy form.
15 |
16 | You may obtain a copy of the License at
17 |
18 | http://www.oculusvr.com/licenses/LICENSE-3.1
19 |
20 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
21 | distributed under the License is distributed on an "AS IS" BASIS,
22 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 | See the License for the specific language governing permissions and
24 | limitations under the License.
25 |
26 | ************************************************************************************/
27 | #ifndef OVR_Color_h
28 | #define OVR_Color_h
29 |
30 | #include "OVR_Types.h"
31 |
32 | namespace OVR {
33 |
34 |
35 | struct Color
36 | {
37 | uint8_t R,G,B,A;
38 |
39 | Color() {}
40 |
41 | // Constructs color by channel. Alpha is set to 0xFF (fully visible)
42 | // if not specified.
43 | Color(unsigned char r,unsigned char g,unsigned char b, unsigned char a = 0xFF)
44 | : R(r), G(g), B(b), A(a) { }
45 |
46 | // 0xAARRGGBB - Common HTML color Hex layout
47 | Color(unsigned c)
48 | : R((unsigned char)(c>>16)), G((unsigned char)(c>>8)),
49 | B((unsigned char)c), A((unsigned char)(c>>24)) { }
50 |
51 | bool operator==(const Color& b) const
52 | {
53 | return R == b.R && G == b.G && B == b.B && A == b.A;
54 | }
55 |
56 | void GetRGBA(float *r, float *g, float *b, float* a) const
57 | {
58 | *r = R / 255.0f;
59 | *g = G / 255.0f;
60 | *b = B / 255.0f;
61 | *a = A / 255.0f;
62 | }
63 | };
64 |
65 |
66 | } // namespace OVR
67 |
68 | #endif
69 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Kernel/OVR_Lockless.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | PublicHeader: OVR_Kernel.h
4 | Filename : OVR_Lockless.h
5 | Content : Lock-less classes for producer/consumer communication
6 | Created : November 9, 2013
7 | Authors : John Carmack
8 |
9 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
10 |
11 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
12 | you may not use the Oculus VR Rift SDK except in compliance with the License,
13 | which is provided at the time of installation or download, or which
14 | otherwise accompanies this software in either electronic or hard copy form.
15 |
16 | You may obtain a copy of the License at
17 |
18 | http://www.oculusvr.com/licenses/LICENSE-3.1
19 |
20 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
21 | distributed under the License is distributed on an "AS IS" BASIS,
22 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 | See the License for the specific language governing permissions and
24 | limitations under the License.
25 |
26 | *************************************************************************************/
27 |
28 | #ifndef OVR_Lockless_h
29 | #define OVR_Lockless_h
30 |
31 | #include "OVR_Atomic.h"
32 |
33 | // Define this to compile-in Lockless test logic
34 | //#define OVR_LOCKLESS_TEST
35 |
36 | namespace OVR {
37 |
38 |
39 | // ***** LocklessUpdater
40 |
41 | // For single producer cases where you only care about the most recent update, not
42 | // necessarily getting every one that happens (vsync timing, SensorFusion updates).
43 | //
44 | // This is multiple consumer safe, but is currently only used with a single consumer.
45 | //
46 | // The SlotType can be the same as T, but should probably be a larger fixed size.
47 | // This allows for forward compatibility when the updater is shared between processes.
48 |
49 | // FIXME: ExchangeAdd_Sync() should be replaced with a portable read-only primitive,
50 | // so that the lockless pose state can be read-only on remote processes and to reduce
51 | // false sharing between processes and improve performance.
52 |
53 | template
54 | class LocklessUpdater
55 | {
56 | public:
57 | LocklessUpdater() : UpdateBegin( 0 ), UpdateEnd( 0 )
58 | {
59 | OVR_COMPILER_ASSERT(sizeof(T) <= sizeof(SlotType));
60 | }
61 |
62 | T GetState() const
63 | {
64 | // Copy the state out, then retry with the alternate slot
65 | // if we determine that our copy may have been partially
66 | // stepped on by a new update.
67 | T state;
68 | int begin, end, final;
69 |
70 | for(;;)
71 | {
72 | // We are adding 0, only using these as atomic memory barriers, so it
73 | // is ok to cast off the const, allowing GetState() to remain const.
74 | end = UpdateEnd.ExchangeAdd_Sync(0);
75 | state = Slots[ end & 1 ];
76 | begin = UpdateBegin.ExchangeAdd_Sync(0);
77 | if ( begin == end ) {
78 | break;
79 | }
80 |
81 | // The producer is potentially blocked while only having partially
82 | // written the update, so copy out the other slot.
83 | state = Slots[ (begin & 1) ^ 1 ];
84 | final = UpdateBegin.ExchangeAdd_NoSync(0);
85 | if ( final == begin ) {
86 | break;
87 | }
88 |
89 | // The producer completed the last update and started a new one before
90 | // we got it copied out, so try fetching the current buffer again.
91 | }
92 | return state;
93 | }
94 |
95 | void SetState( T state )
96 | {
97 | const int slot = UpdateBegin.ExchangeAdd_Sync(1) & 1;
98 | // Write to (slot ^ 1) because ExchangeAdd returns 'previous' value before add.
99 | Slots[slot ^ 1] = state;
100 | UpdateEnd.ExchangeAdd_Sync(1);
101 | }
102 |
103 | mutable AtomicInt UpdateBegin;
104 | mutable AtomicInt UpdateEnd;
105 | SlotType Slots[2];
106 | };
107 |
108 |
109 | #ifdef OVR_LOCKLESS_TEST
110 | void StartLocklessTest();
111 | #endif
112 |
113 |
114 | } // namespace OVR
115 |
116 | #endif // OVR_Lockless_h
117 |
118 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Kernel/OVR_Math.cpp:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : OVR_Math.h
4 | Content : Implementation of 3D primitives such as vectors, matrices.
5 | Created : September 4, 2012
6 | Authors : Andrew Reisse, Michael Antonov, Anna Yershova
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | *************************************************************************************/
26 |
27 | #include "OVR_Math.h"
28 | #include "OVR_Log.h"
29 |
30 | #include
31 |
32 |
33 | namespace OVR {
34 |
35 |
36 | //-------------------------------------------------------------------------------------
37 | // ***** Constants
38 |
39 | template<>
40 | const Vector3 Vector3::ZERO = Vector3();
41 |
42 | template<>
43 | const Vector3 Vector3::ZERO = Vector3();
44 |
45 | template<>
46 | const Matrix4 Matrix4::IdentityValue = Matrix4(1.0f, 0.0f, 0.0f, 0.0f,
47 | 0.0f, 1.0f, 0.0f, 0.0f,
48 | 0.0f, 0.0f, 1.0f, 0.0f,
49 | 0.0f, 0.0f, 0.0f, 1.0f);
50 |
51 | template<>
52 | const Matrix4 Matrix4::IdentityValue = Matrix4(1.0, 0.0, 0.0, 0.0,
53 | 0.0, 1.0, 0.0, 0.0,
54 | 0.0, 0.0, 1.0, 0.0,
55 | 0.0, 0.0, 0.0, 1.0);
56 |
57 |
58 | } // Namespace OVR
59 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Kernel/OVR_RefCount.cpp:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : OVR_RefCount.cpp
4 | Content : Reference counting implementation
5 | Created : September 19, 2012
6 | Notes :
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | ************************************************************************************/
26 |
27 | #include "OVR_RefCount.h"
28 | #include "OVR_Atomic.h"
29 | #include "OVR_Log.h"
30 |
31 | namespace OVR {
32 |
33 | #ifdef OVR_CC_ARM
34 | void* ReturnArg0(void* p)
35 | {
36 | return p;
37 | }
38 | #endif
39 |
40 | // ***** Reference Count Base implementation
41 |
42 | RefCountImplCore::~RefCountImplCore()
43 | {
44 | // RefCount can be either 1 or 0 here.
45 | // 0 if Release() was properly called.
46 | // 1 if the object was declared on stack or as an aggregate.
47 | OVR_ASSERT(RefCount <= 1);
48 | }
49 |
50 | #ifdef OVR_BUILD_DEBUG
51 | void RefCountImplCore::reportInvalidDelete(void *pmem)
52 | {
53 | OVR_DEBUG_LOG(
54 | ("Invalid delete call on ref-counted object at %p. Please use Release()", pmem));
55 | OVR_ASSERT(0);
56 | }
57 | #endif
58 |
59 | RefCountNTSImplCore::~RefCountNTSImplCore()
60 | {
61 | // RefCount can be either 1 or 0 here.
62 | // 0 if Release() was properly called.
63 | // 1 if the object was declared on stack or as an aggregate.
64 | OVR_ASSERT(RefCount <= 1);
65 | }
66 |
67 | #ifdef OVR_BUILD_DEBUG
68 | void RefCountNTSImplCore::reportInvalidDelete(void *pmem)
69 | {
70 | OVR_DEBUG_LOG(
71 | ("Invalid delete call on ref-counted object at %p. Please use Release()", pmem));
72 | OVR_ASSERT(0);
73 | }
74 | #endif
75 |
76 |
77 | // *** Thread-Safe RefCountImpl
78 |
79 | void RefCountImpl::AddRef()
80 | {
81 | AtomicOps::ExchangeAdd_NoSync(&RefCount, 1);
82 | }
83 | void RefCountImpl::Release()
84 | {
85 | if ((AtomicOps::ExchangeAdd_NoSync(&RefCount, -1) - 1) == 0)
86 | delete this;
87 | }
88 |
89 | // *** Thread-Safe RefCountVImpl w/virtual AddRef/Release
90 |
91 | void RefCountVImpl::AddRef()
92 | {
93 | AtomicOps::ExchangeAdd_NoSync(&RefCount, 1);
94 | }
95 | void RefCountVImpl::Release()
96 | {
97 | if ((AtomicOps::ExchangeAdd_NoSync(&RefCount, -1) - 1) == 0)
98 | delete this;
99 | }
100 |
101 | // *** NON-Thread-Safe RefCountImpl
102 |
103 | void RefCountNTSImpl::Release() const
104 | {
105 | RefCount--;
106 | if (RefCount == 0)
107 | delete this;
108 | }
109 |
110 |
111 | } // OVR
112 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Kernel/OVR_StringHash.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | PublicHeader: None
4 | Filename : OVR_StringHash.h
5 | Content : String hash table used when optional case-insensitive
6 | lookup is required.
7 | Created : September 19, 2012
8 | Notes :
9 |
10 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
11 |
12 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
13 | you may not use the Oculus VR Rift SDK except in compliance with the License,
14 | which is provided at the time of installation or download, or which
15 | otherwise accompanies this software in either electronic or hard copy form.
16 |
17 | You may obtain a copy of the License at
18 |
19 | http://www.oculusvr.com/licenses/LICENSE-3.1
20 |
21 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
22 | distributed under the License is distributed on an "AS IS" BASIS,
23 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 | See the License for the specific language governing permissions and
25 | limitations under the License.
26 |
27 | ************************************************************************************/
28 |
29 | #ifndef OVR_StringHash_h
30 | #define OVR_StringHash_h
31 |
32 | #include "OVR_String.h"
33 | #include "OVR_Hash.h"
34 |
35 | namespace OVR {
36 |
37 | //-----------------------------------------------------------------------------------
38 | // *** StringHash
39 |
40 | // This is a custom string hash table that supports case-insensitive
41 | // searches through special functions such as GetCaseInsensitive, etc.
42 | // This class is used for Flash labels, exports and other case-insensitive tables.
43 |
44 | template >
45 | class StringHash : public Hash
46 | {
47 | public:
48 | typedef U ValueType;
49 | typedef StringHash SelfType;
50 | typedef Hash BaseType;
51 |
52 | public:
53 |
54 | void operator = (const SelfType& src) { BaseType::operator = (src); }
55 |
56 | bool GetCaseInsensitive(const String& key, U* pvalue) const
57 | {
58 | String::NoCaseKey ikey(key);
59 | return BaseType::GetAlt(ikey, pvalue);
60 | }
61 | // Pointer-returning get variety.
62 | const U* GetCaseInsensitive(const String& key) const
63 | {
64 | String::NoCaseKey ikey(key);
65 | return BaseType::GetAlt(ikey);
66 | }
67 | U* GetCaseInsensitive(const String& key)
68 | {
69 | String::NoCaseKey ikey(key);
70 | return BaseType::GetAlt(ikey);
71 | }
72 |
73 |
74 | typedef typename BaseType::Iterator base_iterator;
75 |
76 | base_iterator FindCaseInsensitive(const String& key)
77 | {
78 | String::NoCaseKey ikey(key);
79 | return BaseType::FindAlt(ikey);
80 | }
81 |
82 | // Set just uses a find and assigns value if found. The key is not modified;
83 | // this behavior is identical to Flash string variable assignment.
84 | void SetCaseInsensitive(const String& key, const U& value)
85 | {
86 | base_iterator it = FindCaseInsensitive(key);
87 | if (it != BaseType::End())
88 | {
89 | it->Second = value;
90 | }
91 | else
92 | {
93 | BaseType::Add(key, value);
94 | }
95 | }
96 | };
97 |
98 | } // OVR
99 |
100 | #endif
101 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Kernel/OVR_String_FormatUtil.cpp:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : OVR_String_FormatUtil.cpp
4 | Content : String format functions.
5 | Created : February 27, 2013
6 | Notes :
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | ************************************************************************************/
26 |
27 | #include "OVR_String.h"
28 | #include "OVR_Log.h"
29 |
30 | namespace OVR {
31 |
32 | void StringBuffer::AppendFormat(const char* format, ...)
33 | {
34 | va_list argList;
35 |
36 | va_start(argList, format);
37 | size_t size = OVR_vscprintf(format, argList);
38 | va_end(argList);
39 |
40 | char* buffer = (char*) OVR_ALLOC(sizeof(char) * (size+1));
41 |
42 | va_start(argList, format);
43 | size_t result = OVR_vsprintf(buffer, size+1, format, argList);
44 | OVR_UNUSED1(result);
45 | va_end(argList);
46 | OVR_ASSERT_LOG(result == size, ("Error in OVR_vsprintf"));
47 |
48 | AppendString(buffer);
49 |
50 | OVR_FREE(buffer);
51 | }
52 |
53 | } // OVR
54 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Kernel/OVR_SysFile.cpp:
--------------------------------------------------------------------------------
1 | /**************************************************************************
2 |
3 | Filename : OVR_SysFile.cpp
4 | Content : File wrapper class implementation (Win32)
5 |
6 | Created : April 5, 1999
7 | Authors : Michael Antonov
8 |
9 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
10 |
11 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
12 | you may not use the Oculus VR Rift SDK except in compliance with the License,
13 | which is provided at the time of installation or download, or which
14 | otherwise accompanies this software in either electronic or hard copy form.
15 |
16 | You may obtain a copy of the License at
17 |
18 | http://www.oculusvr.com/licenses/LICENSE-3.1
19 |
20 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
21 | distributed under the License is distributed on an "AS IS" BASIS,
22 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 | See the License for the specific language governing permissions and
24 | limitations under the License.
25 |
26 | **************************************************************************/
27 |
28 | #define GFILE_CXX
29 |
30 | // Standard C library (Captain Obvious guarantees!)
31 | #include
32 |
33 | #include "OVR_SysFile.h"
34 | #include "OVR_Log.h"
35 |
36 | namespace OVR {
37 |
38 | // This is - a dummy file that fails on all calls.
39 |
40 | class UnopenedFile : public File
41 | {
42 | public:
43 | UnopenedFile() { }
44 | ~UnopenedFile() { }
45 |
46 | virtual const char* GetFilePath() { return 0; }
47 |
48 | // ** File Information
49 | virtual bool IsValid() { return 0; }
50 | virtual bool IsWritable() { return 0; }
51 |
52 | // Return position / file size
53 | virtual int Tell() { return 0; }
54 | virtual int64_t LTell() { return 0; }
55 | virtual int GetLength() { return 0; }
56 | virtual int64_t LGetLength() { return 0; }
57 |
58 | // virtual bool Stat(FileStats *pfs) { return 0; }
59 | virtual int GetErrorCode() { return Error_FileNotFound; }
60 |
61 | // ** Stream implementation & I/O
62 | virtual int Write(const uint8_t *pbuffer, int numBytes) { return -1; OVR_UNUSED2(pbuffer, numBytes); }
63 | virtual int Read(uint8_t *pbuffer, int numBytes) { return -1; OVR_UNUSED2(pbuffer, numBytes); }
64 | virtual int SkipBytes(int numBytes) { return 0; OVR_UNUSED(numBytes); }
65 | virtual int BytesAvailable() { return 0; }
66 | virtual bool Flush() { return 0; }
67 | virtual int Seek(int offset, int origin) { return -1; OVR_UNUSED2(offset, origin); }
68 | virtual int64_t LSeek(int64_t offset, int origin) { return -1; OVR_UNUSED2(offset, origin); }
69 |
70 | virtual int CopyFromStream(File *pstream, int byteSize) { return -1; OVR_UNUSED2(pstream, byteSize); }
71 | virtual bool Close() { return 0; }
72 | };
73 |
74 |
75 |
76 | // ***** System File
77 |
78 | // System file is created to access objects on file system directly
79 | // This file can refer directly to path
80 |
81 | // ** Constructor
82 | SysFile::SysFile() : DelegatedFile(0)
83 | {
84 | pFile = *new UnopenedFile;
85 | }
86 |
87 | Ptr FileFILEOpen(const String& path, int flags, int mode);
88 |
89 | // Opens a file
90 | SysFile::SysFile(const String& path, int flags, int mode) : DelegatedFile(0)
91 | {
92 | Open(path, flags, mode);
93 | }
94 |
95 |
96 | // ** Open & management
97 | // Will fail if file's already open
98 | bool SysFile::Open(const String& path, int flags, int mode)
99 | {
100 | pFile = FileFILEOpen(path, flags, mode);
101 | if ((!pFile) || (!pFile->IsValid()))
102 | {
103 | pFile = *new UnopenedFile;
104 | OVR_DEBUG_LOG(("Failed to open file: %s", path.ToCStr()));
105 | return 0;
106 | }
107 | //pFile = *OVR_NEW DelegatedFile(pFile); // MA Testing
108 | if (flags & Open_Buffered)
109 | pFile = *new BufferedFile(pFile);
110 | return 1;
111 | }
112 |
113 |
114 | // ** Overrides
115 |
116 | int SysFile::GetErrorCode()
117 | {
118 | return pFile ? pFile->GetErrorCode() : Error_FileNotFound;
119 | }
120 |
121 |
122 | // Overrides to provide re-open support
123 | bool SysFile::IsValid()
124 | {
125 | return pFile && pFile->IsValid();
126 | }
127 | bool SysFile::Close()
128 | {
129 | if (IsValid())
130 | {
131 | DelegatedFile::Close();
132 | pFile = *new UnopenedFile;
133 | return 1;
134 | }
135 | return 0;
136 | }
137 |
138 | } // OVR
139 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Kernel/OVR_SysFile.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | PublicHeader: Kernel
4 | Filename : OVR_SysFile.h
5 | Content : Header for all internal file management - functions and structures
6 | to be inherited by OS specific subclasses.
7 | Created : September 19, 2012
8 | Notes :
9 |
10 | Notes : errno may not be preserved across use of GBaseFile member functions
11 | : Directories cannot be deleted while files opened from them are in use
12 | (For the GetFullName function)
13 |
14 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
15 |
16 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
17 | you may not use the Oculus VR Rift SDK except in compliance with the License,
18 | which is provided at the time of installation or download, or which
19 | otherwise accompanies this software in either electronic or hard copy form.
20 |
21 | You may obtain a copy of the License at
22 |
23 | http://www.oculusvr.com/licenses/LICENSE-3.1
24 |
25 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
26 | distributed under the License is distributed on an "AS IS" BASIS,
27 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28 | See the License for the specific language governing permissions and
29 | limitations under the License.
30 |
31 | ************************************************************************************/
32 |
33 | #ifndef OVR_SysFile_h
34 | #define OVR_SysFile_h
35 |
36 | #include "OVR_File.h"
37 |
38 | namespace OVR {
39 |
40 | // ***** Declared classes
41 | class SysFile;
42 |
43 | //-----------------------------------------------------------------------------------
44 | // *** File Statistics
45 |
46 | // This class contents are similar to _stat, providing
47 | // creation, modify and other information about the file.
48 | struct FileStat
49 | {
50 | // No change or create time because they are not available on most systems
51 | int64_t ModifyTime;
52 | int64_t AccessTime;
53 | int64_t FileSize;
54 |
55 | bool operator== (const FileStat& stat) const
56 | {
57 | return ( (ModifyTime == stat.ModifyTime) &&
58 | (AccessTime == stat.AccessTime) &&
59 | (FileSize == stat.FileSize) );
60 | }
61 | };
62 |
63 | //-----------------------------------------------------------------------------------
64 | // *** System File
65 |
66 | // System file is created to access objects on file system directly
67 | // This file can refer directly to path.
68 | // System file can be open & closed several times; however, such use is not recommended
69 | // This class is realy a wrapper around an implementation of File interface for a
70 | // particular platform.
71 |
72 | class SysFile : public DelegatedFile
73 | {
74 | protected:
75 | SysFile(const SysFile &source) : DelegatedFile () { OVR_UNUSED(source); }
76 | public:
77 |
78 | // ** Constructor
79 | SysFile();
80 | // Opens a file
81 | SysFile(const String& path, int flags = Open_Read|Open_Buffered, int mode = Mode_ReadWrite);
82 |
83 | // ** Open & management
84 | bool Open(const String& path, int flags = Open_Read|Open_Buffered, int mode = Mode_ReadWrite);
85 |
86 | OVR_FORCE_INLINE bool Create(const String& path, int mode = Mode_ReadWrite)
87 | { return Open(path, Open_ReadWrite|Open_Create, mode); }
88 |
89 | // Helper function: obtain file statistics information. In OVR, this is used to detect file changes.
90 | // Return 0 if function failed, most likely because the file doesn't exist.
91 | static bool OVR_CDECL GetFileStat(FileStat* pfileStats, const String& path);
92 |
93 | // ** Overrides
94 | // Overridden to provide re-open support
95 | virtual int GetErrorCode();
96 |
97 | virtual bool IsValid();
98 |
99 | virtual bool Close();
100 | };
101 |
102 | } // Namespace OVR
103 |
104 | #endif
105 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Kernel/OVR_System.cpp:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : OVR_System.cpp
4 | Content : General kernel initialization/cleanup, including that
5 | of the memory allocator.
6 | Created : September 19, 2012
7 | Notes :
8 |
9 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
10 |
11 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
12 | you may not use the Oculus VR Rift SDK except in compliance with the License,
13 | which is provided at the time of installation or download, or which
14 | otherwise accompanies this software in either electronic or hard copy form.
15 |
16 | You may obtain a copy of the License at
17 |
18 | http://www.oculusvr.com/licenses/LICENSE-3.1
19 |
20 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
21 | distributed under the License is distributed on an "AS IS" BASIS,
22 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 | See the License for the specific language governing permissions and
24 | limitations under the License.
25 |
26 | ************************************************************************************/
27 |
28 | #include "OVR_System.h"
29 | #include "OVR_Threads.h"
30 | #include "OVR_Timer.h"
31 | #include "../Displays/OVR_Display.h"
32 | #ifdef OVR_OS_WIN32
33 | #include "../Displays/OVR_Win32_ShimFunctions.h"
34 | #endif
35 |
36 | namespace OVR {
37 |
38 | extern bool anyRiftsInExtendedMode();
39 |
40 | // Stack of destroy listeners (push/pop semantics)
41 | static SystemSingletonInternal *SystemShutdownListenerStack = 0;
42 | static Lock stackLock;
43 |
44 | void SystemSingletonInternal::PushDestroyCallbacks()
45 | {
46 | Lock::Locker locker(&stackLock);
47 |
48 | // Push listener onto the stack
49 | NextSingleton = SystemShutdownListenerStack;
50 | SystemShutdownListenerStack = this;
51 | }
52 |
53 | void System::DirectDisplayInitialize()
54 | {
55 | #ifdef OVR_OS_WIN32
56 | // Set up display code for Windows
57 | Win32::DisplayShim::GetInstance();
58 |
59 | // This code will look for the first display. If it's a display
60 | // that's extending the destkop, the code will assume we're in
61 | // compatibility mode. Compatibility mode prevents shim loading
62 | // and renders only to extended Rifts.
63 | // If we find a display and it's application exclusive,
64 | // we load the shim so we can render to it.
65 | // If no display is available, we revert to whatever the
66 | // driver tells us we're in
67 |
68 | bool anyExtendedRifts = anyRiftsInExtendedMode() || Display::InCompatibilityMode( false );
69 |
70 | Win32::DisplayShim::GetInstance().Initialize(anyExtendedRifts);
71 | #endif
72 | }
73 |
74 | // Initializes System core, installing allocator.
75 | void System::Init(Log* log, Allocator *palloc)
76 | {
77 | if (!Allocator::GetInstance())
78 | {
79 | Log::SetGlobalLog(log);
80 | Timer::initializeTimerSystem();
81 | Allocator::setInstance(palloc);
82 | Display::Initialize();
83 | DirectDisplayInitialize();
84 | }
85 | else
86 | {
87 | OVR_DEBUG_LOG(("System::Init failed - duplicate call."));
88 | }
89 | }
90 |
91 | void System::Destroy()
92 | {
93 | if (Allocator::GetInstance())
94 | {
95 | #ifdef OVR_OS_WIN32
96 | Win32::DisplayShim::GetInstance().Shutdown();
97 | #endif
98 |
99 | // Invoke all of the post-finish callbacks (normal case)
100 | for (SystemSingletonInternal *listener = SystemShutdownListenerStack; listener; listener = listener->NextSingleton)
101 | {
102 | listener->OnThreadDestroy();
103 | }
104 |
105 | #ifdef OVR_ENABLE_THREADS
106 | // Wait for all threads to finish; this must be done so that memory
107 | // allocator and all destructors finalize correctly.
108 | Thread::FinishAllThreads();
109 | #endif
110 |
111 | // Invoke all of the post-finish callbacks (normal case)
112 | for (SystemSingletonInternal *next, *listener = SystemShutdownListenerStack; listener; listener = next)
113 | {
114 | next = listener->NextSingleton;
115 |
116 | listener->OnSystemDestroy();
117 | }
118 |
119 | SystemShutdownListenerStack = 0;
120 |
121 | // Shutdown heap and destroy SysAlloc singleton, if any.
122 | Allocator::GetInstance()->onSystemShutdown();
123 | Allocator::setInstance(0);
124 |
125 | Timer::shutdownTimerSystem();
126 | Log::SetGlobalLog(Log::GetDefaultLog());
127 | }
128 | else
129 | {
130 | OVR_DEBUG_LOG(("System::Destroy failed - System not initialized."));
131 | }
132 | }
133 |
134 | // Returns 'true' if system was properly initialized.
135 | bool System::IsInitialized()
136 | {
137 | return Allocator::GetInstance() != 0;
138 | }
139 |
140 |
141 | } // namespace OVR
142 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Kernel/OVR_Timer.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | PublicHeader: OVR
4 | Filename : OVR_Timer.h
5 | Content : Provides static functions for precise timing
6 | Created : September 19, 2012
7 | Notes :
8 |
9 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
10 |
11 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
12 | you may not use the Oculus VR Rift SDK except in compliance with the License,
13 | which is provided at the time of installation or download, or which
14 | otherwise accompanies this software in either electronic or hard copy form.
15 |
16 | You may obtain a copy of the License at
17 |
18 | http://www.oculusvr.com/licenses/LICENSE-3.1
19 |
20 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
21 | distributed under the License is distributed on an "AS IS" BASIS,
22 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 | See the License for the specific language governing permissions and
24 | limitations under the License.
25 |
26 | ************************************************************************************/
27 |
28 | #ifndef OVR_Timer_h
29 | #define OVR_Timer_h
30 |
31 | #include "OVR_Types.h"
32 |
33 | namespace OVR {
34 |
35 | //-----------------------------------------------------------------------------------
36 | // ***** Timer
37 |
38 | // Timer class defines a family of static functions used for application
39 | // timing and profiling.
40 |
41 | class Timer
42 | {
43 | public:
44 | enum {
45 | MsPerSecond = 1000, // Milliseconds in one second.
46 | NanosPerSecond = MsPerSecond * 1000 * 1000,
47 | MksPerSecond = MsPerSecond * 1000
48 | };
49 |
50 | // ***** Timing APIs for Application
51 |
52 | // These APIs should be used to guide animation and other program functions
53 | // that require precision.
54 |
55 | // Returns global high-resolution application timer in seconds.
56 | static double OVR_STDCALL GetSeconds();
57 |
58 | // Returns time in Nanoseconds, using highest possible system resolution.
59 | static uint64_t OVR_STDCALL GetTicksNanos();
60 |
61 | // Kept for compatibility.
62 | // Returns ticks in milliseconds, as a 32-bit number. May wrap around every 49.2 days.
63 | // Use either time difference of two values of GetTicks to avoid wrap-around.
64 | static uint32_t OVR_STDCALL GetTicksMs()
65 | { return uint32_t(GetTicksNanos() / 1000000); }
66 |
67 | // for recorded data playback
68 | static void SetFakeSeconds(double fakeSeconds)
69 | {
70 | FakeSeconds = fakeSeconds;
71 | useFakeSeconds = true;
72 | }
73 |
74 | private:
75 | friend class System;
76 | // System called during program startup/shutdown.
77 | static void initializeTimerSystem();
78 | static void shutdownTimerSystem();
79 |
80 | // for recorded data playback
81 | static double FakeSeconds;
82 | static bool useFakeSeconds;
83 | };
84 |
85 |
86 | } // OVR::Timer
87 |
88 | #endif
89 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Kernel/OVR_UTF8Util.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | PublicHeader: OVR_Kernel.h
4 | Filename : OVR_UTF8Util.h
5 | Content : UTF8 Unicode character encoding/decoding support
6 | Created : September 19, 2012
7 | Notes :
8 |
9 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
10 |
11 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
12 | you may not use the Oculus VR Rift SDK except in compliance with the License,
13 | which is provided at the time of installation or download, or which
14 | otherwise accompanies this software in either electronic or hard copy form.
15 |
16 | You may obtain a copy of the License at
17 |
18 | http://www.oculusvr.com/licenses/LICENSE-3.1
19 |
20 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
21 | distributed under the License is distributed on an "AS IS" BASIS,
22 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 | See the License for the specific language governing permissions and
24 | limitations under the License.
25 |
26 | ************************************************************************************/
27 |
28 | #ifndef OVR_UTF8Util_h
29 | #define OVR_UTF8Util_h
30 |
31 | #include "OVR_Types.h"
32 |
33 | namespace OVR { namespace UTF8Util {
34 |
35 | //-----------------------------------------------------------------------------------
36 |
37 | // *** UTF8 string length and indexing.
38 |
39 | // Determines the length of UTF8 string in characters.
40 | // If source length is specified (in bytes), null 0 character is counted properly.
41 | intptr_t OVR_STDCALL GetLength(const char* putf8str, intptr_t length = -1);
42 |
43 | // Gets a decoded UTF8 character at index; you can access up to the index returned
44 | // by GetLength. 0 will be returned for out of bounds access.
45 | uint32_t OVR_STDCALL GetCharAt(intptr_t index, const char* putf8str, intptr_t length = -1);
46 |
47 | // Converts UTF8 character index into byte offset.
48 | // -1 is returned if index was out of bounds.
49 | intptr_t OVR_STDCALL GetByteIndex(intptr_t index, const char* putf8str, intptr_t length = -1);
50 |
51 |
52 | // *** 16-bit Unicode string Encoding/Decoding routines.
53 |
54 | // Determines the number of bytes necessary to encode a string.
55 | // Does not count the terminating 0 (null) character.
56 | intptr_t OVR_STDCALL GetEncodeStringSize(const wchar_t* pchar, intptr_t length = -1);
57 |
58 | // Encodes a unicode (UCS-2 only) string into a buffer. The size of buffer must be at
59 | // least GetEncodeStringSize() + 1.
60 | void OVR_STDCALL EncodeString(char *pbuff, const wchar_t* pchar, intptr_t length = -1);
61 |
62 | // Decode UTF8 into a wchar_t buffer. Must have GetLength()+1 characters available.
63 | // Characters over 0xFFFF are replaced with 0xFFFD.
64 | // Returns the length of resulting string (number of characters)
65 | size_t OVR_STDCALL DecodeString(wchar_t *pbuff, const char* putf8str, intptr_t bytesLen = -1);
66 |
67 |
68 | // *** Individual character Encoding/Decoding.
69 |
70 | // Determined the number of bytes necessary to encode a UCS character.
71 | int OVR_STDCALL GetEncodeCharSize(uint32_t ucsCharacter);
72 |
73 | // Encodes the given UCS character into the given UTF-8 buffer.
74 | // Writes the data starting at buffer[offset], and
75 | // increments offset by the number of bytes written.
76 | // May write up to 6 bytes, so make sure there's room in the buffer
77 | void OVR_STDCALL EncodeChar(char* pbuffer, intptr_t* poffset, uint32_t ucsCharacter);
78 |
79 | // Return the next Unicode character in the UTF-8 encoded buffer.
80 | // Invalid UTF-8 sequences produce a U+FFFD character as output.
81 | // Advances *utf8_buffer past the character returned. Pointer advance
82 | // occurs even if the terminating 0 character is hit, since that allows
83 | // strings with middle '\0' characters to be supported.
84 | uint32_t OVR_STDCALL DecodeNextChar_Advance0(const char** putf8Buffer);
85 |
86 | // Safer version of DecodeNextChar, which doesn't advance pointer if
87 | // null character is hit.
88 | inline uint32_t DecodeNextChar(const char** putf8Buffer)
89 | {
90 | uint32_t ch = DecodeNextChar_Advance0(putf8Buffer);
91 | if (ch == 0)
92 | (*putf8Buffer)--;
93 | return ch;
94 | }
95 |
96 |
97 | }} // OVR::UTF8Util
98 |
99 | #endif
100 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Net/OVR_MessageIDTypes.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : OVR_MessageIDTypes.h
4 | Content : Enumeration list indicating what type of message is being sent
5 | Created : July 3, 2014
6 | Authors : Kevin Jenkins
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | ************************************************************************************/
26 |
27 | namespace OVR { namespace Net {
28 |
29 | /// First byte of a network message
30 | typedef unsigned char MessageID;
31 |
32 | enum DefaultMessageIDTypes
33 | {
34 | OVRID_RPC1,
35 | OVRID_END = 128,
36 | OVRID_LATENCY_TESTER_1,
37 | };
38 |
39 | }} // namespace OVR::Net
40 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Net/OVR_NetworkPlugin.cpp:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : OVR_NetworkPlugin.cpp
4 | Content : Base class for an extension to the network objects.
5 | Created : June 10, 2014
6 | Authors : Kevin Jenkins
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | ************************************************************************************/
26 |
27 | #include "OVR_NetworkPlugin.h"
28 |
29 | namespace OVR { namespace Net { namespace Plugins {
30 |
31 |
32 | //-----------------------------------------------------------------------------
33 | // Plugin identifier to assign next
34 |
35 | //static uint8_t pluginIdNext = 0;
36 |
37 |
38 | //-----------------------------------------------------------------------------
39 | // NetworkPlugin
40 |
41 | NetworkPlugin::NetworkPlugin()
42 | {
43 | pSession = 0;
44 | //PluginId = pluginIdNext++;
45 | }
46 |
47 | NetworkPlugin::~NetworkPlugin()
48 | {
49 | }
50 |
51 | void NetworkPlugin::OnAddedToSession(Session* _pSession)
52 | {
53 | if (pSession != 0)
54 | {
55 | pSession->RemoveSessionListener(this);
56 | }
57 |
58 | pSession = _pSession;
59 | }
60 |
61 | void NetworkPlugin::OnRemovedFromSession(Session* _pSession)
62 | {
63 | OVR_UNUSED(_pSession);
64 | OVR_ASSERT(_pSession == pSession);
65 |
66 | pSession = 0;
67 | }
68 |
69 |
70 | }}} // OVR::Net::Plugins
71 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Net/OVR_NetworkPlugin.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | PublicHeader: n/a
4 | Filename : OVR_NetworkPlugin.h
5 | Content : Base class for an extension to the network objects.
6 | Created : June 10, 2014
7 | Authors : Kevin Jenkins
8 |
9 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
10 |
11 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
12 | you may not use the Oculus VR Rift SDK except in compliance with the License,
13 | which is provided at the time of installation or download, or which
14 | otherwise accompanies this software in either electronic or hard copy form.
15 |
16 | You may obtain a copy of the License at
17 |
18 | http://www.oculusvr.com/licenses/LICENSE-3.1
19 |
20 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
21 | distributed under the License is distributed on an "AS IS" BASIS,
22 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 | See the License for the specific language governing permissions and
24 | limitations under the License.
25 |
26 | ************************************************************************************/
27 |
28 | #ifndef OVR_NetworkPlugin_h
29 | #define OVR_NetworkPlugin_h
30 |
31 | #include "OVR_Session.h"
32 |
33 | namespace OVR { namespace Net { namespace Plugins {
34 |
35 | //-----------------------------------------------------------------------------
36 | // NetworkPlugin
37 |
38 | // NetworkPlugins use Session and SessionListener to provide network functionality
39 | // independent of the transport medium.
40 | // Uses the chain of command design pattern such that plugins can invoke or intercept
41 | // network events via the Session.
42 | class NetworkPlugin : public SessionListener
43 | {
44 | public:
45 | NetworkPlugin();
46 | virtual ~NetworkPlugin();
47 |
48 | protected:
49 | virtual void OnAddedToSession(Session* _pSession);
50 | virtual void OnRemovedFromSession(Session* _pSession);
51 |
52 | Session *pSession;
53 | //uint8_t PluginId;
54 | };
55 |
56 |
57 | }}} // OVR::Net::Plugins
58 |
59 | #endif
60 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Net/OVR_NetworkTypes.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | PublicHeader: n/a
4 | Filename : OVR_NetworkTypes.h
5 | Content : Shared header for network types
6 | Created : June 12, 2014
7 | Authors : Kevin Jenkins
8 |
9 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
10 |
11 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
12 | you may not use the Oculus VR Rift SDK except in compliance with the License,
13 | which is provided at the time of installation or download, or which
14 | otherwise accompanies this software in either electronic or hard copy form.
15 |
16 | You may obtain a copy of the License at
17 |
18 | http://www.oculusvr.com/licenses/LICENSE-3.1
19 |
20 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
21 | distributed under the License is distributed on an "AS IS" BASIS,
22 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 | See the License for the specific language governing permissions and
24 | limitations under the License.
25 |
26 | ************************************************************************************/
27 |
28 | #ifndef OVR_NetworkTypes_h
29 | #define OVR_NetworkTypes_h
30 |
31 | #include "../Kernel/OVR_Types.h"
32 |
33 | namespace OVR { namespace Net {
34 |
35 |
36 | typedef uint64_t NetworkID;
37 | const NetworkID InvalidNetworkID = ~((NetworkID)0);
38 |
39 |
40 | } } // OVR::Net
41 |
42 | #endif
43 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Net/OVR_PacketizedTCPSocket.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | PublicHeader: n/a
4 | Filename : OVR_PacketizedTCPSocket.cpp
5 | Content : TCP with automated message framing.
6 | Created : June 10, 2014
7 | Authors : Kevin Jenkins
8 |
9 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
10 |
11 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
12 | you may not use the Oculus VR Rift SDK except in compliance with the License,
13 | which is provided at the time of installation or download, or which
14 | otherwise accompanies this software in either electronic or hard copy form.
15 |
16 | You may obtain a copy of the License at
17 |
18 | http://www.oculusvr.com/licenses/LICENSE-3.1
19 |
20 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
21 | distributed under the License is distributed on an "AS IS" BASIS,
22 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 | See the License for the specific language governing permissions and
24 | limitations under the License.
25 |
26 | ************************************************************************************/
27 |
28 | #ifndef OVR_PacketizedTCPSocket_h
29 | #define OVR_PacketizedTCPSocket_h
30 |
31 | #include "OVR_Socket.h"
32 | #include "../Kernel/OVR_Allocator.h"
33 | #include "../Kernel/OVR_Atomic.h"
34 |
35 | #ifdef OVR_OS_WIN32
36 | #include "OVR_Win32_Socket.h"
37 | #else
38 | #include "OVR_Unix_Socket.h"
39 | #endif
40 |
41 | namespace OVR { namespace Net {
42 |
43 |
44 | //-----------------------------------------------------------------------------
45 | // NetworkPlugin
46 |
47 | // Packetized TCP base socket
48 | class PacketizedTCPSocketBase : public TCPSocket
49 | {
50 | public:
51 | PacketizedTCPSocketBase() {}
52 | PacketizedTCPSocketBase(SocketHandle _sock, bool isListenSocket) : TCPSocket(_sock, isListenSocket) {}
53 | };
54 |
55 |
56 | //-----------------------------------------------------------------------------
57 | // PacketizedTCPSocket
58 |
59 | // Uses TCP but is message aligned rather than stream aligned
60 | // Alternative to reliable UDP
61 | class PacketizedTCPSocket : public PacketizedTCPSocketBase
62 | {
63 | public:
64 | PacketizedTCPSocket();
65 | PacketizedTCPSocket(SocketHandle _sock, bool isListenSocket);
66 | virtual ~PacketizedTCPSocket();
67 |
68 | public:
69 | virtual int Send(const void* pData, int bytes);
70 | virtual int SendAndConcatenate(const void** pDataArray, int *dataLengthArray, int arrayCount);
71 |
72 | protected:
73 | virtual void OnRecv(SocketEvent_TCP* eventHandler, uint8_t* pData, int bytesRead);
74 |
75 | int BytesFromStream(uint8_t* pData, int bytesRead);
76 |
77 | Lock sendLock;
78 | Lock recvBuffLock;
79 |
80 | uint8_t* pRecvBuff; // Queued receive buffered data
81 | int pRecvBuffSize; // Size of receive queue in bytes
82 | };
83 |
84 |
85 | }} // OVR::Net
86 |
87 | #endif
88 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Net/OVR_Socket.cpp:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : OVR_Socket.cpp
4 | Content : Socket common data shared between all platforms.
5 | Created : June 10, 2014
6 | Authors : Kevin Jenkins, Chris Taylor
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | ************************************************************************************/
26 |
27 | #include "OVR_Socket.h"
28 |
29 | namespace OVR { namespace Net {
30 |
31 |
32 | //-----------------------------------------------------------------------------
33 | // Socket
34 |
35 | Socket::Socket() :
36 | Transport(TransportType_None)
37 | {
38 | }
39 |
40 |
41 | //-----------------------------------------------------------------------------
42 | // BerkleyBindParameters
43 |
44 | BerkleyBindParameters::BerkleyBindParameters() :
45 | Port(0),
46 | blockingTimeout(0x7fffffff)
47 | {
48 | }
49 |
50 | //-----------------------------------------------------------------------------
51 | // BerkleySocket
52 |
53 | BerkleySocket::BerkleySocket() :
54 | TheSocket(INVALID_SOCKET)
55 | {
56 | SetBlockingTimeout(1000);
57 | }
58 |
59 | BerkleySocket::~BerkleySocket()
60 | {
61 | // Close socket on destruction
62 | Close();
63 | }
64 |
65 |
66 | //-----------------------------------------------------------------------------
67 | // UDPSocketBase
68 |
69 | UDPSocketBase::UDPSocketBase()
70 | {
71 | Transport = TransportType_UDP;
72 | }
73 |
74 |
75 | //-----------------------------------------------------------------------------
76 | // TCPSocketBase
77 |
78 | TCPSocketBase::TCPSocketBase()
79 | {
80 | Transport = TransportType_TCP;
81 | }
82 |
83 | TCPSocketBase::TCPSocketBase(SocketHandle handle)
84 | {
85 | TheSocket = handle;
86 | }
87 |
88 |
89 | }} // OVR::Net
90 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Net/OVR_Unix_Socket.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
PublicHeader: n/a
Filename : OVR_Unix_Socket.h
Content : Berkley sockets networking implementation
Created : July 1, 2014
Authors : Kevin Jenkins
Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
you may not use the Oculus VR Rift SDK except in compliance with the License,
which is provided at the time of installation or download, or which
otherwise accompanies this software in either electronic or hard copy form.
You may obtain a copy of the License at
http://www.oculusvr.com/licenses/LICENSE-3.1
Unless required by applicable law or agreed to in writing, the Oculus VR SDK
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
************************************************************************************/
#ifndef OVR_Unix_Socket_h
#define OVR_Unix_Socket_h
#include "OVR_Socket.h"
#include "OVR_BitStream.h"
#include
#include
#include
#include
#include
#include
namespace OVR { namespace Net {
//-----------------------------------------------------------------------------
// SockAddr
// Abstraction for IPV6 socket address, with various convenience functions
class SockAddr
{
public:
SockAddr();
SockAddr(SockAddr* sa);
SockAddr(sockaddr_storage* sa);
SockAddr(sockaddr_in6* sa);
SockAddr(const char* hostAddress, UInt16 port, int sockType);
public:
void Set(const sockaddr_storage* sa);
void Set(const sockaddr_in6* sa);
void Set(const char* hostAddress, UInt16 port, int sockType); // SOCK_DGRAM or SOCK_STREAM
UInt16 GetPort();
String ToString(bool writePort, char portDelineator) const;
bool IsLocalhost() const;
void Serialize(BitStream* bs);
bool Deserialize(BitStream);
bool operator==( const SockAddr& right ) const;
bool operator!=( const SockAddr& right ) const;
bool operator >( const SockAddr& right ) const;
bool operator <( const SockAddr& right ) const;
public:
sockaddr_in6 Addr6;
};
//-----------------------------------------------------------------------------
// UDP Socket
// Windows version of TCP socket
class UDPSocket : public UDPSocketBase
{
public:
UDPSocket();
virtual ~UDPSocket();
public:
virtual SocketHandle Bind(BerkleyBindParameters* pBindParameters);
virtual int Send(const void* pData, int bytes, SockAddr* address);
virtual void Poll(SocketEvent_UDP* eventHandler);
protected:
static const int RecvBufSize = 1048576;
UByte* RecvBuf;
virtual void OnRecv(SocketEvent_UDP* eventHandler, UByte* pData,
int bytesRead, SockAddr* address);
};
//-----------------------------------------------------------------------------
// TCP Socket
// Windows version of TCP socket
class TCPSocket : public TCPSocketBase
{
friend class TCPSocketPollState;
public:
TCPSocket();
TCPSocket(SocketHandle boundHandle, bool isListenSocket);
virtual ~TCPSocket();
public:
virtual SocketHandle Bind(BerkleyBindParameters* pBindParameters);
virtual int Listen();
virtual int Connect(SockAddr* address);
virtual int Send(const void* pData, int bytes);
protected:
virtual void OnRecv(SocketEvent_TCP* eventHandler, UByte* pData,
int bytesRead);
public:
bool IsConnecting; // Is in the process of connecting?
};
//-----------------------------------------------------------------------------
// TCPSocketPollState
// Polls multiple blocking TCP sockets at once
class TCPSocketPollState
{
fd_set readFD, exceptionFD, writeFD;
SocketHandle largestDescriptor;
public:
TCPSocketPollState();
bool IsValid() const;
void Add(TCPSocket* tcpSocket);
bool Poll(long usec = 30000, long seconds = 0);
void HandleEvent(TCPSocket* tcpSocket, SocketEvent_TCP* eventHandler);
};
}} // OVR::Net
#endif
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Net/OVR_Win32_Socket.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | PublicHeader: n/a
4 | Filename : OVR_Win32_Socket.h
5 | Content : Windows-specific socket-based networking implementation
6 | Created : June 10, 2014
7 | Authors : Kevin Jenkins
8 |
9 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
10 |
11 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
12 | you may not use the Oculus VR Rift SDK except in compliance with the License,
13 | which is provided at the time of installation or download, or which
14 | otherwise accompanies this software in either electronic or hard copy form.
15 |
16 | You may obtain a copy of the License at
17 |
18 | http://www.oculusvr.com/licenses/LICENSE-3.1
19 |
20 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
21 | distributed under the License is distributed on an "AS IS" BASIS,
22 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 | See the License for the specific language governing permissions and
24 | limitations under the License.
25 |
26 | ************************************************************************************/
27 |
28 | #ifndef OVR_Win32_Socket_h
29 | #define OVR_Win32_Socket_h
30 |
31 | #include "OVR_Socket.h"
32 | #include "OVR_BitStream.h"
33 |
34 | #include
35 | #include
36 | #define WIN32_LEAN_AND_MEAN
37 | #include
38 | #include
39 |
40 | namespace OVR { namespace Net {
41 |
42 |
43 | //-----------------------------------------------------------------------------
44 | // SockAddr
45 |
46 | // Abstraction for IPV6 socket address, with various convenience functions
47 | class SockAddr
48 | {
49 | public:
50 | SockAddr();
51 | SockAddr(SockAddr* sa);
52 | SockAddr(sockaddr_storage* sa);
53 | SockAddr(sockaddr_in6* sa);
54 | SockAddr(const char* hostAddress, uint16_t port, int sockType);
55 |
56 | public:
57 | void Set(const sockaddr_storage* sa);
58 | void Set(const sockaddr_in6* sa);
59 | void Set(const char* hostAddress, uint16_t port, int sockType); // SOCK_DGRAM or SOCK_STREAM
60 |
61 | uint16_t GetPort();
62 |
63 | String ToString(bool writePort, char portDelineator) const;
64 | bool IsLocalhost() const;
65 |
66 | void Serialize(BitStream* bs);
67 | bool Deserialize(BitStream);
68 |
69 | bool operator==( const SockAddr& right ) const;
70 | bool operator!=( const SockAddr& right ) const;
71 | bool operator >( const SockAddr& right ) const;
72 | bool operator <( const SockAddr& right ) const;
73 |
74 | public:
75 | sockaddr_in6 Addr6;
76 | };
77 |
78 |
79 | //-----------------------------------------------------------------------------
80 | // UDP Socket
81 |
82 | // Windows version of TCP socket
83 | class UDPSocket : public UDPSocketBase
84 | {
85 | public:
86 | UDPSocket();
87 | virtual ~UDPSocket();
88 |
89 | public:
90 | virtual SocketHandle Bind(BerkleyBindParameters* pBindParameters);
91 | virtual int Send(const void* pData, int bytes, SockAddr* address);
92 | virtual void Poll(SocketEvent_UDP* eventHandler);
93 |
94 | protected:
95 | static const int RecvBufSize = 1048576;
96 | uint8_t* RecvBuf;
97 |
98 | virtual void OnRecv(SocketEvent_UDP* eventHandler, uint8_t* pData,
99 | int bytesRead, SockAddr* address);
100 | };
101 |
102 |
103 | //-----------------------------------------------------------------------------
104 | // TCP Socket
105 |
106 | // Windows version of TCP socket
107 | class TCPSocket : public TCPSocketBase
108 | {
109 | friend class TCPSocketPollState;
110 |
111 | public:
112 | TCPSocket();
113 | TCPSocket(SocketHandle boundHandle, bool isListenSocket);
114 | virtual ~TCPSocket();
115 |
116 | public:
117 | virtual SocketHandle Bind(BerkleyBindParameters* pBindParameters);
118 | virtual int Listen();
119 | virtual int Connect(SockAddr* address);
120 | virtual int Send(const void* pData, int bytes);
121 |
122 | protected:
123 | virtual void OnRecv(SocketEvent_TCP* eventHandler, uint8_t* pData,
124 | int bytesRead);
125 |
126 | public:
127 | bool IsConnecting; // Is in the process of connecting?
128 | };
129 |
130 |
131 | //-----------------------------------------------------------------------------
132 | // TCPSocketPollState
133 |
134 | // Polls multiple blocking TCP sockets at once
135 | class TCPSocketPollState
136 | {
137 | fd_set readFD, exceptionFD, writeFD;
138 | SocketHandle largestDescriptor;
139 |
140 | public:
141 | TCPSocketPollState();
142 | bool IsValid() const;
143 | void Add(TCPSocket* tcpSocket);
144 | bool Poll(long usec = 30000, long seconds = 0);
145 | void HandleEvent(TCPSocket* tcpSocket, SocketEvent_TCP* eventHandler);
146 | };
147 |
148 |
149 | }} // OVR::Net
150 |
151 | #endif
152 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/OVR_CAPI_GL.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : OVR_CAPI_GL.h
4 | Content : GL specific structures used by the CAPI interface.
5 | Created : November 7, 2013
6 | Authors : Lee Cooper
7 |
8 | Copyright : Copyright 2013 Oculus VR, Inc. All Rights reserved.
9 |
10 | Use of this software is subject to the terms of the Oculus Inc license
11 | agreement provided at the time of installation or download, or which
12 | otherwise accompanies this software in either electronic or hard copy form.
13 |
14 | ************************************************************************************/
15 | #ifndef OVR_CAPI_GL_h
16 | #define OVR_CAPI_GL_h
17 |
18 | /// @file OVR_CAPI_GL.h
19 | /// OpenGL rendering support.
20 |
21 | #include "OVR_CAPI.h"
22 |
23 | //-----------------------------------------------------------------------------------
24 | // ***** GL Specific
25 |
26 | #if defined(OVR_OS_WIN32)
27 | #ifndef WIN32_LEAN_AND_MEAN
28 | #define WIN32_LEAN_AND_MEAN
29 | #endif
30 | #include
31 | #include
32 | #elif defined(OVR_OS_MAC)
33 | #include
34 | #include
35 | #else
36 | #include
37 | #include
38 | #endif
39 |
40 |
41 | /// Used to configure slave GL rendering (i.e. for devices created externally).
42 | typedef struct ovrGLConfigData_s
43 | {
44 | /// General device settings.
45 | ovrRenderAPIConfigHeader Header;
46 |
47 | #if defined(OVR_OS_WIN32)
48 | /// The optional window handle. If unset, rendering will use the current window.
49 | HWND Window;
50 | /// The optional device context. If unset, rendering will use a new context.
51 | HDC DC;
52 | #elif defined(OVR_OS_LINUX)
53 | /// The optional display. If unset, rendering will use the current display.
54 | _XDisplay* Disp;
55 | /// The optional window. If unset, rendering will use the current window.
56 | Window Win;
57 | #endif
58 | } ovrGLConfigData;
59 |
60 | /// Contains OpenGL-specific rendering information.
61 | union ovrGLConfig
62 | {
63 | /// General device settings.
64 | ovrRenderAPIConfig Config;
65 | /// OpenGL-specific settings.
66 | ovrGLConfigData OGL;
67 | };
68 |
69 | /// Used to pass GL eye texture data to ovrHmd_EndFrame.
70 | typedef struct ovrGLTextureData_s
71 | {
72 | /// General device settings.
73 | ovrTextureHeader Header;
74 | /// The OpenGL name for this texture.
75 | GLuint TexId;
76 | } ovrGLTextureData;
77 |
78 | /// Contains OpenGL-specific texture information.
79 | typedef union ovrGLTexture_s
80 | {
81 | /// General device settings.
82 | ovrTexture Texture;
83 | /// OpenGL-specific settings.
84 | ovrGLTextureData OGL;
85 | } ovrGLTexture;
86 |
87 | #endif // OVR_CAPI_GL_h
88 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/OVR_SerialFormat.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | PublicHeader: n/a
4 | Filename : OVR_SerialFormat.h
5 | Content : Serial Number format tools
6 | Created : June 12, 2014
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | ************************************************************************************/
26 |
27 | #ifndef OVR_SerialFormat_h
28 | #define OVR_SerialFormat_h
29 |
30 | #include "Kernel/OVR_Types.h"
31 | #include "Kernel/OVR_String.h"
32 |
33 | namespace OVR {
34 |
35 |
36 | //-----------------------------------------------------------------------------
37 | // SerialFormatType enumeration
38 |
39 | enum SerialFormatType
40 | {
41 | SerialFormatType_Invalid = -1, // Invalid format
42 | SerialFormatType_DK2 = 0, // Format used for DK2
43 | };
44 |
45 | // Returns the expected serial format based on the first byte of the buffer
46 | SerialFormatType DetectBufferFormat(uint8_t firstByte, int sizeInBytes);
47 |
48 |
49 | //-----------------------------------------------------------------------------
50 | // DK2 Serial Format
51 |
52 | enum DK2ProductId
53 | {
54 | DK2ProductId_DK1 = 1, // DK1
55 | DK2ProductId_DK2 = 2, // Product Id used for initial DK2 launch
56 | DK2ProductId_Refurb = 3, // Refurbished DK2
57 | };
58 |
59 | enum DK2PartId
60 | {
61 | DK2PartId_HMD = 0, // HMD
62 | DK2PartId_PTC = 1, // PTC(camera)
63 | DK2PartId_Carton = 2, // Carton: An HMD + PTC combo (should not be stamped on a component) AKA Overpack
64 | };
65 |
66 | typedef DK2PartId DK2LabelType; // Printed Serial Number version
67 |
68 |
69 | // DK2 tool for reading/writing the binary serial format
70 | class DK2BinarySerialFormat
71 | {
72 | public:
73 | static const SerialFormatType FormatType = SerialFormatType_DK2; // first byte
74 |
75 | DK2ProductId ProductId; // [4 bits] 2 = DK2
76 | DK2PartId PartId; // [4 bits] 0 means HMD, 1 means PTC(camera)
77 | int MinutesSinceEpoch; // [3 bytes] Number of minutes that have elapsed since the epoch: May 1st, 2014
78 | // [0] = high byte, [1] = middle byte, [2] = low byte
79 | int UnitNumber; // [2 bytes] Value that increments each time a new serial number is created. Resets to zero each day
80 | // [0] = high byte, [1] = low byte
81 | uint8_t MacHash[5]; // [5 bytes] 5 most significant bytes of MD5 hash from first ethernet adapter mac address
82 |
83 | bool operator==(const DK2BinarySerialFormat& rhs);
84 |
85 | public:
86 | // Returns false if the input is invalid in some way
87 | bool FromBuffer(const uint8_t buffer[12], bool allowUnknownTypes = false);
88 |
89 | // Fills the provided buffer with 12 bytes
90 | void ToBuffer(uint8_t buffer[12]);
91 | };
92 |
93 |
94 | // DK2 tool for reading/writing the printed serial format
95 | class DK2PrintedSerialFormat
96 | {
97 | public:
98 | DK2ProductId ProductId; // [1 char] 2 = DK2, 3 = Reconditioned bundle
99 | DK2LabelType LabelType; // [1 char] 0 means HMD, 1 means PTC(camera), 2 means Overpack(bundle)
100 | int MinutesSinceEpoch; // [4 char] Number of minutes that have elapsed since the epoch: May 1st, 2014
101 | int UnitNumber; // [3 char] Value that increments each time a new serial number is created. Resets to zero each day
102 | uint8_t MacHashLow[3]; // [3 char] 3 least significant bytes of mac hash
103 |
104 | bool operator==(const DK2PrintedSerialFormat& rhs);
105 | bool operator==(const DK2BinarySerialFormat& rhs);
106 |
107 | public:
108 | // Convert from binary to printed
109 | void FromBinary(const DK2BinarySerialFormat& bin);
110 |
111 | // Returns false if the input is invalid in some way
112 | // Convert from a 12 character printed serial number
113 | bool FromBase32(const char* str, bool allowUnknownTypes = false);
114 |
115 | // Returns a long human-readable base32 string (20 characters), NOT a printed serial number
116 | String ToBase32();
117 | };
118 |
119 |
120 | //#define SERIAL_FORMAT_UNIT_TEST
121 | #ifdef SERIAL_FORMAT_UNIT_TEST
122 | void TestSerialFormatStuff();
123 | #endif
124 |
125 | } // OVR
126 |
127 | #endif // OVR_SerialFormat_h
128 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Service/Service_NetSessionCommon.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : Service_NetSessionCommon.h
4 | Content : Shared networking for service
5 | Created : June 12, 2014
6 | Authors : Kevin Jenkins, Chris Taylor
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | ************************************************************************************/
26 |
27 | #ifndef OVR_Service_NetSessionCommon_h
28 | #define OVR_Service_NetSessionCommon_h
29 |
30 | #include "../OVR_CAPI.h"
31 | #include "../Net/OVR_RPC1.h"
32 | #include "../Kernel/OVR_Threads.h"
33 | #include "../Net/OVR_BitStream.h"
34 | #include "../Kernel/OVR_System.h"
35 |
36 | namespace OVR {
37 |
38 | class HMDInfo;
39 |
40 | namespace Service {
41 |
42 |
43 | //-----------------------------------------------------------------------------
44 | // VirtualHmdId
45 |
46 | // This is an identifier that is unique to each VirtualHmd object on the server
47 | // side. The client side uses this to opaquely reference those objects.
48 |
49 | typedef int32_t VirtualHmdId;
50 | static const int32_t InvalidVirtualHmdId = -1;
51 |
52 | // Localhost-bound TCP port that the service listens on for VR apps
53 | static const int VRServicePort = 30322; // 0x7672 = "vr" little-endian
54 |
55 | // HMDInfo section related to networking
56 | struct HMDNetworkInfo
57 | {
58 | HMDNetworkInfo() :
59 | NetId(InvalidVirtualHmdId)
60 | {
61 | }
62 |
63 | // Network identifier for HMD
64 | VirtualHmdId NetId;
65 |
66 | // Name of the shared memory object
67 | String SharedMemoryName;
68 |
69 | void Serialize(Net::BitStream* bs)
70 | {
71 | bs->Write(NetId);
72 | bs->Write(SharedMemoryName);
73 | }
74 | bool Deserialize(Net::BitStream* bs)
75 | {
76 | bs->Read(NetId);
77 | return bs->Read(SharedMemoryName);
78 | }
79 | };
80 |
81 |
82 | //-------------------------------------------------------------------------------------
83 | // ***** NetSessionCommon
84 |
85 | // Common part networking session/RPC implementation shared between client and server.
86 |
87 | class NetSessionCommon : public Thread
88 | {
89 | protected:
90 | virtual void onSystemDestroy();
91 | virtual void onThreadDestroy();
92 |
93 | public:
94 | NetSessionCommon();
95 | virtual ~NetSessionCommon();
96 |
97 | Net::Plugins::RPC1* GetRPC1() const
98 | {
99 | return pRPC;
100 | }
101 | Net::Session* GetSession() const
102 | {
103 | return pSession;
104 | }
105 |
106 | static void SerializeHMDInfo(Net::BitStream* bitStream, HMDInfo* hmdInfo);
107 | static bool DeserializeHMDInfo(Net::BitStream* bitStream, HMDInfo* hmdInfo);
108 |
109 | public:
110 | // Getter/setter tools
111 | enum EGetterSetters
112 | {
113 | // Note: If this enumeration changes, then the Servce_NetSessionCommon.cpp
114 | // IsServiceProperty() function should be updated.
115 |
116 | EGetStringValue,
117 | EGetBoolValue,
118 | EGetIntValue,
119 | EGetNumberValue,
120 | EGetNumberValues,
121 | ESetStringValue,
122 | ESetBoolValue,
123 | ESetIntValue,
124 | ESetNumberValue,
125 | ESetNumberValues,
126 |
127 | ENumTypes
128 | };
129 |
130 | static const char* FilterKeyPrefix(const char* key);
131 | static bool IsServiceProperty(EGetterSetters e, const char* key);
132 |
133 | protected:
134 | bool Terminated; // Thread termination flag
135 | Net::Session* pSession; // Networking session
136 | Net::Plugins::RPC1* pRPC; // Remote procedure calls object
137 | };
138 |
139 |
140 | }} // namespace OVR::Service
141 |
142 | #endif // OVR_Service_NetSessionCommon_h
143 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Tracking/Tracking_PoseState.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : Tracking_PoseState.h
4 | Content : Describes the complete pose at a point in time, including derivatives
5 | Created : May 13, 2014
6 | Authors : Dov Katz
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | *************************************************************************************/
26 |
27 | #ifndef Tracking_PoseState_h
28 | #define Tracking_PoseState_h
29 |
30 | #include "../Kernel/OVR_Math.h"
31 |
32 | namespace OVR {
33 |
34 | // PoseState describes the complete pose, or a rigid body configuration, at a
35 | // point in time, including first and second derivatives. It is used to specify
36 | // instantaneous location and movement of the headset.
37 | // SensorState is returned as a part of the sensor state.
38 |
39 | template
40 | class PoseState
41 | {
42 | public:
43 | typedef typename CompatibleTypes >::Type CompatibleType;
44 |
45 | PoseState() : TimeInSeconds(0.0) { }
46 | PoseState(Pose pose, double time) : TimeInSeconds(time), ThePose(pose) { }
47 |
48 | // float <-> double conversion constructor.
49 | explicit PoseState(const PoseState::OtherFloatType> &src)
50 | : ThePose(src.ThePose),
51 | AngularVelocity(src.AngularVelocity), LinearVelocity(src.LinearVelocity),
52 | AngularAcceleration(src.AngularAcceleration), LinearAcceleration(src.LinearAcceleration),
53 | TimeInSeconds(src.TimeInSeconds)
54 | { }
55 |
56 | // C-interop support: PoseStatef <-> ovrPoseStatef
57 | PoseState(const typename CompatibleTypes >::Type& src)
58 | : ThePose(src.ThePose),
59 | AngularVelocity(src.AngularVelocity), LinearVelocity(src.LinearVelocity),
60 | AngularAcceleration(src.AngularAcceleration), LinearAcceleration(src.LinearAcceleration),
61 | TimeInSeconds(src.TimeInSeconds)
62 | { }
63 |
64 | operator typename CompatibleTypes >::Type() const
65 | {
66 | typename CompatibleTypes >::Type result;
67 | result.ThePose = ThePose;
68 | result.AngularVelocity = AngularVelocity;
69 | result.LinearVelocity = LinearVelocity;
70 | result.AngularAcceleration = AngularAcceleration;
71 | result.LinearAcceleration = LinearAcceleration;
72 | result.TimeInSeconds = TimeInSeconds;
73 | return result;
74 | }
75 |
76 | Pose ThePose;
77 | Vector3 AngularVelocity;
78 | Vector3 LinearVelocity;
79 | Vector3 AngularAcceleration;
80 | Vector3 LinearAcceleration;
81 | // Absolute time of this state sample; always a double measured in seconds.
82 | double TimeInSeconds;
83 |
84 | // ***** Helpers for Pose integration
85 |
86 | // Stores and integrates gyro angular velocity reading for a given time step.
87 | void StoreAndIntegrateGyro(Vector3d angVel, double dt);
88 | // Stores and integrates position/velocity from accelerometer reading for a given time step.
89 | void StoreAndIntegrateAccelerometer(Vector3d linearAccel, double dt);
90 |
91 | // Performs integration of state by adding next state delta to it
92 | // to produce a combined state change
93 | void AdvanceByDelta(const PoseState& delta);
94 | };
95 |
96 |
97 | template
98 | PoseState operator*(const OVR::Pose& trans, const PoseState& poseState)
99 | {
100 | PoseState result;
101 | result.ThePose = trans * poseState.ThePose;
102 | result.LinearVelocity = trans.Rotate(poseState.LinearVelocity);
103 | result.LinearAcceleration = trans.Rotate(poseState.LinearAcceleration);
104 | result.AngularVelocity = trans.Rotate(poseState.AngularVelocity);
105 | result.AngularAcceleration = trans.Rotate(poseState.AngularAcceleration);
106 | return result;
107 | }
108 |
109 |
110 | // External API returns pose as float, but uses doubles internally for quaternion precision.
111 | typedef PoseState PoseStatef;
112 | typedef PoseState PoseStated;
113 |
114 |
115 | } // namespace OVR::Vision
116 |
117 |
118 | namespace OVR {
119 |
120 | template<> struct CompatibleTypes > { typedef ovrPoseStatef Type; };
121 | template<> struct CompatibleTypes > { typedef ovrPoseStated Type; };
122 |
123 | }
124 |
125 | #endif // Tracking_PoseState_h
126 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Tracking/Tracking_SensorStateReader.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : Tracking_SensorStateReader.h
4 | Content : Separate reader component that is able to recover sensor pose
5 | Created : June 4, 2014
6 | Authors : Chris Taylor
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | *************************************************************************************/
26 |
27 | #ifndef Tracking_SensorStateReader_h
28 | #define Tracking_SensorStateReader_h
29 |
30 | #include "../Kernel/OVR_Lockless.h"
31 | #include "Tracking_SensorState.h"
32 |
33 | namespace OVR { namespace Tracking {
34 |
35 |
36 | //-----------------------------------------------------------------------------
37 | // SensorStateReader
38 |
39 | // User interface to retrieve pose from the sensor fusion subsystem
40 | class SensorStateReader : public NewOverrideBase
41 | {
42 | protected:
43 | const CombinedSharedStateUpdater *Updater;
44 |
45 | // Transform from real-world coordinates to centered coordinates
46 | Posed CenteredFromWorld;
47 |
48 | // Last latency warning time
49 | mutable double LastLatWarnTime;
50 |
51 | public:
52 | SensorStateReader();
53 |
54 | // Initialize the updater
55 | void SetUpdater(const CombinedSharedStateUpdater *updater);
56 |
57 | // Re-centers on the current yaw (optionally pitch) and translation
58 | void RecenterPose();
59 |
60 | // Get the full dynamical system state of the CPF, which includes velocities and accelerations,
61 | // predicted at a specified absolute point in time.
62 | bool GetSensorStateAtTime(double absoluteTime, Tracking::TrackingState& state) const;
63 |
64 | // Get the predicted pose (orientation, position) of the center pupil frame (CPF) at a specific point in time.
65 | bool GetPoseAtTime(double absoluteTime, Posef& transform) const;
66 |
67 | // Get the sensor status (same as GetSensorStateAtTime(...).Status)
68 | uint32_t GetStatus() const;
69 | };
70 |
71 |
72 | }} // namespace OVR::Tracking
73 |
74 | #endif // Tracking_SensorStateReader_h
75 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Util/Util_Interface.cpp:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : Util_Interface.cpp
4 | Content : Simple interface, utilised by internal demos,
5 | with access to wider SDK as needed.
6 | Located in the body of the SDK to ensure updated
7 | when new SDK features are added.
8 | Created : February 20, 2014
9 | Authors : Tom Heath
10 |
11 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
12 |
13 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
14 | you may not use the Oculus VR Rift SDK except in compliance with the License,
15 | which is provided at the time of installation or download, or which
16 | otherwise accompanies this software in either electronic or hard copy form.
17 |
18 | You may obtain a copy of the License at
19 |
20 | http://www.oculusvr.com/licenses/LICENSE-3.1
21 |
22 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
23 | distributed under the License is distributed on an "AS IS" BASIS,
24 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 | See the License for the specific language governing permissions and
26 | limitations under the License.
27 |
28 | *************************************************************************************/
29 |
30 | #include "Util_Interface.h"
31 |
32 |
33 |
34 | //Files left in to ease its possible return......
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Util/Util_Interface.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : Util_Interface.h
4 | Content : Simple interface, utilised by internal demos,
5 | with access to wider SDK as needed.
6 | Located in the body of the SDK to ensure updated
7 | when new SDK features are added.
8 | Created : February 20, 2014
9 | Authors : Tom Heath
10 |
11 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
12 |
13 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
14 | you may not use the Oculus VR Rift SDK except in compliance with the License,
15 | which is provided at the time of installation or download, or which
16 | otherwise accompanies this software in either electronic or hard copy form.
17 |
18 | You may obtain a copy of the License at
19 |
20 | http://www.oculusvr.com/licenses/LICENSE-3.1
21 |
22 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
23 | distributed under the License is distributed on an "AS IS" BASIS,
24 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 | See the License for the specific language governing permissions and
26 | limitations under the License.
27 |
28 | *************************************************************************************/
29 |
30 | #ifndef OVR_Util_Interface_h
31 | #define OVR_Util_Interface_h
32 | #include "../OVR_CAPI.h"
33 |
34 | //Files left in to ease its possible return......
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Util/Util_LatencyTest2Reader.cpp:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : Util_LatencyTest2Reader.cpp
4 | Content : Shared functionality for the DK2 latency tester
5 | Created : July 8, 2014
6 | Authors : Volga Aksoy, Chris Taylor
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | *************************************************************************************/
26 |
27 | #include "Util_LatencyTest2Reader.h"
28 |
29 | namespace OVR { namespace Util {
30 |
31 |
32 | //// FrameTimeRecord
33 |
34 | bool FrameTimeRecord::ColorToReadbackIndex(int *readbackIndex, unsigned char color)
35 | {
36 | int compareColor = color - LT2_ColorIncrement/2;
37 | int index = color / LT2_ColorIncrement; // Use color without subtraction due to rounding.
38 | int delta = compareColor - index * LT2_ColorIncrement;
39 |
40 | if ((delta < LT2_PixelTestThreshold) && (delta > -LT2_PixelTestThreshold))
41 | {
42 | *readbackIndex = index;
43 | return true;
44 | }
45 | return false;
46 | }
47 |
48 | unsigned char FrameTimeRecord::ReadbackIndexToColor(int readbackIndex)
49 | {
50 | OVR_ASSERT(readbackIndex < LT2_IncrementCount);
51 | return (unsigned char)(readbackIndex * LT2_ColorIncrement + LT2_ColorIncrement/2);
52 | }
53 |
54 |
55 | //// FrameTimeRecordSet
56 |
57 | FrameTimeRecordSet::FrameTimeRecordSet()
58 | {
59 | NextWriteIndex = 0;
60 | memset(this, 0, sizeof(FrameTimeRecordSet));
61 | }
62 |
63 | void FrameTimeRecordSet::AddValue(int readValue, double timeSeconds)
64 | {
65 | Records[NextWriteIndex].ReadbackIndex = readValue;
66 | Records[NextWriteIndex].TimeSeconds = timeSeconds;
67 | NextWriteIndex++;
68 | if (NextWriteIndex == RecordCount)
69 | NextWriteIndex = 0;
70 | }
71 | // Matching should be done starting from NextWrite index
72 | // until wrap-around
73 |
74 | const FrameTimeRecord& FrameTimeRecordSet::operator [] (int i) const
75 | {
76 | return Records[(NextWriteIndex + i) & RecordMask];
77 | }
78 |
79 | const FrameTimeRecord& FrameTimeRecordSet::GetMostRecentFrame()
80 | {
81 | return Records[(NextWriteIndex - 1) & RecordMask];
82 | }
83 |
84 | // Advances I to absolute color index
85 | bool FrameTimeRecordSet::FindReadbackIndex(int* i, int readbackIndex) const
86 | {
87 | for (; *i < RecordCount; (*i)++)
88 | {
89 | if ((*this)[*i].ReadbackIndex == readbackIndex)
90 | return true;
91 | }
92 | return false;
93 | }
94 |
95 | bool FrameTimeRecordSet::IsAllZeroes() const
96 | {
97 | for (int i = 0; i < RecordCount; i++)
98 | if (Records[i].ReadbackIndex != 0)
99 | return false;
100 | return true;
101 | }
102 |
103 |
104 | //// RecordStateReader
105 |
106 | void RecordStateReader::GetRecordSet(FrameTimeRecordSet& recordset)
107 | {
108 | if(!Updater)
109 | {
110 | return;
111 | }
112 |
113 | recordset = Updater->SharedLatencyTestState.GetState();
114 | return;
115 | }
116 |
117 |
118 | }} // namespace OVR::Util
119 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Util/Util_LatencyTest2Reader.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : Util_LatencyTest2Reader.h
4 | Content : Shared functionality for the DK2 latency tester
5 | Created : July 8, 2014
6 | Authors : Volga Aksoy, Chris Taylor
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | *************************************************************************************/
26 |
27 | #ifndef OVR_Util_LatencyTest2Reader_h
28 | #define OVR_Util_LatencyTest2Reader_h
29 |
30 | #include "../Tracking/Tracking_SensorState.h"
31 | #include "Util_LatencyTest2State.h"
32 |
33 | namespace OVR { namespace Util {
34 |
35 |
36 | //-----------------------------------------------------------------------------
37 | // RecordStateReader
38 |
39 | // User interface to retrieve pose from the sensor fusion subsystem
40 | class RecordStateReader : public NewOverrideBase
41 | {
42 | protected:
43 | const Tracking::CombinedSharedStateUpdater* Updater;
44 |
45 | public:
46 | RecordStateReader()
47 | : Updater(NULL)
48 | {
49 | }
50 |
51 | // Initialize the updater
52 | void SetUpdater(const Tracking::CombinedSharedStateUpdater *updater)
53 | {
54 | Updater = updater;
55 | }
56 |
57 | void GetRecordSet(FrameTimeRecordSet& recordset);
58 | };
59 |
60 |
61 | }} // namespace OVR::Util
62 |
63 | #endif // OVR_Util_LatencyTest2Reader_h
64 |
--------------------------------------------------------------------------------
/libs/LibOVR/Src/Util/Util_LatencyTest2State.h:
--------------------------------------------------------------------------------
1 | /************************************************************************************
2 |
3 | Filename : Util_LatencyTest2Reader.h
4 | Content : Shared functionality for the DK2 latency tester
5 | Created : July 8, 2014
6 | Authors : Volga Aksoy, Chris Taylor
7 |
8 | Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 |
10 | Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 | you may not use the Oculus VR Rift SDK except in compliance with the License,
12 | which is provided at the time of installation or download, or which
13 | otherwise accompanies this software in either electronic or hard copy form.
14 |
15 | You may obtain a copy of the License at
16 |
17 | http://www.oculusvr.com/licenses/LICENSE-3.1
18 |
19 | Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 | distributed under the License is distributed on an "AS IS" BASIS,
21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | See the License for the specific language governing permissions and
23 | limitations under the License.
24 |
25 | *************************************************************************************/
26 |
27 | #ifndef OVR_Util_LatencyTest2_State_h
28 | #define OVR_Util_LatencyTest2_State_h
29 |
30 | #include "../Kernel/OVR_Lockless.h"
31 |
32 | namespace OVR { namespace Util {
33 |
34 |
35 | enum LatencyTester2Constants
36 | {
37 | LT2_ColorIncrement = 32,
38 | LT2_PixelTestThreshold = LT2_ColorIncrement / 3,
39 | LT2_IncrementCount = 256 / LT2_ColorIncrement,
40 | LT2_TimeoutWaitingForColorDetected = 1000 // 1 second
41 | };
42 |
43 |
44 | //-------------------------------------------------------------------------------------
45 | // FrameTimeRecord
46 |
47 | // Describes frame scan-out time used for latency testing.
48 | struct FrameTimeRecord
49 | {
50 | int ReadbackIndex;
51 | double TimeSeconds;
52 |
53 | // Utility functions to convert color to readBack indices and back.
54 | // The purpose of ReadbackIndex is to allow direct comparison by value.
55 |
56 | static bool ColorToReadbackIndex(int *readbackIndex, unsigned char color);
57 | static unsigned char ReadbackIndexToColor(int readbackIndex);
58 | };
59 |
60 |
61 | //-----------------------------------------------------------------------------
62 | // FrameTimeRecordSet
63 |
64 | // FrameTimeRecordSet is a container holding multiple consecutive frame timing records
65 | // returned from the lock-less state. Used by FrameTimeManager.
66 | struct FrameTimeRecordSet
67 | {
68 | enum {
69 | RecordCount = 4,
70 | RecordMask = RecordCount - 1
71 | };
72 | FrameTimeRecord Records[RecordCount];
73 | int NextWriteIndex;
74 |
75 | FrameTimeRecordSet();
76 |
77 | void AddValue(int readValue, double timeSeconds);
78 | // Matching should be done starting from NextWrite index
79 | // until wrap-around
80 |
81 | const FrameTimeRecord& operator [] (int i) const;
82 |
83 | const FrameTimeRecord& GetMostRecentFrame();
84 |
85 | // Advances I to absolute color index
86 | bool FindReadbackIndex(int* i, int readbackIndex) const;
87 |
88 | bool IsAllZeroes() const;
89 | };
90 |
91 | typedef LocklessUpdater LockessRecordUpdater;
92 |
93 |
94 | }} // namespace OVR::Util
95 |
96 | #endif // OVR_Util_LatencyTest2_State_h
97 |
--------------------------------------------------------------------------------
/license.md:
--------------------------------------------------------------------------------
1 |
2 | The license for the Oculus SDK can be found here:
3 | https://developer.oculusvr.com/license
--------------------------------------------------------------------------------
/ofxOculusDK2Lib/.gitignore:
--------------------------------------------------------------------------------
1 | Debug/
2 | Release/
3 |
--------------------------------------------------------------------------------
/ofxOculusDK2Lib/ofxOculusDK2.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | ..\..\..\addons\ofxOculusDK2\libs\LibOVR\Src;..\..\..\addons\ofxOculusDK2\libs\LibOVR\Include;..\..\..\addons\ofxOculusDK2\libs\3rdParty;..\..\..\addons\ofxOculusDK2\src;%(AdditionalIncludeDirectories)
9 | true
10 |
11 |
12 | ..\..\..\addons\ofxOculusDK2\libs\LibOVR\Lib\x64\VS2012;%(AdditionalLibraryDirectories)
13 | %(AdditionalDependencies)
14 |
15 |
16 |
17 |
18 | ..\..\..\addons\ofxOculusDK2\libs\LibOVR\Lib\x64\VS2012;%(AdditionalLibraryDirectories)
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/ofxOculusDK2Lib/ofxOculusDK2Lib.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ofxOculusDK2Lib", "ofxOculusDK2Lib.vcxproj", "{06DF4A39-7102-462B-8F20-FC26E9A93826}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Win32 = Debug|Win32
9 | Debug|x64 = Debug|x64
10 | Release|Win32 = Release|Win32
11 | Release|x64 = Release|x64
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {06DF4A39-7102-462B-8F20-FC26E9A93826}.Debug|Win32.ActiveCfg = Debug|Win32
15 | {06DF4A39-7102-462B-8F20-FC26E9A93826}.Debug|Win32.Build.0 = Debug|Win32
16 | {06DF4A39-7102-462B-8F20-FC26E9A93826}.Debug|x64.ActiveCfg = Debug|x64
17 | {06DF4A39-7102-462B-8F20-FC26E9A93826}.Debug|x64.Build.0 = Debug|x64
18 | {06DF4A39-7102-462B-8F20-FC26E9A93826}.Release|Win32.ActiveCfg = Release|Win32
19 | {06DF4A39-7102-462B-8F20-FC26E9A93826}.Release|Win32.Build.0 = Release|Win32
20 | {06DF4A39-7102-462B-8F20-FC26E9A93826}.Release|x64.ActiveCfg = Release|x64
21 | {06DF4A39-7102-462B-8F20-FC26E9A93826}.Release|x64.Build.0 = Release|x64
22 | EndGlobalSection
23 | GlobalSection(SolutionProperties) = preSolution
24 | HideSolutionNode = FALSE
25 | EndGlobalSection
26 | EndGlobal
27 |
--------------------------------------------------------------------------------
/ofxOculusDK2Lib/ofxOculusDK2Lib.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {f2ed3ef3-c9c0-4e0d-b759-ccaf1093e327}
6 |
7 |
8 |
9 |
10 | src
11 |
12 |
13 |
14 |
15 | src
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/ofxOculusDK2.h:
--------------------------------------------------------------------------------
1 | //
2 | // ofxOculusRift.cpp
3 | // OculusRiftRendering
4 | //
5 | // Created by Andreas Müller on 30/04/2013.
6 | // Updated by James George September 27th 2013
7 | // Updated by Jason Walters October 22nd 2013
8 | //
9 |
10 | #pragma once
11 |
12 | #include "ofMain.h"
13 |
14 | //#include "OVR.h"
15 | #include "OVR_Kernel.h"
16 | using namespace OVR;
17 |
18 | #include "OVR_CAPI.h"
19 |
20 | #include "Util/Util_Render_Stereo.h"
21 | using namespace OVR::Util::Render;
22 |
23 | #include "CAPI/CAPI_HMDState.h"
24 | using namespace OVR::CAPI;
25 |
26 | #include "Sensors/OVR_DeviceConstants.h"
27 | #include
28 |
29 |
30 |
31 | class ofxOculusDK2
32 | {
33 | public:
34 |
35 | ofxOculusDK2();
36 | ~ofxOculusDK2();
37 |
38 | //set a pointer to the camera you want as the base perspective
39 | //the oculus rendering will create a stereo pair from this camera
40 | //and mix in the head transformation
41 | ofCamera* baseCamera;
42 |
43 | bool setup();
44 | bool setup(ofFbo::Settings& render_settings);
45 |
46 | bool isSetup();
47 | void reset();
48 | bool lockView;
49 |
50 | //draw background, before rendering eyes
51 | void beginBackground();
52 | void endBackground();
53 |
54 | //draw overlay, before rendering eyes
55 | void beginOverlay(float overlayZDistance = -150, float width = 256, float height = 256);
56 | void endOverlay();
57 |
58 | void beginLeftEye();
59 | void endLeftEye();
60 |
61 | void beginRightEye();
62 | void endRightEye();
63 |
64 | void draw();
65 |
66 | void setUsePredictedOrientation(bool usePredicted);
67 | bool getUsePredictiveOrientation();
68 |
69 | void reloadShader();
70 |
71 | ofQuaternion getOrientationQuat();
72 | ofMatrix4x4 getOrientationMat();
73 |
74 | //default 1 has more constrained mouse movement,
75 | //while turning it up increases the reach of the mouse
76 | float oculusScreenSpaceScale;
77 |
78 | //projects a 3D point into 2D, optionally accounting for the head orientation
79 | ofVec3f worldToScreen(ofVec3f worldPosition, bool considerHeadOrientation = false);
80 | ofVec3f screenToWorld(ofVec3f screenPt, bool considerHeadOrientation = false);
81 | ofVec3f screenToOculus2D(ofVec3f screenPt, bool considerHeadOrientation = false);
82 |
83 | //returns a 3d position of the mouse projected in front of the camera, at point z
84 | ofVec3f mousePosition3D(float z = 0, bool considerHeadOrientation = false);
85 |
86 | ofVec2f gazePosition2D();
87 |
88 | //sets up the view so that things drawn in 2D are billboarded to the caemra,
89 | //centered at the mouse
90 | //Good way to draw custom cursors. don't forget to push/pop matrix around the call
91 | void multBillboardMatrix();
92 | void multBillboardMatrix(ofVec3f objectPosition, ofVec3f upDirection = ofVec3f(0,1,0) );
93 |
94 | float distanceFromMouse(ofVec3f worldPoint);
95 | float distanceFromScreenPoint(ofVec3f worldPoint, ofVec2f screenPoint);
96 |
97 | ofRectangle getOverlayRectangle() {
98 | return ofRectangle(0,0,
99 | overlayTarget.getWidth(),
100 | overlayTarget.getHeight());
101 | }
102 | ofFbo& getOverlayTarget(){
103 | return overlayTarget;
104 | }
105 | ofFbo& getBackgroundTarget(){
106 | return backgroundTarget;
107 | }
108 | ofFbo& getRenderTarget(){
109 | return renderTarget;
110 | }
111 |
112 | ofRectangle getOculusViewport();
113 | bool isHD();
114 | //allows you to disable moving the camera based on inner ocular distance
115 | bool applyTranslation;
116 |
117 | private:
118 | bool bSetup;
119 | bool insideFrame;
120 | bool bUsingDebugHmd;
121 | unsigned startTrackingCaps;
122 |
123 | bool bHmdSettingsChanged;
124 | bool bPositionTrackingEnabled;
125 | bool bLowPersistence;
126 | bool bDynamicPrediction;
127 |
128 | bool bUsePredictedOrientation;
129 | bool bUseBackground;
130 | bool bUseOverlay;
131 | float overlayZDistance;
132 |
133 | ovrHmd hmd;
134 | ovrFovPort eyeFov[2];
135 | ovrEyeRenderDesc eyeRenderDesc[2];
136 | ovrRecti eyeRenderViewport[2];
137 | ovrVector2f UVScaleOffset[2][2];
138 | ofVboMesh eyeMesh[2];
139 | ovrPosef headPose[2];
140 | ovrFrameTiming frameTiming;// = ovrHmd_BeginFrameTiming(hmd, 0);
141 |
142 | void initializeClientRenderer();
143 |
144 | Sizei windowSize;
145 |
146 | OVR::Util::Render::StereoConfig stereo;
147 | float renderScale;
148 | ofMesh overlayMesh;
149 | ofMatrix4x4 orientationMatrix;
150 |
151 | ofVboMesh leftEyeMesh;
152 | ofVboMesh rightEyeMesh;
153 |
154 | Sizei renderTargetSize;
155 | ofFbo renderTarget;
156 | ofFbo backgroundTarget;
157 | ofFbo overlayTarget;
158 | ofShader distortionShader;
159 |
160 | void setupEyeParams(ovrEyeType eye);
161 | void setupShaderUniforms(ovrEyeType eye);
162 |
163 | void renderOverlay();
164 | };
165 |
--------------------------------------------------------------------------------