summaryrefslogtreecommitdiffstats
path: root/Samples
diff options
context:
space:
mode:
authorBrad Davis <[email protected]>2014-04-14 21:25:09 -0700
committerBrad Davis <[email protected]>2014-04-14 21:25:09 -0700
commit07d0f4d0bbf3477ac6a9584f726e8ec6ab285707 (patch)
tree1854d0c690eff32e77b137567c88a52d56d8b660 /Samples
parentf28388ff2af14b56ef2d973b2f4f9da021716d4c (diff)
Adding windows 0.3.1 SDK
Diffstat (limited to 'Samples')
-rw-r--r--Samples/CommonSrc/Makefile7
-rw-r--r--Samples/CommonSrc/Platform/Gamepad.h4
-rw-r--r--Samples/CommonSrc/Platform/Linux_Gamepad.cpp453
-rw-r--r--Samples/CommonSrc/Platform/Linux_Gamepad.h83
-rw-r--r--Samples/CommonSrc/Platform/Linux_Platform.cpp563
-rw-r--r--Samples/CommonSrc/Platform/Linux_Platform.h120
-rw-r--r--Samples/CommonSrc/Platform/OSX_Gamepad.cpp424
-rw-r--r--Samples/CommonSrc/Platform/OSX_Gamepad.h66
-rw-r--r--Samples/CommonSrc/Platform/OSX_Platform.h80
-rw-r--r--Samples/CommonSrc/Platform/OSX_Platform.mm514
-rw-r--r--Samples/CommonSrc/Platform/OSX_PlatformObjc.h31
-rw-r--r--Samples/CommonSrc/Platform/OSX_WavPlayer.cpp242
-rw-r--r--Samples/CommonSrc/Platform/OSX_WavPlayer.h64
-rw-r--r--Samples/CommonSrc/Platform/Platform.cpp4
-rw-r--r--Samples/CommonSrc/Platform/Platform.h2
-rw-r--r--Samples/CommonSrc/Platform/Platform_Default.h11
-rw-r--r--Samples/CommonSrc/Platform/Win32_Gamepad.cpp2
-rw-r--r--Samples/CommonSrc/Platform/Win32_Gamepad.h2
-rw-r--r--Samples/CommonSrc/Platform/Win32_Platform.cpp7
-rw-r--r--Samples/CommonSrc/Platform/Win32_Platform.h10
-rw-r--r--Samples/CommonSrc/Render/Render_D3D1X_Device.cpp710
-rw-r--r--Samples/CommonSrc/Render/Render_D3D1X_Device.h41
-rw-r--r--Samples/CommonSrc/Render/Render_Device.cpp2306
-rw-r--r--Samples/CommonSrc/Render/Render_Device.h326
-rw-r--r--Samples/CommonSrc/Render/Render_GL_Device.cpp639
-rw-r--r--Samples/CommonSrc/Render/Render_GL_Device.h113
-rw-r--r--Samples/CommonSrc/Render/Render_GL_Win32_Device.cpp248
-rw-r--r--Samples/CommonSrc/Render/Render_GL_Win32_Device.h24
-rw-r--r--Samples/CommonSrc/Render/Render_LoadTextureDDS.cpp6
-rw-r--r--Samples/CommonSrc/Render/Render_XmlSceneLoader.cpp13
-rw-r--r--Samples/CommonSrc/Render/Render_XmlSceneLoader.h2
-rw-r--r--Samples/LibOVR_Samples_Msvc2010.sln43
-rw-r--r--Samples/LibOVR_Samples_VS2010.sln35
-rw-r--r--Samples/LibOVR_Samples_VS2012.sln43
-rw-r--r--Samples/LibOVR_Samples_VS2013.sln38
-rw-r--r--Samples/LibOVR_With_Samples.xcodeproj/OculusRoomTiny-Info.plist34
-rw-r--r--Samples/LibOVR_With_Samples.xcodeproj/OculusWorldDemo-Info.plist34
-rw-r--r--Samples/LibOVR_With_Samples.xcodeproj/SensorBoxTest-Info.plist34
-rw-r--r--Samples/LibOVR_With_Samples.xcodeproj/project.pbxproj1131
-rw-r--r--Samples/LibOVR_With_Samples.xcodeproj/project.xcworkspace/contents.xcworkspacedata7
-rw-r--r--Samples/LibOVR_With_Samples.xcodeproj/project.xcworkspace/xcuserdata/Nate.xcuserdatad/UserInterfaceState.xcuserstatebin15669 -> 0 bytes
-rw-r--r--Samples/LibOVR_With_Samples.xcodeproj/project.xcworkspace/xcuserdata/Nate.xcuserdatad/WorkspaceSettings.xcsettings20
-rw-r--r--Samples/LibOVR_With_Samples.xcodeproj/xcshareddata/xcschemes/OculusRoomTiny.xcscheme86
-rw-r--r--Samples/LibOVR_With_Samples.xcodeproj/xcshareddata/xcschemes/OculusWorldDemo.xcscheme86
-rw-r--r--Samples/LibOVR_With_Samples.xcodeproj/xcshareddata/xcschemes/SensorBoxTest.xcscheme86
-rw-r--r--Samples/LibOVR_With_Samples.xcodeproj/xcshareddata/xcschemes/ovr.xcscheme59
-rw-r--r--Samples/LibOVR_With_Samples.xcodeproj/xcuserdata/Nate.xcuserdatad/xcschemes/xcschememanagement.plist29
-rw-r--r--Samples/LibOVR_With_Samples_Msvc2010.sln67
-rw-r--r--Samples/LibOVR_With_Samples_VS2010.sln51
-rw-r--r--Samples/LibOVR_With_Samples_VS2012.sln63
-rw-r--r--Samples/LibOVR_With_Samples_VS2013.sln53
-rw-r--r--Samples/OculusRoomTiny/OSX_OculusRoomTiny.mm861
-rw-r--r--Samples/OculusRoomTiny/OSX_OculusRoomTiny2.h (renamed from Samples/OculusRoomTiny/OSX_OculusRoomTiny.h)2
-rw-r--r--Samples/OculusRoomTiny/OculusRoomModel.cpp8
-rw-r--r--Samples/OculusRoomTiny/OculusRoomTiny2.rc (renamed from Samples/OculusRoomTiny/OculusRoomTiny.rc)bin144 -> 144 bytes
-rw-r--r--Samples/OculusRoomTiny/OculusRoomTiny_Msvc2010.vcxproj.filters17
-rw-r--r--Samples/OculusRoomTiny/Projects/Win/VS2010/OculusRoomTiny.vcxproj (renamed from Samples/OculusRoomTiny/OculusRoomTiny_Msvc2010.vcxproj)64
-rw-r--r--Samples/OculusRoomTiny/Projects/Win/VS2010/OculusRoomTiny.vcxproj.filters26
-rw-r--r--Samples/OculusRoomTiny/Projects/Win/VS2012/OculusRoomTiny.vcxproj (renamed from Samples/OculusWorldDemo/OculusWorldDemo_Msvc2010.vcxproj)100
-rw-r--r--Samples/OculusRoomTiny/Projects/Win/VS2012/OculusRoomTiny.vcxproj.filters26
-rw-r--r--Samples/OculusRoomTiny/Projects/Win/VS2013/OculusRoomTiny.vcxproj208
-rw-r--r--Samples/OculusRoomTiny/Projects/Win/VS2013/OculusRoomTiny.vcxproj.filters29
-rw-r--r--Samples/OculusRoomTiny/RenderTiny_D3D11_Device.cpp (renamed from Samples/OculusRoomTiny/RenderTiny_D3D1X_Device.cpp)727
-rw-r--r--Samples/OculusRoomTiny/RenderTiny_D3D11_Device.h (renamed from Samples/OculusRoomTiny/RenderTiny_Device.h)484
-rw-r--r--Samples/OculusRoomTiny/RenderTiny_D3D1X_Device.h273
-rw-r--r--Samples/OculusRoomTiny/RenderTiny_Device.cpp442
-rw-r--r--Samples/OculusRoomTiny/RenderTiny_GL_Device.cpp784
-rw-r--r--Samples/OculusRoomTiny/RenderTiny_GL_Device.h228
-rw-r--r--Samples/OculusRoomTiny/Win32_DistortionMesh.cpp244
-rw-r--r--Samples/OculusRoomTiny/Win32_OculusRoomTiny.cpp876
-rw-r--r--Samples/OculusRoomTiny/Win32_OculusRoomTiny.h189
-rw-r--r--Samples/OculusRoomTiny/Win32_OculusRoomTiny_Util.cpp254
-rw-r--r--Samples/OculusWorldDemo/Assets/Tuscany/Tuscany_OculusCube.tgabin0 -> 2699618 bytes
-rw-r--r--Samples/OculusWorldDemo/Assets/Tuscany/Tuscany_blueCube.tgabin0 -> 270018 bytes
-rw-r--r--Samples/OculusWorldDemo/Assets/Tuscany/Tuscany_redCube.tgabin0 -> 270018 bytes
-rw-r--r--Samples/OculusWorldDemo/Makefile135
-rw-r--r--Samples/OculusWorldDemo/Obj/Linux/Debug/i386/readme2
-rw-r--r--Samples/OculusWorldDemo/Obj/Linux/Debug/x86_64/readme2
-rw-r--r--Samples/OculusWorldDemo/Obj/Linux/Release/i386/readme2
-rw-r--r--Samples/OculusWorldDemo/Obj/Linux/Release/x86_64/readme2
-rw-r--r--Samples/OculusWorldDemo/OculusWorldDemo.cpp2390
-rw-r--r--Samples/OculusWorldDemo/OculusWorldDemo.h339
-rw-r--r--Samples/OculusWorldDemo/OculusWorldDemo_Msvc2010.vcxproj.filters89
-rw-r--r--Samples/OculusWorldDemo/OculusWorldDemo_Scene.cpp399
-rw-r--r--Samples/OculusWorldDemo/OptionMenu.cpp896
-rw-r--r--Samples/OculusWorldDemo/OptionMenu.h442
-rw-r--r--Samples/OculusWorldDemo/Player.cpp226
-rw-r--r--Samples/OculusWorldDemo/Player.h48
-rw-r--r--Samples/OculusWorldDemo/Projects/Win/VS2010/OculusWorldDemo.vcxproj227
-rw-r--r--Samples/OculusWorldDemo/Projects/Win/VS2010/OculusWorldDemo.vcxproj.filters107
-rw-r--r--Samples/OculusWorldDemo/Projects/Win/VS2012/OculusWorldDemo.vcxproj232
-rw-r--r--Samples/OculusWorldDemo/Projects/Win/VS2012/OculusWorldDemo.vcxproj.filters106
-rw-r--r--Samples/OculusWorldDemo/Projects/Win/VS2013/OculusWorldDemo.vcxproj232
-rw-r--r--Samples/OculusWorldDemo/Projects/Win/VS2013/OculusWorldDemo.vcxproj.filters106
-rw-r--r--Samples/OculusWorldDemo/Release/readme2
-rw-r--r--Samples/OculusWorldDemo/RenderProfiler.cpp99
-rw-r--r--Samples/OculusWorldDemo/RenderProfiler.h71
-rw-r--r--Samples/SensorBox/SensorBoxTest.cpp506
-rw-r--r--Samples/SensorBox/SensorBoxTest.rcbin144 -> 0 bytes
-rw-r--r--Samples/SensorBox/SensorBoxTest_Msvc2010.vcxproj126
-rw-r--r--Samples/SensorBox/SensorBoxTest_Msvc2010.vcxproj.filters73
101 files changed, 9497 insertions, 12320 deletions
diff --git a/Samples/CommonSrc/Makefile b/Samples/CommonSrc/Makefile
deleted file mode 100644
index 8c07a2a..0000000
--- a/Samples/CommonSrc/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-
-PLATFORM_SRCS := Samples/CommonSrc/Platform/Platform.cpp Samples/CommonSrc/Platform/X11_Platform.cpp
-
-RENDER_SRCS := Samples/CommonSrc/Render/Render_Device.cpp Samples/CommonSrc/Render/Render_Stereo.cpp \
- Samples/CommonSrc/Render/Render_GL_Device.cpp \
- Samples/CommonSrc/Render/Render_LoadTextureTGA.cpp
-
diff --git a/Samples/CommonSrc/Platform/Gamepad.h b/Samples/CommonSrc/Platform/Gamepad.h
index f32effc..95cff10 100644
--- a/Samples/CommonSrc/Platform/Gamepad.h
+++ b/Samples/CommonSrc/Platform/Gamepad.h
@@ -5,7 +5,7 @@ Content : Cross platform Gamepad interface.
Created : May 6, 2013
Authors : Lee Cooper
-Copyright : Copyright 2013 Oculus VR, Inc. All Rights reserved.
+Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -75,7 +75,7 @@ struct GamepadState
{
return !(*this == b);
}
- void Debug()
+ void Debug() const
{
OVR_DEBUG_LOG(("Buttons:0x%4x LX:%.2f LY:%.2f RX:%.2f RY:%.2f LT:%.2f RT:%.2f", Buttons, LX, LY, RX, RY, LT, RT));
}
diff --git a/Samples/CommonSrc/Platform/Linux_Gamepad.cpp b/Samples/CommonSrc/Platform/Linux_Gamepad.cpp
deleted file mode 100644
index 7bca5c5..0000000
--- a/Samples/CommonSrc/Platform/Linux_Gamepad.cpp
+++ /dev/null
@@ -1,453 +0,0 @@
-/************************************************************************************
-
-Filename : Linux_Gamepad.cpp
-Content : Linux implementation of Platform app infrastructure
-Created : May 6, 2013
-Authors : Lee Cooper, Simon Hallam
-
-Copyright : Copyright 2013 Oculus VR, Inc. All Rights reserved.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-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.
-
-************************************************************************************/
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <glob.h>
-#include <linux/joystick.h>
-#include "Linux_Gamepad.h"
-
-
-namespace OVR { namespace Platform { namespace Linux {
-
-const char* pNameXbox360Wireless = "Xbox 360";
-const char* pNameXbox360Wired = "Microsoft X-Box 360";
-
-
-GamepadManager::GamepadManager() :
- pDevice(NULL)
-{
-}
-
-GamepadManager::~GamepadManager()
-{
- // if we have an open device, close it
- if (pDevice)
- {
- pDevice->Close();
- pDevice = NULL;
- }
-}
-
-UInt32 GamepadManager::GetGamepadCount()
-{
- return 1;
-}
-
-bool GamepadManager::GetGamepadState(UInt32 index, GamepadState *pState)
-{
- if (!pDevice)
- {
- // get a list of paths to all the connected joystick devices
- glob_t joystickGlobBuffer;
- glob("/dev/input/js*", 0, NULL, &joystickGlobBuffer);
-
- // open each joystick device, until we find one that will work for our needs
- for (UInt32 i = 0; i < joystickGlobBuffer.gl_pathc; i++)
- {
- pDevice = new Gamepad();
- if (pDevice->Open(joystickGlobBuffer.gl_pathv[i]))
- {
-
- if (pDevice->IsSupportedType())
- {
- break;
- }
- }
-
- // we don't know why the device was not useable, make sure it gets closed cleanly
- pDevice->Close();
- pDevice = NULL;
- }
-
- }
-
- if (pDevice)
- {
- // we have a device, so update it
- pDevice->UpdateState();
-
- // copy the device state into the struct param
- memcpy(pState, pDevice->GetState(), sizeof(GamepadState));
-
- // TODO: is the device still active/connected? if not, we should close it
- // and clear pDevice, so that another device can take over
-
- return true;
- }
- else
- {
- return false;
- }
-}
-
-Gamepad::Gamepad() :
- IsInitialized(false),
- Name(String("Undefined")),
- Type(UNDEFINED)
-{
-}
-
-Gamepad::~Gamepad()
-{
- this->Close();
-}
-
-bool Gamepad::Open(const String& devicePathName)
-{
- Name = "Undefined";
- Type = UNDEFINED;
-
- FileDescriptor = ::open(devicePathName.ToCStr(), O_RDONLY | O_NONBLOCK);
- if (FileDescriptor == -1)
- {
- return false;
- }
-
- // get the device name
- char name[128];
- if (ioctl(FileDescriptor, JSIOCGNAME(sizeof(name)), name) < 0)
- {
- return false;
- }
-
- Name = name;
-
- // see if device name matches one of our supported devices
- static const UInt32 Wireless360Len = String(pNameXbox360Wireless).GetLength();
- static const UInt32 Wired360Len = String(pNameXbox360Wired).GetLength();
- if (Name.Substring(0, Wireless360Len) == pNameXbox360Wireless)
- {
- Type = XBOX360GAMEPADWIRELESS;
- return true;
- }
- else if(Name.Substring(0, Wired360Len) == pNameXbox360Wired)
- {
- Type = XBOX360GAMEPADWIRED;
- return true;
- }
-
- return false;
-}
-
-bool Gamepad::Close()
-{
- IsInitialized = false;
- Name = "Undefined";
- Type = UNDEFINED;
- return !::close(FileDescriptor);
-}
-
-void Gamepad::UpdateState()
-{
- GamepadState *pState = &State;
- js_event gamepadEvent;
-
- // read the latest batch of events
- while (read(FileDescriptor, &gamepadEvent, sizeof(struct js_event)) != -1)
- {
- switch (gamepadEvent.type)
- {
- case JS_EVENT_BUTTON:
- IsInitialized = true;
- SetStateButton(pState, gamepadEvent.number, gamepadEvent.value);
- break;
-
- case JS_EVENT_AXIS:
- IsInitialized = true;
- SetStateAxis(pState, gamepadEvent.number, gamepadEvent.value);
- break;
-
- case JS_EVENT_BUTTON | JS_EVENT_INIT:
- if (IsInitialized) // skip the fake values during device event initialization
- {
- SetStateButton(pState, gamepadEvent.number, gamepadEvent.value);
- }
- break;
-
- case JS_EVENT_AXIS | JS_EVENT_INIT:
- if (IsInitialized) // skip the fake values during device event initialization
- {
- SetStateAxis(pState, gamepadEvent.number, gamepadEvent.value);
- }
- break;
-
- default:
- LogText("OVR::Linux::UpdateState unknown event type\n");
- }
- }
-}
-
-const GamepadState* Gamepad::GetState()
-{
- return &State;
-}
-
-
-bool Gamepad::IsSupportedType()
-{
- return Type != UNDEFINED;
-}
-
-const String& Gamepad::GetIdentifier()
-{
- return Name;
-}
-
-static inline float NormalizeGamepadStickXbox360(SInt32 in)
-{
- float v;
- if (abs(in) < 9000) return 0;
- else if (in > 9000) v = (float)in - 9000;
- else v = (float)in + 9000;
- return v / (32767 - 9000);
-}
-
-static inline float NormalizeGamepadTriggerXbox360(SInt32 in,
- SInt32 offset,
- SInt32 deadBand,
- float divisor)
-{
- in += offset;
-
- if (in < deadBand)
- {
- return 0;
- }
- else
- {
- return float(in - deadBand) / divisor;
- }
-}
-
-static inline void UpdateButtonMaskAndBitfield(GamepadState *pState,
- SInt32 value,
- UInt32 buttonBitfield)
-{
- if (value)
- {
- pState->Buttons |= buttonBitfield;
- }
- else
- {
- pState->Buttons = pState->Buttons & (0xFFFFFFFF ^ buttonBitfield);
- }
-}
-
-void Gamepad::SetStateAxis(GamepadState *pState, UInt32 axis, SInt32 value)
-{
- // some pads/sticks have lots in common with one another,
- // handle those shared cases first
- switch (Type)
- {
- case XBOX360GAMEPADWIRELESS:
- case XBOX360GAMEPADWIRED:
- switch (axis)
- {
- case 0:
- pState->LX = NormalizeGamepadStickXbox360(value);
- break;
-
- case 1:
- pState->LY = -NormalizeGamepadStickXbox360(value);
- break;
-
- case 3:
- pState->RX = NormalizeGamepadStickXbox360(value);
- break;
-
- case 4:
- pState->RY = -NormalizeGamepadStickXbox360(value);
- break;
- }
- break;
-
- case UNDEFINED:
- default:
- break;
- }
-
- // handle the special cases, or pads/sticks which are unique
- switch (Type)
- {
- case XBOX360GAMEPADWIRELESS:
- switch (axis)
- {
- case 2:
- pState->LT = NormalizeGamepadTriggerXbox360(value, 0, 500, 32267);
- break;
-
- case 5:
- pState->RT = NormalizeGamepadTriggerXbox360(value, 0, 500, 32267);
- break;
- }
- break;
-
- case XBOX360GAMEPADWIRED:
- switch (axis)
- {
- case 2:
- pState->LT = NormalizeGamepadTriggerXbox360(value, 32767, 1000, 64535);
- break;
-
- case 5:
- pState->RT = NormalizeGamepadTriggerXbox360(value, 32767, 1000, 64535);
- break;
-
- case 6:
- if (value == 0)
- {
- UpdateButtonMaskAndBitfield(pState, 0, Gamepad_Left);
- UpdateButtonMaskAndBitfield(pState, 0, Gamepad_Right);
- }
- else if (value < 0)
- {
- UpdateButtonMaskAndBitfield(pState, 1, Gamepad_Left);
- }
- else if (value > 0)
- {
- UpdateButtonMaskAndBitfield(pState, 1, Gamepad_Right);
- }
- break;
-
- case 7:
- if (value == 0)
- {
- UpdateButtonMaskAndBitfield(pState, 0, Gamepad_Up);
- UpdateButtonMaskAndBitfield(pState, 0, Gamepad_Down);
- }
- else if (value < 0)
- {
- UpdateButtonMaskAndBitfield(pState, 1, Gamepad_Up);
- }
- else if (value > 0)
- {
- UpdateButtonMaskAndBitfield(pState, 1, Gamepad_Down);
- }
- break;
- }
- break;
-
- case UNDEFINED:
- default:
- break;
- }
-}
-
-void Gamepad::SetStateButton(GamepadState *pState, UInt32 button, SInt32 value)
-{
- // some pads/sticks have lots in common with one another,
- // handle those shared cases first
- switch (Type)
- {
- case XBOX360GAMEPADWIRELESS:
- case XBOX360GAMEPADWIRED:
- switch (button)
- {
- case 0:
- UpdateButtonMaskAndBitfield(pState, value, Gamepad_A);
- break;
-
- case 1:
- UpdateButtonMaskAndBitfield(pState, value, Gamepad_B);
- break;
-
- case 2:
- UpdateButtonMaskAndBitfield(pState, value, Gamepad_X);
- break;
-
- case 3:
- UpdateButtonMaskAndBitfield(pState, value, Gamepad_Y);
- break;
-
- case 4:
- UpdateButtonMaskAndBitfield(pState, value, Gamepad_L1);
- break;
-
- case 5:
- UpdateButtonMaskAndBitfield(pState, value, Gamepad_R1);
- break;
-
- case 6:
- UpdateButtonMaskAndBitfield(pState, value, Gamepad_Back);
- break;
-
- case 7:
- UpdateButtonMaskAndBitfield(pState, value, Gamepad_Start);
- break;
-
- case 8:
- // we have no value defined for the Xbox/power button
- break;
-
- case 9:
- UpdateButtonMaskAndBitfield(pState, value, Gamepad_LStick);
- break;
-
- case 10:
- UpdateButtonMaskAndBitfield(pState, value, Gamepad_RStick);
- break;
- }
- break;
-
- case UNDEFINED:
- default:
- break;
- }
-
- // handle the special cases, or pads/sticks which are unique
- switch (Type)
- {
- case XBOX360GAMEPADWIRELESS:
- switch (button)
- {
- case 11:
- UpdateButtonMaskAndBitfield(pState, value, Gamepad_Left);
- break;
-
- case 12:
- UpdateButtonMaskAndBitfield(pState, value, Gamepad_Right);
- break;
-
- case 13:
- UpdateButtonMaskAndBitfield(pState, value, Gamepad_Up);
- break;
-
- case 14:
- UpdateButtonMaskAndBitfield(pState, value, Gamepad_Down);
- break;
- }
-
- case XBOX360GAMEPADWIRED:
- break;
-
- case UNDEFINED:
- default:
- break;
- }
-}
-
-}}} // OVR::Platform::Linux
-
diff --git a/Samples/CommonSrc/Platform/Linux_Gamepad.h b/Samples/CommonSrc/Platform/Linux_Gamepad.h
deleted file mode 100644
index ba66e70..0000000
--- a/Samples/CommonSrc/Platform/Linux_Gamepad.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/************************************************************************************
-
-Filename : Linux_Gamepad.h
-Content : Linux implementation of Gamepad functionality.
-Created : May 6, 2013
-Authors : Lee Cooper, Simon Hallam
-
-Copyright : Copyright 2013 Oculus VR, Inc. All Rights reserved.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-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_Linux_Gamepad_h
-#define OVR_Linux_Gamepad_h
-
-#include "Gamepad.h"
-
-namespace OVR { namespace Platform { namespace Linux {
-
-class Gamepad; // forward declaration for readability
-
-class GamepadManager : public Platform::GamepadManager
-{
-public:
-
- GamepadManager();
- ~GamepadManager();
-
- virtual UInt32 GetGamepadCount();
- virtual bool GetGamepadState(UInt32 index, GamepadState *pState);
-
-private:
-
- Gamepad *pDevice;
-};
-
-class Gamepad
-{
-public:
-
- Gamepad();
- virtual ~Gamepad();
-
- bool Open(const String& devicePathName);
- bool Close();
- bool IsSupportedType();
- const String& GetIdentifier();
- void UpdateState();
- const GamepadState* GetState();
-
-private:
-
- void SetStateAxis(GamepadState *pState, UInt32 axis, SInt32 value);
- void SetStateButton(GamepadState *pState, UInt32 button, SInt32 value);
-
- enum GamepadType
- {
- UNDEFINED,
- XBOX360GAMEPADWIRELESS,
- XBOX360GAMEPADWIRED
- };
-
- UInt32 FileDescriptor;
- bool IsInitialized;
- String Name;
- GamepadType Type;
- GamepadState State;
-};
-
-}}}
-
-#endif // OVR_Linux_Gamepad_h
diff --git a/Samples/CommonSrc/Platform/Linux_Platform.cpp b/Samples/CommonSrc/Platform/Linux_Platform.cpp
deleted file mode 100644
index c9d3e40..0000000
--- a/Samples/CommonSrc/Platform/Linux_Platform.cpp
+++ /dev/null
@@ -1,563 +0,0 @@
-/************************************************************************************
-
-Filename : Platform_Linux.cpp
-Content : Linux (X11) implementation of Platform app infrastructure
-Created : September 6, 2012
-Authors : Andrew Reisse
-
-Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
-
-Use of this software is subject to the terms of the Oculus LLC license
-agreement provided at the time of installation or download, or which
-otherwise accompanies this software in either electronic or hard copy form.
-
-************************************************************************************/
-
-#include "Kernel/OVR_System.h"
-#include "Kernel/OVR_Array.h"
-#include "Kernel/OVR_String.h"
-#include "Kernel/OVR_Timer.h"
-
-#include "Linux_Platform.h"
-#include "Linux_Gamepad.h"
-
-// Renderers
-#include "../Render/Render_GL_Device.h"
-
-#include <X11/extensions/Xinerama.h>
-
-
-namespace OVR { namespace Platform { namespace Linux {
-
-static const char *AtomNames[] = {"WM_PROTOCOLS", "WM_DELETE_WINDOW"};
-
-PlatformCore::PlatformCore(Application* app)
- : Platform::PlatformCore(app), Disp(NULL), Win(0), Vis(NULL), Quit(0), MMode(Mouse_Normal)
-{
- pGamepadManager = *new Linux::GamepadManager();
-}
-PlatformCore::~PlatformCore()
-{
- XFreeCursor(Disp, InvisibleCursor);
-
- if (Disp)
- XCloseDisplay(Disp);
-}
-
-// Setup an X11 window in windowed mode.
-bool PlatformCore::SetupWindow(int w, int h)
-{
-
- if (!Disp)
- {
- XInitThreads();
-
- Disp = XOpenDisplay(NULL);
- if (!Disp)
- {
- OVR_DEBUG_LOG(("XOpenDisplay failed."));
- return false;
- }
-
- XInternAtoms(Disp, const_cast<char**>(AtomNames), NumAtoms, false, Atoms);
- }
-
- XSetWindowAttributes winattr;
- unsigned attrmask = CWEventMask | CWBorderPixel;
-
- winattr.event_mask = ButtonPressMask|ButtonReleaseMask|KeyPressMask|KeyReleaseMask|ButtonMotionMask|PointerMotionMask|
- /*PointerMotionHintMask|*/StructureNotifyMask;//|ExposureMask;
- winattr.border_pixel = 0;
-
- int screenNumber = DefaultScreen(Disp);
-
- if (!Vis)
- {
- int attr[16];
- int nattr = 2;
-
- attr[0] = GLX_RGBA;
- attr[1] = GLX_DOUBLEBUFFER;
- attr[nattr++] = GLX_DEPTH_SIZE;
- attr[nattr++] = 24;
- attr[nattr] = 0;
-
- Vis = glXChooseVisual(Disp, screenNumber, attr);
-
- if (!Vis)
- {
- OVR_DEBUG_LOG(("glXChooseVisual failed."));
- return false;
- }
- }
-
- Window rootWindow = XRootWindow(Disp, Vis->screen);
-
- winattr.colormap = XCreateColormap(Disp, rootWindow, Vis->visual, AllocNone);
- attrmask |= CWColormap;
-
-
- Win = XCreateWindow(Disp, rootWindow, 0, 0, w, h, 0, Vis->depth,
- InputOutput, Vis->visual, attrmask, &winattr);
-
- if (!Win)
- {
- OVR_DEBUG_LOG(("XCreateWindow failed."));
- return false;
- }
-
-
- XStoreName(Disp, Win, "OVR App");
- XSetWMProtocols(Disp, Win, &Atoms[WM_DELETE_WINDOW], 1);
-
- // Intialize empty cursor for show/hide.
- XColor black;
- static char noData[] = { 0,0,0,0,0,0,0,0 };
- black.red = black.green = black.blue = 0;
-
- Pixmap bitmapNoData = XCreateBitmapFromData(Disp, Win, noData, 8, 8);
- InvisibleCursor = XCreatePixmapCursor(Disp, bitmapNoData, bitmapNoData,
- &black, &black, 0, 0);
- XDefineCursor(Disp, Win, InvisibleCursor);
-
- Width = w;
- Height = h;
-
- return true;
-}
-
-void PlatformCore::SetMouseMode(MouseMode mm)
-{
- if (mm == MMode)
- return;
-
- if (Win)
- {
- if (mm == Mouse_Relative)
- {
- XWarpPointer(Disp, Win, Win, 0,0,Width,Height, Width/2, Height/2);
- }
- else
- {
- //if (MMode == Mouse_Relative)
- // ShowCursor(TRUE);
- }
- }
- MMode = mm;
-}
-
-void PlatformCore::GetWindowSize(int* w, int* h) const
-{
- *w = Width;
- *h = Height;
-}
-
-void PlatformCore::SetWindowTitle(const char* title)
-{
- XStoreName(Disp, Win, title);
-}
-
-void PlatformCore::ShowWindow(bool show)
-{
- if (show)
- XRaiseWindow(Disp, Win);
- else
- XIconifyWindow(Disp, Win, 0);
-}
-
-void PlatformCore::DestroyWindow()
-{
- if (Win)
- XDestroyWindow(Disp, Win);
- Win = 0;
-}
-
-
-static int KeyMap[][2] =
-{
- { XK_BackSpace, Key_Backspace },
- { XK_Tab, Key_Tab },
- { XK_Clear, Key_Clear },
- { XK_Return, Key_Return },
- { XK_Shift_L, Key_Shift },
- { XK_Control_L, Key_Control },
- { XK_Alt_L, Key_Alt },
- { XK_Shift_R, Key_Shift },
- { XK_Control_R, Key_Control },
- { XK_Alt_R, Key_Alt },
- { XK_Pause, Key_Pause },
- { XK_Caps_Lock, Key_CapsLock },
- { XK_Escape, Key_Escape },
- { XK_space, Key_Space },
- { XK_Page_Up, Key_PageUp },
- { XK_Page_Down, Key_PageDown },
- { XK_Prior, Key_PageUp },
- { XK_Next, Key_PageDown },
- { XK_End, Key_End },
- { XK_Home, Key_Home },
- { XK_Left, Key_Left },
- { XK_Up, Key_Up },
- { XK_Right, Key_Right },
- { XK_Down, Key_Down },
- { XK_Insert, Key_Insert },
- { XK_Delete, Key_Delete },
- { XK_Help, Key_Help },
- { XK_Num_Lock, Key_NumLock },
- { XK_Scroll_Lock, Key_ScrollLock },
-};
-
-
-static KeyCode MapXKToKeyCode(unsigned vk)
-{
- unsigned key = Key_None;
-
- if ((vk >= 'a') && (vk <= 'z'))
- {
- key = vk - 'a' + Key_A;
- }
- else if ((vk >= ' ') && (vk <= '~'))
- {
- key = vk;
- }
- else if ((vk >= XK_KP_0) && (vk <= XK_KP_9))
- {
- key = vk - XK_KP_0 + Key_KP_0;
- }
- else if ((vk >= XK_F1) && (vk <= XK_F15))
- {
- key = vk - XK_F1 + Key_F1;
- }
- else
- {
- for (unsigned i = 0; i< (sizeof(KeyMap) / sizeof(KeyMap[1])); i++)
- {
- if (vk == KeyMap[i][0])
- {
- key = KeyMap[i][1];
- break;
- }
- }
- }
-
- return (KeyCode)key;
-}
-
-static int MapModifiers(int xmod)
-{
- int mod = 0;
- if (xmod & ShiftMask)
- mod |= Mod_Shift;
- if (xmod & ControlMask)
- mod |= Mod_Control;
- if (xmod & Mod1Mask)
- mod |= Mod_Alt;
- if (xmod & Mod4Mask)
- mod |= Mod_Meta;
- return mod;
-}
-
-void PlatformCore::processEvent(XEvent& event)
-{
- switch (event.xany.type)
- {
- case ConfigureNotify:
- if (event.xconfigure.width != Width || event.xconfigure.height != Height)
- {
- Width = event.xconfigure.width;
- Height = event.xconfigure.height;
- pApp->OnResize(Width, Height);
-
- if (pRender)
- pRender->SetWindowSize(Width, Height);
- }
- break;
-
- case KeyPress:
- case KeyRelease:
- {
- char chars[8] = {0};
- KeySym xk;
- XComposeStatus comp;
- XLookupString(&event.xkey, chars, sizeof(chars), &xk, &comp);
- if (xk != XK_VoidSymbol)
- pApp->OnKey(MapXKToKeyCode((unsigned)xk), chars[0], event.xany.type == KeyPress, MapModifiers(event.xkey.state));
- if (xk == XK_Escape && MMode == Mouse_Relative)
- {
- //ungrab
- MMode = Mouse_RelativeEscaped;
- showCursor(true);
- }
- }
- break;
-
- case MotionNotify:
- if (MMode == Mouse_Relative)
- {
- int dx = event.xmotion.x - Width/2;
- int dy = event.xmotion.y - Height/2;
-
- // do not remove this check, WarpPointer generates events too.
- if (dx == 0 && dy == 0)
- break;
-
- XWarpPointer(Disp, Win, Win, 0,0,Width,Height, Width/2, Height/2);
- pApp->OnMouseMove(dx, dy, Mod_MouseRelative|MapModifiers(event.xmotion.state));
- }
- else
- {
- pApp->OnMouseMove(event.xmotion.x, event.xmotion.y, MapModifiers(event.xmotion.state));
- }
- break;
-
- case MapNotify:
- if (MMode == Mouse_Relative)
- {
- XWarpPointer(Disp, Win, Win, 0,0,Width,Height, Width/2, Height/2);
- showCursor(false);
- }
- break;
-
- case ButtonPress:
- if (event.xbutton.button == 1)
- {
- //grab
-
- if (MMode == Mouse_RelativeEscaped)
- {
- XWarpPointer(Disp, Win, Win, 0,0,Width,Height, Width/2, Height/2);
- showCursor(false);
- MMode = Mouse_Relative;
- }
- }
- break;
-
- case FocusOut:
- if (MMode == Mouse_Relative)
- {
- MMode = Mouse_RelativeEscaped;
- showCursor(true);
- }
- break;
-
- case ClientMessage:
- if (event.xclient.message_type == Atoms[WM_PROTOCOLS] &&
- Atom(event.xclient.data.l[0]) == Atoms[WM_DELETE_WINDOW])
- pApp->OnQuitRequest();
- break;
- }
-}
-
-int PlatformCore::Run()
-{
- while (!Quit)
- {
- if (XPending(Disp))
- {
- XEvent event;
- XNextEvent(Disp, &event);
-
- if (pApp && event.xany.window == Win)
- processEvent(event);
- }
- else
- {
- pApp->OnIdle();
- }
- }
-
- return ExitCode;
-}
-
-bool PlatformCore::determineScreenOffset(int screenId, int* screenOffsetX, int* screenOffsetY)
-{
- Display* display = XOpenDisplay(NULL);
-
- bool foundScreen = false;
-
- if (display)
- {
- int numberOfScreens;
- XineramaScreenInfo* screens = XineramaQueryScreens(display, &numberOfScreens);
-
- if (screenId < numberOfScreens)
- {
- XineramaScreenInfo screenInfo = screens[screenId];
- *screenOffsetX = screenInfo.x_org;
- *screenOffsetY = screenInfo.y_org;
-
- foundScreen = true;
- }
-
- XFree(screens);
- }
-
- return foundScreen;
-}
-
-void PlatformCore::showWindowDecorations(bool show)
-{
- // Declaration of 'MOTIF_WM_HINTS' struct and flags can be found at:
- // https://people.gnome.org/~tthurman/docs/metacity/xprops_8h-source.html
- typedef struct WMHints
- {
- unsigned long flags;
- unsigned long functions;
- unsigned long decorations;
- long inputMode;
- unsigned long status;
- } Hints;
-
- #define MWM_DECOR_ALL (1L << 0)
- #define MWM_DECOR_BORDER (1L << 1)
- #define MWM_DECOR_RESIZEH (1L << 2)
- #define MWM_DECOR_TITLE (1L << 3)
- #define MWM_DECOR_MENU (1L << 4)
- #define MWM_DECOR_MINIMIZE (1L << 5)
- #define MWM_DECOR_MAXIMIZE (1L << 6)
-
- Atom property = XInternAtom(Disp, "_MOTIF_WM_HINTS", true);
-
- Hints hints;
- hints.flags = 2; // We only want to specify decoration.
-
- if (show)
- {
- hints.decorations = MWM_DECOR_BORDER | MWM_DECOR_TITLE | MWM_DECOR_MENU | MWM_DECOR_MINIMIZE | MWM_DECOR_MAXIMIZE;
- }
- else
- {
- // Remove all window border items.
- hints.decorations = 0;
- }
-
- XChangeProperty(Disp,Win,property,property,32,PropModeReplace,(unsigned char *)&hints,5);
-}
-
-bool PlatformCore::SetFullscreen(const Render::RendererParams& rp, int fullscreen)
-{
- if (rp.Fullscreen == Render::Display_Window && fullscreen == Render::Display_FakeFullscreen)
- {
- // Transitioning from windowed to fake fullscreen.
- int xOffset;
- int yOffset;
-
- if (!determineScreenOffset(rp.Display.CgDisplayId, &xOffset, &yOffset))
- {
- return false;
- }
-
- showWindowDecorations(false);
-
- XMoveWindow(Disp, Win, xOffset, yOffset);
- XMapRaised(Disp, Win);
-
- Platform::PlatformCore::SetFullscreen(rp, fullscreen);
- return true;
- }
- else if (rp.Fullscreen == Render::Display_FakeFullscreen && fullscreen == Render::Display_Window)
- {
- // Transitioning from fake fullscreen to windowed.
- showWindowDecorations(true);
-
- XMoveWindow(Disp, Win, 0, 0);
- XMapRaised(Disp, Win);
-
- Platform::PlatformCore::SetFullscreen(rp, fullscreen);
- return true;
- }
- else if (fullscreen == Render::Display_Fullscreen)
- {
- return false;
- }
-}
-
-RenderDevice* PlatformCore::SetupGraphics(const SetupGraphicsDeviceSet& setupGraphicsDesc,
- const char* type, const Render::RendererParams& rp)
-{
- const SetupGraphicsDeviceSet* setupDesc = setupGraphicsDesc.PickSetupDevice(type);
- OVR_ASSERT(setupDesc);
-
- pRender = *setupDesc->pCreateDevice(rp, this);
- if (pRender)
- pRender->SetWindowSize(Width, Height);
-
- return pRender.GetPtr();
-}
-
-void PlatformCore::showCursor(bool show)
-{
- if (show)
- {
- XUndefineCursor(Disp, Win);
- }
- else
- {
- XDefineCursor(Disp, Win, InvisibleCursor);
- }
-}
-
-}}
-
-// GL
-namespace Render { namespace GL { namespace Linux {
-
-Render::RenderDevice* RenderDevice::CreateDevice(const RendererParams& rp, void* oswnd)
-{
- Platform::Linux::PlatformCore* PC = (Platform::Linux::PlatformCore*)oswnd;
-
- GLXContext context = glXCreateContext(PC->Disp, PC->Vis, 0, GL_TRUE);
-
- if (!context)
- return NULL;
-
- if (!glXMakeCurrent(PC->Disp, PC->Win, context))
- {
- glXDestroyContext(PC->Disp, context);
- return NULL;
- }
-
- XMapRaised(PC->Disp, PC->Win);
-
- return new Render::GL::Linux::RenderDevice(rp, PC->Disp, PC->Win, context);
-}
-
-void RenderDevice::Present()
-{
- glXSwapBuffers(Disp, Win);
-}
-
-void RenderDevice::Shutdown()
-{
- if (Context)
- {
- glXMakeCurrent(Disp, 0, NULL);
- glXDestroyContext(Disp, Context);
- Context = NULL;
- Win = 0;
- }
-}
-
-}}}}
-
-
-int main(int argc, const char* argv[])
-{
- using namespace OVR;
- using namespace OVR::Platform;
-
- // CreateApplication must be the first call since it does OVR::System::Initialize.
- Application* app = Application::CreateApplication();
- Linux::PlatformCore* platform = new Linux::PlatformCore(app);
- // The platform attached to an app will be deleted by DestroyApplication.
- app->SetPlatformCore(platform);
-
- int exitCode = app->OnStartup(argc, argv);
- if (!exitCode)
- exitCode = platform->Run();
-
- // No OVR functions involving memory are allowed after this.
- Application::DestroyApplication(app);
- app = 0;
-
- return exitCode;
-}
diff --git a/Samples/CommonSrc/Platform/Linux_Platform.h b/Samples/CommonSrc/Platform/Linux_Platform.h
deleted file mode 100644
index 7fbb220..0000000
--- a/Samples/CommonSrc/Platform/Linux_Platform.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/************************************************************************************
-
-Filename : Platform_Linux.h
-Content : Linux (X11) implementation of Platform app infrastructure
-Created : September 6, 2012
-Authors : Andrew Reisse
-
-Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
-
-Use of this software is subject to the terms of the Oculus LLC license
-agreement provided at the time of installation or download, or which
-otherwise accompanies this software in either electronic or hard copy form.
-
-************************************************************************************/
-
-#ifndef OVR_Platform_Linux_h
-#define OVR_Platform_Linux_h
-
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <GL/glx.h>
-
-#include "Platform.h"
-#include "../Render/Render_GL_Device.h"
-
-namespace OVR { namespace Render {
- class RenderDevice;
-}}
-
-namespace OVR { namespace Platform { namespace Linux {
-
-class PlatformCore : public Platform::PlatformCore
-{
-public:
- Display* Disp;
- XVisualInfo* Vis;
- Window Win;
-
- bool Quit;
- int ExitCode;
- int Width, Height;
-
- MouseMode MMode;
- Cursor InvisibleCursor;
-
- enum
- {
- WM_PROTOCOLS,
- WM_DELETE_WINDOW,
- NumAtoms
- };
- Atom Atoms[NumAtoms];
-
- void processEvent(XEvent& event);
-
- Render::RenderDevice* SetupGraphics_GL(const Render::RendererParams& rp);
-
- void showCursor(bool show);
- bool determineScreenOffset(int screenId, int* screenOffsetX, int* screenOffsetY);
- void showWindowDecorations(bool show);
-
-public:
- PlatformCore(Application* app);
- ~PlatformCore();
-
- bool SetupWindow(int w, int h);
- void Exit(int exitcode) { Quit = 1; ExitCode = exitcode; }
-
- RenderDevice* SetupGraphics(const SetupGraphicsDeviceSet& setupGraphicsDesc,
- const char* gtype, const Render::RendererParams& rp);
-
- void SetMouseMode(MouseMode mm);
- void GetWindowSize(int* w, int* h) const;
-
- void SetWindowTitle(const char*title);
-
- void ShowWindow(bool show);
- void DestroyWindow();
- bool SetFullscreen(const Render::RendererParams& rp, int fullscreen);
- int Run();
-};
-
-}}
-namespace Render { namespace GL { namespace Linux {
-
-class RenderDevice : public Render::GL::RenderDevice
-{
- Display* Disp;
- Window Win;
- GLXContext Context;
-
-public:
- RenderDevice(const Render::RendererParams& p, Display* disp, Window w, GLXContext gl)
- : GL::RenderDevice(p), Disp(disp), Win(w), Context(gl) {}
-
- virtual void Shutdown();
- virtual void Present();
-
- // oswnd = Linux::PlatformCore*
- static Render::RenderDevice* CreateDevice(const RendererParams& rp, void* oswnd);
-};
-
-}}}}
-
-
-// OVR_PLATFORM_APP_ARGS specifies the Application class to use for startup,
-// providing it with startup arguments.
-#define OVR_PLATFORM_APP_ARGS(AppClass, args) \
- OVR::Platform::Application* OVR::Platform::Application::CreateApplication() \
- { OVR::System::Init(OVR::Log::ConfigureDefaultLog(OVR::LogMask_All)); \
- return new AppClass args; } \
- void OVR::Platform::Application::DestroyApplication(OVR::Platform::Application* app) \
- { OVR::Platform::PlatformCore* platform = app->pPlatform; \
- delete app; delete platform; OVR::System::Destroy(); };
-
-// OVR_PLATFORM_APP_ARGS specifies the Application startup class with no args.
-#define OVR_PLATFORM_APP(AppClass) OVR_PLATFORM_APP_ARGS(AppClass, ())
-
-
-#endif
diff --git a/Samples/CommonSrc/Platform/OSX_Gamepad.cpp b/Samples/CommonSrc/Platform/OSX_Gamepad.cpp
deleted file mode 100644
index 934319b..0000000
--- a/Samples/CommonSrc/Platform/OSX_Gamepad.cpp
+++ /dev/null
@@ -1,424 +0,0 @@
-/************************************************************************************
-
-Filename : OSX_Gamepad.cpp
-Content : OSX implementation of Gamepad functionality.
-Created : May 6, 2013
-Authors : Lee Cooper
-
-Copyright : Copyright 2013 Oculus VR, Inc. All Rights reserved.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-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.
-
-************************************************************************************/
-
-#include "OSX_Gamepad.h"
-
-
-static const UInt32 Logitech_F710_VendorID = 0x046D;
-static const UInt32 Logitech_F710_ProductID = 0xC219;
-
-static const UInt32 Sony_DualShock3_VendorID = 0x054C;
-static const UInt32 Sony_DualShock3_ProductID = 0x0268;
-
-
-namespace OVR { namespace Platform { namespace OSX {
-
-
-GamepadManager::GamepadManager()
- : bStateChanged(false)
-{
-
- HidManager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
- IOHIDManagerOpen(HidManager, kIOHIDOptionsTypeNone);
- IOHIDManagerScheduleWithRunLoop(HidManager,
- CFRunLoopGetCurrent(),
- kCFRunLoopDefaultMode);
-
-
- // Setup device matching.
- CFStringRef keys[] = { CFSTR(kIOHIDDeviceUsagePageKey),
- CFSTR(kIOHIDDeviceUsageKey)};
-
- int value;
- CFNumberRef values[2];
- CFDictionaryRef dictionaries[2];
-
- // Match joysticks.
- value = kHIDPage_GenericDesktop;
- values[0] = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value);
-
- value = kHIDUsage_GD_Joystick;
- values[1] = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value);
-
- dictionaries[0] = CFDictionaryCreate(kCFAllocatorDefault,
- (const void **) keys,
- (const void **) values,
- 2,
- &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
- CFRelease(values[0]);
- CFRelease(values[1]);
-
- // Match gamepads.
- value = kHIDPage_GenericDesktop;
- values[0] = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value);
-
- value = kHIDUsage_GD_GamePad;
- values[1] = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value);
-
- dictionaries[1] = CFDictionaryCreate(kCFAllocatorDefault,
- (const void **) keys,
- (const void **) values,
- 2,
- &kCFTypeDictionaryKeyCallBacks,
- &kCFTypeDictionaryValueCallBacks);
- CFRelease(values[0]);
- CFRelease(values[1]);
-
- CFArrayRef array = CFArrayCreate( kCFAllocatorDefault,
- (const void **) dictionaries,
- 2,
- &kCFTypeArrayCallBacks);
- CFRelease(dictionaries[0]);
- CFRelease(dictionaries[1]);
-
- IOHIDManagerSetDeviceMatchingMultiple(HidManager, array);
-
- CFRelease(array);
-
-
- IOHIDManagerRegisterDeviceMatchingCallback(HidManager, staticOnDeviceMatched, this);
- IOHIDManagerRegisterDeviceRemovalCallback(HidManager, staticOnDeviceRemoved, this);
-
-}
-
-GamepadManager::~GamepadManager()
-{
- CFRelease(HidManager);
-}
-
-UInt32 GamepadManager::GetGamepadCount()
-{
- return 1;
-}
-
-bool GamepadManager::GetGamepadState(UInt32 index, GamepadState* pState)
-{
- // For now we just support one gamepad.
- OVR_UNUSED(index);
-
- if (!bStateChanged)
- {
- return false;
- }
-
- bStateChanged = false;
-// State.Debug();
-
- *pState = State;
- return true;
-}
-
-int GamepadManager::getIntDeviceProperty(IOHIDDeviceRef device, CFStringRef key)
-{
- CFTypeRef type = IOHIDDeviceGetProperty(device, key);
- OVR_ASSERT(type != NULL && CFGetTypeID(type) == CFNumberGetTypeID());
-
- int value;
- CFNumberGetValue((CFNumberRef) type, kCFNumberSInt32Type, &value);
-
- return value;
-}
-
-void GamepadManager::staticOnDeviceMatched(void* context, IOReturn result, void* sender, IOHIDDeviceRef device)
-{
- GamepadManager* pManager = (GamepadManager*) context;
- pManager->onDeviceMatched(device);
-}
-
-void GamepadManager::onDeviceMatched(IOHIDDeviceRef device)
-{
- IOHIDDeviceRegisterInputValueCallback(device, staticOnDeviceValueChanged, this);
-}
-
-void GamepadManager::staticOnDeviceRemoved(void* context, IOReturn result, void* sender, IOHIDDeviceRef device)
-{
- GamepadManager* pManager = (GamepadManager*) context;
- pManager->onDeviceRemoved(device);
-}
-
-void GamepadManager::onDeviceRemoved(IOHIDDeviceRef device)
-{
- IOHIDDeviceRegisterInputValueCallback(device, NULL, NULL);
-}
-
-void GamepadManager::staticOnDeviceValueChanged(void* context, IOReturn result, void* sender, IOHIDValueRef value)
-{
- GamepadManager* pManager = (GamepadManager*) context;
- pManager->onDeviceValueChanged(value);
-}
-
-float GamepadManager::mapAnalogAxis(IOHIDValueRef value, IOHIDElementRef element)
-{
-
- CFIndex val = IOHIDValueGetIntegerValue(value);
- CFIndex min = IOHIDElementGetLogicalMin(element);
- CFIndex max = IOHIDElementGetLogicalMax(element);
-
- float v = (float) (val - min) / (float) (max - min);
- v = v * 2.0f - 1.0f;
-
- // Dead zone.
- if (v < 0.1f && v > -0.1f)
- {
- v = 0.0f;
- }
-
- return v;
-}
-
-bool GamepadManager::setStateIfDifferent(float& state, float newState)
-{
- if (state == newState)
- return false;
-
- state = newState;
-
- return true;
-}
-
-void GamepadManager::onDeviceValueChanged(IOHIDValueRef value)
-{
-
- IOHIDElementRef element = IOHIDValueGetElement(value);
- IOHIDDeviceRef device = IOHIDElementGetDevice(element);
-
- int vendorID = getIntDeviceProperty(device, CFSTR(kIOHIDVendorIDKey));
- int productID = getIntDeviceProperty(device, CFSTR(kIOHIDProductIDKey));
- OVR_UNUSED(productID);
-
- uint32_t usagePage = IOHIDElementGetUsagePage(element);
- uint32_t usage = IOHIDElementGetUsage(element);
-
- // The following controller mapping is based on the Logitech F710, however we use it for
- // all Logitech devices on the assumption that they're likely to share the same mapping.
- if (vendorID == Logitech_F710_VendorID)
- {
- // Logitech F710 mapping.
- if (usagePage == kHIDPage_Button)
- {
- bool buttonState = IOHIDValueGetIntegerValue(value);
-
- switch(usage)
- {
- case kHIDUsage_Button_1:
- manipulateBitField(State.Buttons, Gamepad_X, buttonState);
- break;
- case kHIDUsage_Button_2:
- manipulateBitField(State.Buttons, Gamepad_A, buttonState);
- break;
- case kHIDUsage_Button_3:
- manipulateBitField(State.Buttons, Gamepad_B, buttonState);
- break;
- case kHIDUsage_Button_4:
- manipulateBitField(State.Buttons, Gamepad_Y, buttonState);
- break;
- case 0x05:
- manipulateBitField(State.Buttons, Gamepad_L1, buttonState);
- break;
- case 0x06:
- manipulateBitField(State.Buttons, Gamepad_R1, buttonState);
- break;
- case 0x07:
- State.LT = buttonState ? 1.0f:0.0f;
- break;
- case 0x08:
- State.RT = buttonState ? 1.0f:0.0f;
- break;
- case 0x09:
- manipulateBitField(State.Buttons, Gamepad_Back, buttonState);
- break;
- case 0x0A:
- manipulateBitField(State.Buttons, Gamepad_Start, buttonState);
- break;
- case 0x0B:
- manipulateBitField(State.Buttons, Gamepad_LStick, buttonState);
- break;
- case 0x0C:
- manipulateBitField(State.Buttons, Gamepad_RStick, buttonState);
- break;
- default:
- return;
- }
- }
- else if (usagePage == kHIDPage_GenericDesktop)
- {
- float v;
- switch(usage)
- {
- case kHIDUsage_GD_X:
- v = mapAnalogAxis(value, element);
- if (!setStateIfDifferent(State.LX, v))
- return;
- break;
- case kHIDUsage_GD_Y:
- v = mapAnalogAxis(value, element);
- if (!setStateIfDifferent(State.LY, -v))
- return;
- break;
- case kHIDUsage_GD_Z:
- v = mapAnalogAxis(value, element);
- if (!setStateIfDifferent(State.RX, v))
- return;
- break;
- case kHIDUsage_GD_Rz:
- v = mapAnalogAxis(value, element);
- if (!setStateIfDifferent(State.RY, -v))
- return;
- break;
- case kHIDUsage_GD_Hatswitch:
- {
- CFIndex integerValue = IOHIDValueGetIntegerValue(value);
-
- manipulateBitField(State.Buttons,
- Gamepad_Up,
- integerValue == 7 || integerValue == 0 || integerValue == 1);
- manipulateBitField(State.Buttons,
- Gamepad_Down,
- integerValue == 3 || integerValue == 4 || integerValue == 5);
- manipulateBitField(State.Buttons,
- Gamepad_Left,
- integerValue == 5 || integerValue == 6 || integerValue == 7);
- manipulateBitField(State.Buttons,
- Gamepad_Right,
- integerValue == 1 || integerValue == 2 || integerValue == 3);
- }
- break;
- default:
- return;
- }
- }
- }
- // The following controller mapping is based on the Sony DualShock3, however we use it for
- // all Sony devices on the assumption that they're likely to share the same mapping.
- else if (vendorID == Sony_DualShock3_VendorID)
- {
- // PS3 Controller.
- if (usagePage == kHIDPage_Button)
- {
- bool buttonState = IOHIDValueGetIntegerValue(value);
-
- switch(usage)
- {
- case kHIDUsage_Button_1:
- manipulateBitField(State.Buttons, Gamepad_Back, buttonState);
- break;
- case kHIDUsage_Button_2:
- manipulateBitField(State.Buttons, Gamepad_LStick, buttonState);
- break;
- case kHIDUsage_Button_3:
- manipulateBitField(State.Buttons, Gamepad_RStick, buttonState);
- break;
- case kHIDUsage_Button_4:
- manipulateBitField(State.Buttons, Gamepad_Start, buttonState);
- break;
- case 0x05:
- manipulateBitField(State.Buttons, Gamepad_Up, buttonState);
- break;
- case 0x06:
- manipulateBitField(State.Buttons, Gamepad_Right, buttonState);
- break;
- case 0x07:
- manipulateBitField(State.Buttons, Gamepad_Down, buttonState);
- break;
- case 0x08:
- manipulateBitField(State.Buttons, Gamepad_Left, buttonState);
- break;
- case 0x09:
- State.LT = buttonState ? 1.0f:0.0f;
- break;
- case 0x0A:
- State.RT = buttonState ? 1.0f:0.0f;
- break;
- case 0x0B:
- manipulateBitField(State.Buttons, Gamepad_L1, buttonState);
- break;
- case 0x0C:
- manipulateBitField(State.Buttons, Gamepad_R1, buttonState);
- break;
- case 0x0D:
- // PS3 Triangle.
- manipulateBitField(State.Buttons, Gamepad_TRIANGLE, buttonState);
- break;
- case 0x0E:
- // PS3 Circle
- manipulateBitField(State.Buttons, Gamepad_CIRCLE, buttonState);
- break;
- case 0x0F:
- // PS3 Cross
- manipulateBitField(State.Buttons, Gamepad_CROSS, buttonState);
- break;
- case 0x10:
- // PS3 Square
- manipulateBitField(State.Buttons, Gamepad_SQUARE, buttonState);
- break;
- default:
- return;
- }
- }
- else if (usagePage == kHIDPage_GenericDesktop)
- {
- float v;
- switch(usage)
- {
- case kHIDUsage_GD_X:
- v = mapAnalogAxis(value, element);
- if (!setStateIfDifferent(State.LX, v))
- return;
- break;
- case kHIDUsage_GD_Y:
- v = mapAnalogAxis(value, element);
- if (!setStateIfDifferent(State.LY, -v))
- return;
- break;
- case kHIDUsage_GD_Z:
- v = mapAnalogAxis(value, element);
- if (!setStateIfDifferent(State.RX, v))
- return;
- break;
- case kHIDUsage_GD_Rz:
- v = mapAnalogAxis(value, element);
- if (!setStateIfDifferent(State.RY, -v))
- return;
- break;
- default:
- return;
- }
- }
- }
-
- bStateChanged = true;
-}
-
-void GamepadManager::manipulateBitField(unsigned int& bitfield, unsigned int mask, bool val)
-{
- if (val)
- {
- bitfield |= mask;
- }
- else
- {
- bitfield &= ~mask;
- }
-}
-
-}}} // OVR::Platform::OSX
diff --git a/Samples/CommonSrc/Platform/OSX_Gamepad.h b/Samples/CommonSrc/Platform/OSX_Gamepad.h
deleted file mode 100644
index 335a512..0000000
--- a/Samples/CommonSrc/Platform/OSX_Gamepad.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/************************************************************************************
-
-Filename : OSX_Gamepad.h
-Content : OSX implementation of Gamepad functionality.
-Created : May 6, 2013
-Authors : Lee Cooper
-
-Copyright : Copyright 2013 Oculus VR, Inc. All Rights reserved.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-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_Gamepad_h
-#define OVR_OSX_Gamepad_h
-
-#include <IOKit/IOKitLib.h>
-#include <IOKit/hid/IOHIDManager.h>
-
-#include "Gamepad.h"
-
-namespace OVR { namespace Platform { namespace OSX {
-
-
-class GamepadManager : public Platform::GamepadManager
-{
-public:
- GamepadManager();
- ~GamepadManager();
-
- virtual UInt32 GetGamepadCount();
- virtual bool GetGamepadState(UInt32 index, GamepadState* pState);
-
-private:
- static void staticOnDeviceMatched(void* context, IOReturn result, void* sender, IOHIDDeviceRef device);
- void onDeviceMatched(IOHIDDeviceRef device);
-
- static void staticOnDeviceRemoved(void* context, IOReturn result, void* sender, IOHIDDeviceRef device);
- void onDeviceRemoved(IOHIDDeviceRef device);
-
- static void staticOnDeviceValueChanged(void* context, IOReturn result, void* sender, IOHIDValueRef value);
- void onDeviceValueChanged(IOHIDValueRef value);
-
- int getIntDeviceProperty(IOHIDDeviceRef device, CFStringRef key);
- float mapAnalogAxis(IOHIDValueRef value, IOHIDElementRef element);
- void manipulateBitField(unsigned int& bitfield, unsigned int mask, bool val);
- bool setStateIfDifferent(float& state, float newState);
-
- IOHIDManagerRef HidManager;
- GamepadState State;
- bool bStateChanged;
-};
-
-}}}
-
-#endif // OVR_OSX_Gamepad_h
diff --git a/Samples/CommonSrc/Platform/OSX_Platform.h b/Samples/CommonSrc/Platform/OSX_Platform.h
deleted file mode 100644
index 11d4279..0000000
--- a/Samples/CommonSrc/Platform/OSX_Platform.h
+++ /dev/null
@@ -1,80 +0,0 @@
-
-#include "../Platform/Platform.h"
-#include "../Render/Render_GL_Device.h"
-
-namespace OVR { namespace Platform { namespace OSX {
-
-class PlatformCore : public Platform::PlatformCore
-{
-public:
- void* Win;
- void* View;
- void* NsApp;
- bool Quit;
- int ExitCode;
- int Width, Height;
- MouseMode MMode;
-
- void RunIdle();
-
-public:
- PlatformCore(Application* app, void* nsapp);
- ~PlatformCore();
-
- bool SetupWindow(int w, int h);
- void Exit(int exitcode);
-
- RenderDevice* SetupGraphics(const SetupGraphicsDeviceSet& setupGraphicsDesc,
- const char* gtype, const Render::RendererParams& rp);
-
- void SetMouseMode(MouseMode mm);
- void GetWindowSize(int* w, int* h) const;
-
- void SetWindowTitle(const char*title);
-
- void ShowWindow(bool show);
- void DestroyWindow();
- bool SetFullscreen(const Render::RendererParams& rp, int fullscreen);
- int GetDisplayCount();
- Render::DisplayId GetDisplay(int screen);
-
- String GetContentDirectory() const;
-};
-
-}}
-namespace Render { namespace GL { namespace OSX {
-
-class RenderDevice : public Render::GL::RenderDevice
-{
-public:
- void* Context;
-
- RenderDevice(const Render::RendererParams& p, void* context)
- : GL::RenderDevice(p), Context(context) {}
-
- virtual void Shutdown();
- virtual void Present();
-
- virtual bool SetFullscreen(DisplayMode fullscreen);
-
- // oswnd = X11::PlatformCore*
- static Render::RenderDevice* CreateDevice(const RendererParams& rp, void* oswnd);
-};
-
-}}}}
-
-
-// OVR_PLATFORM_APP_ARGS specifies the Application class to use for startup,
-// providing it with startup arguments.
-#define OVR_PLATFORM_APP_ARGS(AppClass, args) \
-OVR::Platform::Application* OVR::Platform::Application::CreateApplication() \
-{ OVR::System::Init(OVR::Log::ConfigureDefaultLog(OVR::LogMask_All)); \
-return new AppClass args; } \
-void OVR::Platform::Application::DestroyApplication(OVR::Platform::Application* app) \
-{ OVR::Platform::PlatformCore* platform = app->pPlatform; \
-delete app; delete platform; OVR::System::Destroy(); };
-
-// OVR_PLATFORM_APP_ARGS specifies the Application startup class with no args.
-#define OVR_PLATFORM_APP(AppClass) OVR_PLATFORM_APP_ARGS(AppClass, ())
-
-
diff --git a/Samples/CommonSrc/Platform/OSX_Platform.mm b/Samples/CommonSrc/Platform/OSX_Platform.mm
deleted file mode 100644
index 491ff6c..0000000
--- a/Samples/CommonSrc/Platform/OSX_Platform.mm
+++ /dev/null
@@ -1,514 +0,0 @@
-
-#import "../Platform/OSX_PlatformObjc.h"
-
-using namespace OVR;
-using namespace OVR::Platform;
-
-@implementation OVRApp
-
-- (void)dealloc
-{
- [super dealloc];
-}
-
-- (void)run
-{
- NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- _running = YES;
- OVR::Platform::Application* app;
- {
- using namespace OVR;
- using namespace OVR::Platform;
-
- // CreateApplication must be the first call since it does OVR::System::Initialize.
- app = Application::CreateApplication();
- OSX::PlatformCore* platform = new OSX::PlatformCore(app, self);
- // The platform attached to an app will be deleted by DestroyApplication.
- app->SetPlatformCore(platform);
-
- [self setApp:app];
- [self setPlatform:platform];
-
- const char* argv[] = {"OVRApp"};
- int exitCode = app->OnStartup(1, argv);
- if (exitCode)
- {
- Application::DestroyApplication(app);
- exit(exitCode);
- }
- }
- [self finishLaunching];
- [pool drain];
-
- while ([self isRunning])
- {
- pool = [[NSAutoreleasePool alloc] init];
- NSEvent* event = [self nextEventMatchingMask:NSAnyEventMask untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES];
- if (event)
- {
- [self sendEvent:event];
- }
- _App->OnIdle();
- [pool drain];
- }
- OVR::Platform::Application::DestroyApplication(app);
-}
-
-@end
-
-static int KeyMap[][2] =
-{
- { NSDeleteFunctionKey, OVR::Key_Delete },
- { '\t', OVR::Key_Tab },
- { '\n', OVR::Key_Return },
- { NSPauseFunctionKey, OVR::Key_Pause },
- { 27, OVR::Key_Escape },
- { 127, OVR::Key_Backspace },
- { ' ', OVR::Key_Space },
- { NSPageUpFunctionKey, OVR::Key_PageUp },
- { NSPageDownFunctionKey, OVR::Key_PageDown },
- { NSNextFunctionKey, OVR::Key_PageDown },
- { NSEndFunctionKey, OVR::Key_End },
- { NSHomeFunctionKey, OVR::Key_Home },
- { NSLeftArrowFunctionKey, OVR::Key_Left },
- { NSUpArrowFunctionKey, OVR::Key_Up },
- { NSRightArrowFunctionKey, OVR::Key_Right },
- { NSDownArrowFunctionKey, OVR::Key_Down },
- { NSInsertFunctionKey, OVR::Key_Insert },
- { NSDeleteFunctionKey, OVR::Key_Delete },
- { NSHelpFunctionKey, OVR::Key_Insert },
-};
-
-
-static KeyCode MapToKeyCode(wchar_t vk)
-{
- unsigned key = Key_None;
-
- if ((vk >= 'a') && (vk <= 'z'))
- {
- key = vk - 'a' + Key_A;
- }
- else if ((vk >= ' ') && (vk <= '~'))
- {
- key = vk;
- }
- else if ((vk >= '0') && (vk <= '9'))
- {
- key = vk - '0' + Key_Num0;
- }
- else if ((vk >= NSF1FunctionKey) && (vk <= NSF15FunctionKey))
- {
- key = vk - NSF1FunctionKey + Key_F1;
- }
- else
- {
- for (unsigned i = 0; i< (sizeof(KeyMap) / sizeof(KeyMap[1])); i++)
- {
- if (vk == KeyMap[i][0])
- {
- key = KeyMap[i][1];
- break;
- }
- }
- }
-
- return (KeyCode)key;
-}
-
-static int MapModifiers(unsigned long xmod)
-{
- int mod = 0;
- if (xmod & NSShiftKeyMask)
- mod |= OVR::Platform::Mod_Shift;
- if (xmod & NSCommandKeyMask)
- mod |= OVR::Platform::Mod_Control;
- if (xmod & NSAlternateKeyMask)
- mod |= OVR::Platform::Mod_Alt;
- if (xmod & NSControlKeyMask)
- mod |= OVR::Platform::Mod_Meta;
- return mod;
-}
-
-@implementation OVRView
-
--(BOOL) acceptsFirstResponder
-{
- return YES;
-}
--(BOOL) acceptsFirstMouse:(NSEvent *)ev
-{
- return YES;
-}
-
-+(CGDirectDisplayID) displayFromScreen:(NSScreen *)s
-{
- NSNumber* didref = (NSNumber*)[[s deviceDescription] objectForKey:@"NSScreenNumber"];
- CGDirectDisplayID disp = (CGDirectDisplayID)[didref longValue];
- return disp;
-}
-
--(void) warpMouseToCenter
-{
- NSPoint w;
- w.x = _Platform->Width/2.0f;
- w.y = _Platform->Height/2.0f;
- w = [[self window] convertBaseToScreen:w];
- CGDirectDisplayID disp = [OVRView displayFromScreen:[[self window] screen]];
- CGPoint p = {w.x, CGDisplayPixelsHigh(disp)-w.y};
- CGDisplayMoveCursorToPoint(disp, p);
-}
-
-static bool LookupKey(NSEvent* ev, wchar_t& ch, OVR::KeyCode& key, unsigned& mods)
-{
- NSString* chars = [ev charactersIgnoringModifiers];
- if ([chars length] == 0)
- return false;
- ch = [chars characterAtIndex:0];
- mods = MapModifiers([ev modifierFlags]);
-
- // check for Cmd+Latin Letter
- NSString* modchars = [ev characters];
- if ([modchars length])
- {
- wchar_t modch = [modchars characterAtIndex:0];
- if (modch >= 'a' && modch <= 'z')
- ch = modch;
- }
- key = MapToKeyCode(ch);
- return true;
-}
-
--(void) keyDown:(NSEvent*)ev
-{
- OVR::KeyCode key;
- unsigned mods;
- wchar_t ch;
- if (!LookupKey(ev, ch, key, mods))
- return;
- if (key == Key_Escape && _Platform->MMode == Mouse_Relative)
- {
- [self warpMouseToCenter];
- CGAssociateMouseAndMouseCursorPosition(true);
- [NSCursor unhide];
- _Platform->MMode = Mouse_RelativeEscaped;
- }
- _App->OnKey(key, ch, true, mods);
-}
--(void) keyUp:(NSEvent*)ev
-{
- OVR::KeyCode key;
- unsigned mods;
- wchar_t ch;
- if (LookupKey(ev, ch, key, mods))
- _App->OnKey(key, ch, false, mods);
-}
-
-static const OVR::KeyCode ModifierKeys[] = {OVR::Key_None, OVR::Key_Shift, OVR::Key_Control, OVR::Key_Alt, OVR::Key_Meta};
-
--(void)flagsChanged:(NSEvent *)ev
-{
- unsigned long cmods = [ev modifierFlags];
- if ((cmods & 0xffff0000) != _Modifiers)
- {
- uint32_t mods = MapModifiers(cmods);
- for (int i = 1; i <= 4; i++)
- {
- unsigned long m = (1 << (16+i));
- if ((cmods & m) != (_Modifiers & m))
- {
- if (cmods & m)
- _App->OnKey(ModifierKeys[i], 0, true, mods);
- else
- _App->OnKey(ModifierKeys[i], 0, false, mods);
- }
- }
- _Modifiers = cmods & 0xffff0000;
- }
-}
-
--(void)ProcessMouse:(NSEvent*)ev
-{
- switch ([ev type])
- {
- case NSLeftMouseDragged:
- case NSRightMouseDragged:
- case NSOtherMouseDragged:
- case NSMouseMoved:
- {
- if (_Platform->MMode == OVR::Platform::Mouse_Relative)
- {
- int dx = [ev deltaX];
- int dy = [ev deltaY];
-
- if (dx != 0 || dy != 0)
- {
- _App->OnMouseMove(dx, dy, Mod_MouseRelative|MapModifiers([ev modifierFlags]));
- [self warpMouseToCenter];
- }
- }
- else
- {
- NSPoint p = [ev locationInWindow];
- _App->OnMouseMove(p.x, p.y, MapModifiers([ev modifierFlags]));
- }
- }
- break;
- case NSLeftMouseDown:
- case NSRightMouseDown:
- case NSOtherMouseDown:
- break;
- }
-}
-
--(void) mouseMoved:(NSEvent*)ev
-{
- [self ProcessMouse:ev];
-}
--(void) mouseDragged:(NSEvent*)ev
-{
- [self ProcessMouse:ev];
-}
--(void) mouseDown:(NSEvent*)ev
-{
- if (_Platform->MMode == Mouse_RelativeEscaped)
- {
- [self warpMouseToCenter];
- CGAssociateMouseAndMouseCursorPosition(false);
- [NSCursor hide];
- _Platform->MMode = Mouse_Relative;
- }
-}
-
-//-(void)
-
--(id) initWithFrame:(NSRect)frameRect
-{
- NSOpenGLPixelFormatAttribute attr[] =
- {NSOpenGLPFAWindow, NSOpenGLPFADoubleBuffer, NSOpenGLPFADepthSize, 24, nil};
-
- NSOpenGLPixelFormat *pf = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attr] autorelease];
-
- self = [super initWithFrame:frameRect pixelFormat:pf];
- GLint swap = 0;
- [[self openGLContext] setValues:&swap forParameter:NSOpenGLCPSwapInterval];
- //[self setWantsBestResolutionOpenGLSurface:YES];
- return self;
-}
-
--(void) reshape
-{
- NSRect bounds = [self bounds];
- _App->OnResize(bounds.size.width, bounds.size.height);
-
- _Platform->Width = bounds.size.width;
- _Platform->Height = bounds.size.height;
-
- if (_Platform->GetRenderer())
- _Platform->GetRenderer()->SetWindowSize(bounds.size.width, bounds.size.height);
-}
-
--(BOOL)windowShouldClose:(id)sender
-{
- if (_Platform)
- _Platform->Exit(0);
- else
- exit(0);
- return 1;
-}
-
-@end
-
-namespace OVR { namespace Platform { namespace OSX {
-
-PlatformCore::PlatformCore(Application* app, void* nsapp)
- : Platform::PlatformCore(app), NsApp(nsapp), Win(NULL), View(NULL), Quit(0), MMode(Mouse_Normal)
-{
- pGamepadManager = *new OSX::GamepadManager();
-}
-PlatformCore::~PlatformCore()
-{
-}
-
-void PlatformCore::Exit(int exitcode)
-{
- OVRApp* nsApp = (OVRApp*)NsApp;
- [nsApp stop:nil];
-}
-
-String PlatformCore::GetContentDirectory() const
-{
- NSBundle* bundle = [NSBundle mainBundle];
- if (bundle)
- return String([[bundle bundlePath] UTF8String]) + "/Contents/Resources";
- else
- return ".";
-}
-
-
-void PlatformCore::SetMouseMode(MouseMode mm)
-{
- if (mm == MMode)
- return;
-
- if (Win)
- {
- if (mm == Mouse_Relative)
- {
- [NSCursor hide];
- [(OVRView*)View warpMouseToCenter];
- CGAssociateMouseAndMouseCursorPosition(false);
- }
- else
- {
- if (MMode == Mouse_Relative)
- {
- CGAssociateMouseAndMouseCursorPosition(true);
- [NSCursor unhide];
- [(OVRView*)View warpMouseToCenter];
- }
- }
- }
- MMode = mm;
-}
-
-
-void PlatformCore::GetWindowSize(int* w, int* h) const
-{
- *w = Width;
- *h = Height;
-}
-
-bool PlatformCore::SetupWindow(int w, int h)
-{
- NSRect winrect;
- winrect.origin.x = 0;
- winrect.origin.y = 1000;
- winrect.size.width = w;
- winrect.size.height = h;
- NSWindow* win = [[NSWindow alloc] initWithContentRect:winrect styleMask:NSTitledWindowMask|NSClosableWindowMask backing:NSBackingStoreBuffered defer:NO];
-
- OVRView* view = [[OVRView alloc] initWithFrame:winrect];
- [view setPlatform:this];
- [win setContentView:view];
- [win setAcceptsMouseMovedEvents:YES];
- [win setDelegate:view];
- [view setApp:pApp];
- Win = win;
- View = view;
- return 1;
-}
-
-void PlatformCore::SetWindowTitle(const char* title)
-{
- [((NSWindow*)Win) setTitle:[[NSString alloc] initWithBytes:title length:strlen(title) encoding:NSUTF8StringEncoding]];
-}
-
-void PlatformCore::ShowWindow(bool show)
-{
- if (show)
- [((NSWindow*)Win) makeKeyAndOrderFront:nil];
- else
- [((NSWindow*)Win) orderOut:nil];
-}
-
-void PlatformCore::DestroyWindow()
-{
- [((NSWindow*)Win) close];
- Win = NULL;
-}
-
-RenderDevice* PlatformCore::SetupGraphics(const SetupGraphicsDeviceSet& setupGraphicsDesc,
- const char* type, const Render::RendererParams& rp)
-{
- const SetupGraphicsDeviceSet* setupDesc = setupGraphicsDesc.PickSetupDevice(type);
- OVR_ASSERT(setupDesc);
-
- pRender = *setupDesc->pCreateDevice(rp, this);
- if (pRender)
- pRender->SetWindowSize(Width, Height);
-
- return pRender.GetPtr();
-}
-
-int PlatformCore::GetDisplayCount()
-{
- return (int)[[NSScreen screens] count];
-}
-
-Render::DisplayId PlatformCore::GetDisplay(int i)
-{
- NSScreen* s = (NSScreen*)[[NSScreen screens] objectAtIndex:i];
- return Render::DisplayId([OVRView displayFromScreen:s]);
-}
-
-bool PlatformCore::SetFullscreen(const Render::RendererParams& rp, int fullscreen)
-{
- if (fullscreen == Render::Display_Window)
- [(OVRView*)View exitFullScreenModeWithOptions:nil];
- else
- {
- NSScreen* usescreen = [NSScreen mainScreen];
- NSArray* screens = [NSScreen screens];
- for (int i = 0; i < [screens count]; i++)
- {
- NSScreen* s = (NSScreen*)[screens objectAtIndex:i];
- CGDirectDisplayID disp = [OVRView displayFromScreen:s];
-
- if (disp == rp.Display.CgDisplayId)
- usescreen = s;
- }
-
- [(OVRView*)View enterFullScreenMode:usescreen withOptions:nil];
- }
-
- if (pRender)
- pRender->SetFullscreen((Render::DisplayMode)fullscreen);
- return 1;
-}
-
-}}
-// GL
-namespace Render { namespace GL { namespace OSX {
-
-Render::RenderDevice* RenderDevice::CreateDevice(const RendererParams& rp, void* oswnd)
-{
- Platform::OSX::PlatformCore* PC = (Platform::OSX::PlatformCore*)oswnd;
-
- OVRView* view = (OVRView*)PC->View;
- NSOpenGLContext *context = [view openGLContext];
- if (!context)
- return NULL;
-
- [context makeCurrentContext];
- [((NSWindow*)PC->Win) makeKeyAndOrderFront:nil];
-
- return new Render::GL::OSX::RenderDevice(rp, context);
-}
-
-void RenderDevice::Present()
-{
- NSOpenGLContext *context = (NSOpenGLContext*)Context;
- [context flushBuffer];
-}
-
-void RenderDevice::Shutdown()
-{
- Context = NULL;
-}
-
-bool RenderDevice::SetFullscreen(DisplayMode fullscreen)
-{
- Params.Fullscreen = fullscreen;
- return 1;
-}
-
-}}}}
-
-
-int main(int argc, char *argv[])
-{
- NSApplication* nsapp = [OVRApp sharedApplication];
- [nsapp run];
- return 0;
-}
-
diff --git a/Samples/CommonSrc/Platform/OSX_PlatformObjc.h b/Samples/CommonSrc/Platform/OSX_PlatformObjc.h
deleted file mode 100644
index 7d195eb..0000000
--- a/Samples/CommonSrc/Platform/OSX_PlatformObjc.h
+++ /dev/null
@@ -1,31 +0,0 @@
-
-#import <Cocoa/Cocoa.h>
-#import "OSX_Platform.h"
-#import "OSX_Gamepad.h"
-
-#import <CoreGraphics/CoreGraphics.h>
-#import <CoreGraphics/CGDirectDisplay.h>
-
-@interface OVRApp : NSApplication
-
-@property (assign) IBOutlet NSWindow* win;
-@property (assign) OVR::Platform::OSX::PlatformCore* Platform;
-@property (assign) OVR::Platform::Application* App;
-
--(void) run;
-
-@end
-
-@interface OVRView : NSOpenGLView <NSWindowDelegate>
-
-@property (assign) OVR::Platform::OSX::PlatformCore* Platform;
-@property (assign) OVR::Platform::Application* App;
-@property unsigned long Modifiers;
-
--(void)ProcessMouse:(NSEvent*)event;
--(void)warpMouseToCenter;
-
-+(CGDirectDisplayID) displayFromScreen:(NSScreen*)s;
-
-@end
-
diff --git a/Samples/CommonSrc/Platform/OSX_WavPlayer.cpp b/Samples/CommonSrc/Platform/OSX_WavPlayer.cpp
deleted file mode 100644
index a6cb937..0000000
--- a/Samples/CommonSrc/Platform/OSX_WavPlayer.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-/************************************************************************************
-
-Filename : WavPlayer_OSX.cpp
-Content : An Apple OSX audio handler.
-Created : March 5, 2013
-Authors : Robotic Arm Software - Peter Hoff, Dan Goodman, Bryan Croteau
-
-Copyright : Copyright 2013 Oculus VR, Inc. All Rights reserved.
-
-Use of this software is subject to the terms of the Oculus LLC license
-agreement provided at the time of installation or download, or which
-otherwise accompanies this software in either electronic or hard copy form.
-
-************************************************************************************/
-
-#include "OSX_WavPlayer.h"
-
-namespace OVR { namespace Platform { namespace OSX {
-
-WavPlayer::WavPlayer(const char* fileName)
-{
- FileName = fileName;
-}
-
-bool WavPlayer::isDataChunk(unsigned char* buffer, int index)
-{
- unsigned char a = buffer[index];
- unsigned char b = buffer[index + 1];
- unsigned char c = buffer[index + 2];
- unsigned char d = buffer[index + 3];
- return (a == 'D' || a == 'd') && (b == 'A' || b == 'a') &&
- (c == 'T' || c == 't') && (d == 'A' || d == 'a');
-}
-
-int WavPlayer::getWord(unsigned char* buffer, int index)
-{
- unsigned char a = buffer[index];
- unsigned char b = buffer[index + 1];
- unsigned char c = buffer[index + 2];
- unsigned char d = buffer[index + 3];
- int result = 0;
- result |= a;
- result |= b << 8;
- result |= c << 16;
- result |= d << 24;
- return result;
-}
-
-short WavPlayer::getHalf(unsigned char* buffer, int index)
-{
- unsigned char a = buffer[index];
- unsigned char b = buffer[index + 1];
- short result = 0;
- result |= a;
- result |= b << 8;
- return result;
-}
-
-void *WavPlayer::LoadPCM(const char *filename, unsigned long *len)
-{
- FILE *file;
- struct stat s;
- void *pcm;
-
- if(stat(filename, &s))
- {
- return NULL;
- }
- *len = s.st_size;
- pcm = (void *) malloc(s.st_size);
- if(!pcm)
- {
- return NULL;
- }
- file = fopen(filename, "rb");
- if(!file)
- {
- free(pcm);
- return NULL;
- }
- fread(pcm, s.st_size, 1, file);
- fclose(file);
- return pcm;
-}
-
-int WavPlayer::PlayBuffer(void *pcmbuffer, unsigned long len)
-{
- AQCallbackStruct aqc;
- UInt32 err, bufferSize;
- int i;
-
- aqc.DataFormat.mSampleRate = SampleRate;
- aqc.DataFormat.mFormatID = kAudioFormatLinearPCM;
- if(BitsPerSample == 16)
- {
- aqc.DataFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger
- | kAudioFormatFlagIsPacked;
- }
- aqc.DataFormat.mBytesPerPacket = NumChannels * (BitsPerSample / 8);
- aqc.DataFormat.mFramesPerPacket = 1;
- aqc.DataFormat.mBytesPerFrame = NumChannels * (BitsPerSample / 8);
- aqc.DataFormat.mChannelsPerFrame = NumChannels;
- aqc.DataFormat.mBitsPerChannel = BitsPerSample;
- aqc.FrameCount = SampleRate / 60;
- aqc.SampleLen = (UInt32)(len);
- aqc.PlayPtr = 0;
- aqc.PCMBuffer = static_cast<unsigned char*>(pcmbuffer);
-
- err = AudioQueueNewOutput(&aqc.DataFormat,
- aqBufferCallback,
- &aqc,
- NULL,
- kCFRunLoopCommonModes,
- 0,
- &aqc.Queue);
- if(err)
- {
- return err;
- }
-
- aqc.FrameCount = SampleRate / 60;
- bufferSize = aqc.FrameCount * aqc.DataFormat.mBytesPerPacket;
-
- for(i = 0; i < AUDIO_BUFFERS; i++)
- {
- err = AudioQueueAllocateBuffer(aqc.Queue, bufferSize,
- &aqc.Buffers[i]);
- if(err)
- {
- return err;
- }
- aqBufferCallback(&aqc, aqc.Queue, aqc.Buffers[i]);
- }
-
- err = AudioQueueStart(aqc.Queue, NULL);
- if(err)
- {
- return err;
- }
-
- while(true)
- {
- }
- sleep(1);
- return 0;
-}
-
-void WavPlayer::aqBufferCallback(void *in, AudioQueueRef inQ, AudioQueueBufferRef outQB)
-{
- AQCallbackStruct *aqc;
- unsigned char *coreAudioBuffer;
-
- aqc = (AQCallbackStruct *) in;
- coreAudioBuffer = (unsigned char*) outQB->mAudioData;
-
- printf("Sync: %u / %u\n", aqc->PlayPtr, aqc->SampleLen);
-
- if(aqc->FrameCount > 0)
- {
- outQB->mAudioDataByteSize = aqc->DataFormat.mBytesPerFrame * aqc->FrameCount;
- for(int i = 0; i < aqc->FrameCount * aqc->DataFormat.mBytesPerFrame; i++)
- {
- if(aqc->PlayPtr > aqc->SampleLen)
- {
- aqc->PlayPtr = 0;
- i = 0;
- }
- coreAudioBuffer[i] = aqc->PCMBuffer[aqc->PlayPtr];
- aqc->PlayPtr++;
- }
- AudioQueueEnqueueBuffer(inQ, outQB, 0, NULL);
- }
-}
-
-int WavPlayer::PlayAudio()
-{
- unsigned long len;
- void *pcmbuffer;
- int ret;
-
- pcmbuffer = LoadPCM(FileName, &len);
- if(!pcmbuffer)
- {
- fprintf(stderr, "%s: %s\n", FileName, strerror(errno));
- exit(EXIT_FAILURE);
- }
-
- unsigned char* bytes = (unsigned char*)pcmbuffer;
- int index = 0;
-
- // 'RIFF'
- getWord(bytes, index);
- index += 4;
- // int Length
- getWord(bytes, index);
- index += 4;
- // 'WAVE'
- getWord(bytes, index);
- index += 4;
- // 'fmt '
- getWord(bytes, index);
- index += 4;
-
- // int Format Length
- int fmtLen = getWord(bytes, index);
- index += 4;
- AudioFormat = getHalf(bytes, index);
- index += 2;
- NumChannels = getHalf(bytes, index);
- index += 2;
- SampleRate = getWord(bytes, index);
- index += 4;
- ByteRate = getWord(bytes, index);
- index += 4;
- BlockAlign = getHalf(bytes, index);
- index += 2;
- BitsPerSample = getHalf(bytes, index);
- index += 2;
- index += fmtLen - 16;
- while(!isDataChunk(bytes, index))
- {
- // Any Chunk
- getWord(bytes, index);
- index += 4;
- // Any Chunk Length
- int anyChunkLen = getWord(bytes, index);
- index += 4 + anyChunkLen;
- }
- // 'data'
- getWord(bytes, index);
- index += 4;
- // int Data Length
- unsigned long dataLen = getWord(bytes, index);
- index += 4;
- unsigned char* target = &bytes[index];
-
- ret = PlayBuffer((void *)target, dataLen);
- free(pcmbuffer);
- return ret;
-}
-
-}}}
diff --git a/Samples/CommonSrc/Platform/OSX_WavPlayer.h b/Samples/CommonSrc/Platform/OSX_WavPlayer.h
deleted file mode 100644
index 4aaba10..0000000
--- a/Samples/CommonSrc/Platform/OSX_WavPlayer.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/************************************************************************************
-
-Filename : WavPlayer_OSX.h
-Content : An Apple OSX audio handler.
-Created : March 5, 2013
-Authors : Robotic Arm Software - Peter Hoff, Dan Goodman, Bryan Croteau
-
-Copyright : Copyright 2013 Oculus VR, Inc. All Rights reserved.
-
-Use of this software is subject to the terms of the Oculus LLC license
-agreement provided at the time of installation or download, or which
-otherwise accompanies this software in either electronic or hard copy form.
-
-************************************************************************************/
-
-#ifndef OVR_WavPlayer_h
-#define OVR_WavPlayer_h
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <AudioToolbox/AudioQueue.h>
-
-#define AUDIO_BUFFERS 4
-
-namespace OVR { namespace Platform { namespace OSX {
-
-typedef struct AQCallbackStruct
-{
- AudioQueueRef Queue;
- UInt32 FrameCount;
- AudioQueueBufferRef Buffers[AUDIO_BUFFERS];
- AudioStreamBasicDescription DataFormat;
- UInt32 PlayPtr;
- UInt32 SampleLen;
- unsigned char* PCMBuffer;
-} AQCallbackStruct;
-
-class WavPlayer
-{
-public:
- WavPlayer(const char* fileName);
- int PlayAudio();
-private:
- bool isDataChunk(unsigned char* buffer, int index);
- int getWord(unsigned char* buffer, int index);
- short getHalf(unsigned char* buffer, int index);
- void *LoadPCM(const char *filename, unsigned long *len);
- int PlayBuffer(void *pcm, unsigned long len);
- static void aqBufferCallback(void *in, AudioQueueRef inQ, AudioQueueBufferRef outQB);
-
- short AudioFormat;
- short NumChannels;
- int SampleRate;
- int ByteRate;
- short BlockAlign;
- short BitsPerSample;
- const char* FileName;
-};
-
-}}}
-
-#endif
diff --git a/Samples/CommonSrc/Platform/Platform.cpp b/Samples/CommonSrc/Platform/Platform.cpp
index c0e4438..108c7f5 100644
--- a/Samples/CommonSrc/Platform/Platform.cpp
+++ b/Samples/CommonSrc/Platform/Platform.cpp
@@ -52,12 +52,12 @@ PlatformCore::PlatformCore(Application *app)
{
pApp = app;
pApp->SetPlatformCore(this);
- StartupTicks = OVR::Timer::GetTicks();
+ StartupSeconds = OVR::Timer::GetSeconds();
}
double PlatformCore::GetAppTime() const
{
- return (OVR::Timer::GetTicks() - StartupTicks) * (1.0 / (double)OVR::Timer::MksPerSecond);
+ return OVR::Timer::GetSeconds() - StartupSeconds;
}
bool PlatformCore::SetFullscreen(const Render::RendererParams&, int fullscreen)
diff --git a/Samples/CommonSrc/Platform/Platform.h b/Samples/CommonSrc/Platform/Platform.h
index 201aad6..47d8f67 100644
--- a/Samples/CommonSrc/Platform/Platform.h
+++ b/Samples/CommonSrc/Platform/Platform.h
@@ -111,7 +111,7 @@ protected:
Application* pApp;
Ptr<RenderDevice> pRender;
Ptr<GamepadManager> pGamepadManager;
- UInt64 StartupTicks;
+ double StartupSeconds;
public:
PlatformCore(Application *app);
diff --git a/Samples/CommonSrc/Platform/Platform_Default.h b/Samples/CommonSrc/Platform/Platform_Default.h
index e4fecf2..420b088 100644
--- a/Samples/CommonSrc/Platform/Platform_Default.h
+++ b/Samples/CommonSrc/Platform/Platform_Default.h
@@ -29,17 +29,18 @@ limitations under the License.
#if defined(OVR_OS_WIN32)
#include "Win32_Platform.h"
-
+
#include "../Render/Render_D3D11_Device.h"
#undef OVR_D3D_VERSION
#include "../Render/Render_D3D10_Device.h"
-// #include "../Render/Render_GL_Win32_Device.h"
+ #include "../Render/Render_GL_Win32_Device.h"
// Modify this list or pass a smaller set to select a specific render device,
// while avoiding linking extra classes.
- #define OVR_DEFAULT_RENDER_DEVICE_SET \
- SetupGraphicsDeviceSet("D3D11", &OVR::Render::D3D11::RenderDevice::CreateDevice, \
- SetupGraphicsDeviceSet("D3D10", &OVR::Render::D3D10::RenderDevice::CreateDevice) )
+ #define OVR_DEFAULT_RENDER_DEVICE_SET \
+ SetupGraphicsDeviceSet("D3D11", &OVR::Render::D3D11::RenderDevice::CreateDevice, \
+ SetupGraphicsDeviceSet("D3D10", &OVR::Render::D3D10::RenderDevice::CreateDevice, \
+ SetupGraphicsDeviceSet("GL", &OVR::Render::GL::Win32::RenderDevice::CreateDevice)))
#elif defined(OVR_OS_MAC) && !defined(OVR_MAC_X11)
#include "OSX_Platform.h"
diff --git a/Samples/CommonSrc/Platform/Win32_Gamepad.cpp b/Samples/CommonSrc/Platform/Win32_Gamepad.cpp
index 9b8793f..ce7af63 100644
--- a/Samples/CommonSrc/Platform/Win32_Gamepad.cpp
+++ b/Samples/CommonSrc/Platform/Win32_Gamepad.cpp
@@ -5,7 +5,7 @@ Content : Win32 implementation of Platform app infrastructure
Created : May 6, 2013
Authors : Lee Cooper
-Copyright : Copyright 2013 Oculus VR, Inc. All Rights reserved.
+Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/Samples/CommonSrc/Platform/Win32_Gamepad.h b/Samples/CommonSrc/Platform/Win32_Gamepad.h
index 09815ae..e3f81af 100644
--- a/Samples/CommonSrc/Platform/Win32_Gamepad.h
+++ b/Samples/CommonSrc/Platform/Win32_Gamepad.h
@@ -5,7 +5,7 @@ Content : Win32 implementation of Gamepad functionality.
Created : May 6, 2013
Authors : Lee Cooper
-Copyright : Copyright 2013 Oculus VR, Inc. All Rights reserved.
+Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/Samples/CommonSrc/Platform/Win32_Platform.cpp b/Samples/CommonSrc/Platform/Win32_Platform.cpp
index eeab429..0614a3f 100644
--- a/Samples/CommonSrc/Platform/Win32_Platform.cpp
+++ b/Samples/CommonSrc/Platform/Win32_Platform.cpp
@@ -21,6 +21,8 @@ limitations under the License.
************************************************************************************/
+#include <Windows.h>
+
#include "Kernel/OVR_System.h"
#include "Kernel/OVR_Array.h"
#include "Kernel/OVR_String.h"
@@ -177,7 +179,7 @@ static UByte KeyMap[][2] =
{ VK_OEM_MINUS, Key_Minus },
{ VK_OEM_PERIOD,Key_Period },
{ VK_OEM_2, Key_Slash },
- { VK_OEM_3, Key_Bar },
+ { VK_OEM_3, Key_Backtick },
{ VK_OEM_4, Key_BracketLeft },
{ VK_OEM_5, Key_Backslash },
{ VK_OEM_6, Key_BracketRight },
@@ -418,9 +420,9 @@ int PlatformCore::Run()
if (IsIconic(hWnd))
{
Sleep(10);
+ }
}
}
- }
return ExitCode;
}
@@ -545,6 +547,7 @@ Render::DisplayId PlatformCore::GetDisplay(int screen)
OVR::Platform::Application* g_app;
+
int WINAPI WinMain(HINSTANCE hinst, HINSTANCE prevInst, LPSTR inArgs, int show)
{
using namespace OVR;
diff --git a/Samples/CommonSrc/Platform/Win32_Platform.h b/Samples/CommonSrc/Platform/Win32_Platform.h
index 6081968..23f0b70 100644
--- a/Samples/CommonSrc/Platform/Win32_Platform.h
+++ b/Samples/CommonSrc/Platform/Win32_Platform.h
@@ -98,4 +98,14 @@ KeyCode MapVKToKeyCode(unsigned vk);
// OVR_PLATFORM_APP_ARGS specifies the Application startup class with no args.
#define OVR_PLATFORM_APP(AppClass) OVR_PLATFORM_APP_ARGS(AppClass, ())
+#define OVR_PLATFORM_APP_ARGS_WITH_LOG(AppClass, LogClass, args) \
+ OVR::Platform::Application* OVR::Platform::Application::CreateApplication() \
+ { static LogClass log; OVR::System::Init(&log); \
+ return new AppClass args; } \
+ void OVR::Platform::Application::DestroyApplication(OVR::Platform::Application* app) \
+ { OVR::Platform::PlatformCore* platform = app->pPlatform; \
+ delete app; delete platform; OVR::System::Destroy(); };
+
+#define OVR_PLATFORM_APP_WITH_LOG(AppClass,LogClass) OVR_PLATFORM_APP_ARGS_WITH_LOG(AppClass,LogClass, ())
+
#endif // OVR_Win32_Platform_h
diff --git a/Samples/CommonSrc/Render/Render_D3D1X_Device.cpp b/Samples/CommonSrc/Render/Render_D3D1X_Device.cpp
index 6408e08..d7c606f 100644
--- a/Samples/CommonSrc/Render/Render_D3D1X_Device.cpp
+++ b/Samples/CommonSrc/Render/Render_D3D1X_Device.cpp
@@ -21,13 +21,20 @@ limitations under the License.
************************************************************************************/
+#define GPU_PROFILING 0
+
#include "Kernel/OVR_Log.h"
#include "Kernel/OVR_Std.h"
#include "Render_D3D1X_Device.h"
+#include "Util/Util_ImageWindow.h"
+
+#include "OVR_CAPI_D3D.h"
#include <d3dcompiler.h>
+#include <d3d9.h> // for GPU markers
+
#if (OVR_D3D_VERSION == 10)
namespace OVR { namespace Render { namespace D3D10 {
#else
@@ -43,7 +50,6 @@ static D3D1x_(INPUT_ELEMENT_DESC) ModelVertexDesc[] =
{"Normal", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, offsetof(Vertex, Norm), D3D1x_(INPUT_PER_VERTEX_DATA), 0},
};
-
static const char* StdVertexShaderSrc =
"float4x4 Proj;\n"
"float4x4 View;\n"
@@ -135,13 +141,18 @@ static const char* MultiTexturePixelShaderSrc =
"{\n"
"float4 color1;\n"
"float4 color2;\n"
- " color1 = Texture[0].Sample(Linear, ov.TexCoord);\n"
+ " color1 = Texture[0].Sample(Linear, ov.TexCoord);\n"
+ // go to linear space colors (assume gamma 2.0 for speed)
+ " color1.rgb *= color1.rgb;\n"
" color2 = Texture[1].Sample(Linear, ov.TexCoord1);\n"
+ // go to linear space colors (assume gamma 2.0 for speed)
+ " color2.rgb *= color2.rgb;\n"
" color2.rgb = color2.rgb * lerp(1.2, 1.9, saturate(length(color2.rgb)));\n"
" color2 = color1 * color2;\n"
" if (color2.a <= 0.4)\n"
" discard;\n"
- " return color2;\n"
+ // go to back to gamma space space colors (assume gamma 2.0 for speed)
+ " return float4(sqrt(color2.rgb), color2.a);\n"
"}\n";
#define LIGHTING_COMMON \
@@ -201,7 +212,9 @@ static const char* AlphaTexturePixelShaderSrc =
"};\n"
"float4 main(in Varyings ov) : SV_Target\n"
"{\n"
- " return ov.Color * float4(1,1,1,Texture.Sample(Linear, ov.TexCoord).r);\n"
+ " float4 finalColor = ov.Color;\n"
+ " finalColor.a *= Texture.Sample(Linear, ov.TexCoord).r;\n"
+ " return finalColor;\n"
"}\n";
@@ -211,97 +224,294 @@ static const char* PostProcessVertexShaderSrc =
"float4x4 View : register(c4);\n"
"float4x4 Texm : register(c8);\n"
"void main(in float4 Position : POSITION, in float4 Color : COLOR0, in float2 TexCoord : TEXCOORD0, in float2 TexCoord1 : TEXCOORD1,\n"
- " out float4 oPosition : SV_Position, out float4 oColor : COLOR, out float2 oTexCoord : TEXCOORD0)\n"
+ " out float4 oPosition : SV_Position, out float2 oTexCoord : TEXCOORD0)\n"
"{\n"
" oPosition = mul(View, Position);\n"
" oTexCoord = mul(Texm, float4(TexCoord,0,1));\n"
- " oColor = Color;\n"
"}\n";
-// Shader with just lens distortion correction.
-static const char* PostProcessPixelShaderSrc =
+
+// Shader with lens distortion and chromatic aberration correction.
+static const char* PostProcessPixelShaderWithChromAbSrc =
"Texture2D Texture : register(t0);\n"
"SamplerState Linear : register(s0);\n"
- "float2 LensCenter;\n"
- "float2 ScreenCenter;\n"
- "float2 Scale;\n"
- "float2 ScaleIn;\n"
+ "float3 DistortionClearColor;\n"
+ "float EdgeFadeScale;\n"
+ "float2 EyeToSourceUVScale;\n"
+ "float2 EyeToSourceUVOffset;\n"
+ "float2 EyeToSourceNDCScale;\n"
+ "float2 EyeToSourceNDCOffset;\n"
+ "float2 TanEyeAngleScale;\n"
+ "float2 TanEyeAngleOffset;\n"
"float4 HmdWarpParam;\n"
+ "float4 ChromAbParam;\n"
"\n"
- // Scales input texture coordinates for distortion.
- // ScaleIn maps texture coordinates to Scales to ([-1, 1]), although top/bottom will be
- // larger due to aspect ratio.
- "float2 HmdWarp(float2 in01)\n"
+ "float4 main(in float4 oPosition : SV_Position,\n"
+ " in float2 oTexCoord : TEXCOORD0) : SV_Target\n"
"{\n"
- " float2 theta = (in01 - LensCenter) * ScaleIn;\n" // Scales to [-1, 1]
- " float rSq = theta.x * theta.x + theta.y * theta.y;\n"
- " float2 theta1 = theta * (HmdWarpParam.x + HmdWarpParam.y * rSq + "
- " HmdWarpParam.z * rSq * rSq + HmdWarpParam.w * rSq * rSq * rSq);\n"
- " return LensCenter + Scale * theta1;\n"
- "}\n"
+ // Input oTexCoord is [-1,1] across the half of the screen used for a single eye.
+ " float2 TanEyeAngleDistorted = oTexCoord * TanEyeAngleScale + TanEyeAngleOffset;\n" // Scales to tan(thetaX),tan(thetaY), but still distorted (i.e. only the center is correct)
+ " float RadiusSq = TanEyeAngleDistorted.x * TanEyeAngleDistorted.x + TanEyeAngleDistorted.y * TanEyeAngleDistorted.y;\n"
+ " float Distort = rcp ( 1.0 + RadiusSq * ( HmdWarpParam.y + RadiusSq * ( HmdWarpParam.z + RadiusSq * ( HmdWarpParam.w ) ) ) );\n"
+ " float DistortR = Distort * ( ChromAbParam.x + RadiusSq * ChromAbParam.y );\n"
+ " float DistortG = Distort;\n"
+ " float DistortB = Distort * ( ChromAbParam.z + RadiusSq * ChromAbParam.w );\n"
+ " float2 TanEyeAngleR = DistortR * TanEyeAngleDistorted;\n"
+ " float2 TanEyeAngleG = DistortG * TanEyeAngleDistorted;\n"
+ " float2 TanEyeAngleB = DistortB * TanEyeAngleDistorted;\n"
+
+ // These are now in "TanEyeAngle" space.
+ // The vectors (TanEyeAngleRGB.x, TanEyeAngleRGB.y, 1.0) are real-world vectors pointing from the eye to where the components of the pixel appear to be.
+ // If you had a raytracer, you could just use them directly.
+
+ // Scale them into ([0,0.5],[0,1]) or ([0.5,0],[0,1]) UV lookup space (depending on eye)
+ " float2 SourceCoordR = TanEyeAngleR * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
+ " float2 SourceCoordG = TanEyeAngleG * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
+ " float2 SourceCoordB = TanEyeAngleB * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
+
+ // Find the distance to the nearest edge.
+ " float2 NDCCoord = TanEyeAngleG * EyeToSourceNDCScale + EyeToSourceNDCOffset;\n"
+ " float EdgeFadeIn = EdgeFadeScale * ( 1.0 - max ( abs ( NDCCoord.x ), abs ( NDCCoord.y ) ) );\n"
+ " if ( EdgeFadeIn < 0.0 )\n"
+ " {\n"
+ " return float4(DistortionClearColor.r, DistortionClearColor.g, DistortionClearColor.b, 1.0);\n"
+ " }\n"
+ " EdgeFadeIn = saturate ( EdgeFadeIn );\n"
+
+ // Actually do the lookups.
+ " float ResultR = Texture.Sample(Linear, SourceCoordR).r;\n"
+ " float ResultG = Texture.Sample(Linear, SourceCoordG).g;\n"
+ " float ResultB = Texture.Sample(Linear, SourceCoordB).b;\n"
+
+ " return float4(ResultR * EdgeFadeIn, ResultG * EdgeFadeIn, ResultB * EdgeFadeIn, 1.0);\n"
+ "}\n";
+
+//----------------------------------------------------------------------------
+
+// A vertex format used for mesh-based distortion.
+/*
+struct DistortionVertex
+{
+ Vector2f Pos;
+ Vector2f TexR;
+ Vector2f TexG;
+ Vector2f TexB;
+ Color Col;
+};
+*/
+static D3D1x_(INPUT_ELEMENT_DESC) DistortionVertexDesc[] =
+{
+ {"Position", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D1x_(INPUT_PER_VERTEX_DATA), 0},
+ {"TexCoord", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 8, D3D1x_(INPUT_PER_VERTEX_DATA), 0},
+ {"TexCoord", 1, DXGI_FORMAT_R32G32_FLOAT, 0, 8+8, D3D1x_(INPUT_PER_VERTEX_DATA), 0},
+ {"TexCoord", 2, DXGI_FORMAT_R32G32_FLOAT, 0, 8+8+8, D3D1x_(INPUT_PER_VERTEX_DATA), 0},
+ {"Color", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, 8+8+8+8, D3D1x_(INPUT_PER_VERTEX_DATA), 0},
+};
+
+
+//----------------------------------------------------------------------------
+// Simple distortion shader that does three texture reads.
+// Used for mesh-based distortion without timewarp.
+
+static const char* PostProcessMeshVertexShaderSrc =
+ "float2 EyeToSourceUVScale;\n"
+ "float2 EyeToSourceUVOffset;\n"
+ "void main(in float2 Position : POSITION, in float4 Color : COLOR0, in float2 TexCoord0 : TEXCOORD0, in float2 TexCoord1 : TEXCOORD1, in float2 TexCoord2 : TEXCOORD2,\n"
+ " out float4 oPosition : SV_Position, out float4 oColor : COLOR, out float2 oTexCoord0 : TEXCOORD0, out float2 oTexCoord1 : TEXCOORD1, out float2 oTexCoord2 : TEXCOORD2)\n"
+ "{\n"
+ " oPosition.x = Position.x;\n"
+ " oPosition.y = Position.y;\n"
+ " oPosition.z = 0.5;\n"
+ " oPosition.w = 1.0;\n"
+ // Vertex inputs are in TanEyeAngle space for the R,G,B channels (i.e. after chromatic aberration and distortion).
+ // Scale them into the correct [0-1],[0-1] UV lookup space (depending on eye)
+ " oTexCoord0 = TexCoord0 * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
+ " oTexCoord1 = TexCoord1 * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
+ " oTexCoord2 = TexCoord2 * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
+ " oColor = Color;\n" // Used for vignette fade.
+ "}\n";
+
+static const char* PostProcessMeshPixelShaderSrc =
+ "Texture2D Texture : register(t0);\n"
+ "SamplerState Linear : register(s0);\n"
+ "\n"
"float4 main(in float4 oPosition : SV_Position, in float4 oColor : COLOR,\n"
- " in float2 oTexCoord : TEXCOORD0) : SV_Target\n"
+ " in float2 oTexCoord0 : TEXCOORD0, in float2 oTexCoord1 : TEXCOORD1, in float2 oTexCoord2 : TEXCOORD2) : SV_Target\n"
"{\n"
- " float2 tc = HmdWarp(oTexCoord);\n"
- " if (any(clamp(tc, ScreenCenter-float2(0.25,0.5), ScreenCenter+float2(0.25, 0.5)) - tc))\n"
- " return 0;\n"
- " return Texture.Sample(Linear, tc);\n"
+ " float ResultR = Texture.Sample(Linear, oTexCoord0).r;\n"
+ " float ResultG = Texture.Sample(Linear, oTexCoord1).g;\n"
+ " float ResultB = Texture.Sample(Linear, oTexCoord2).b;\n"
+ " return float4(ResultR * oColor.r, ResultG * oColor.g, ResultB * oColor.b, 1.0);\n"
"}\n";
-// Shader with lens distortion and chromatic aberration correction.
-static const char* PostProcessPixelShaderWithChromAbSrc =
+
+//----------------------------------------------------------------------------
+// Pixel shader is very simple - does three texture reads.
+// Vertex shader does all the hard work.
+// Used for mesh-based distortion with timewarp.
+
+static const char* PostProcessMeshTimewarpVertexShaderSrc =
+ "float2 EyeToSourceUVScale;\n"
+ "float2 EyeToSourceUVOffset;\n"
+ "float3x3 EyeRotationStart;\n"
+ "float3x3 EyeRotationEnd;\n"
+ "void main(in float2 Position : POSITION, in float4 Color : COLOR0, in float2 TexCoord0 : TEXCOORD0, in float2 TexCoord1 : TEXCOORD1, in float2 TexCoord2 : TEXCOORD2,\n"
+ " out float4 oPosition : SV_Position, out float4 oColor : COLOR, out float2 oTexCoord0 : TEXCOORD0, out float2 oTexCoord1 : TEXCOORD1, out float2 oTexCoord2 : TEXCOORD2)\n"
+ "{\n"
+ " oPosition.x = Position.x;\n"
+ " oPosition.y = Position.y;\n"
+ " oPosition.z = 0.5;\n"
+ " oPosition.w = 1.0;\n"
+
+ // Vertex inputs are in TanEyeAngle space for the R,G,B channels (i.e. after chromatic aberration and distortion).
+ // These are now "real world" vectors in direction (x,y,1) relative to the eye of the HMD.
+ " float3 TanEyeAngleR = float3 ( TexCoord0.x, TexCoord0.y, 1.0 );\n"
+ " float3 TanEyeAngleG = float3 ( TexCoord1.x, TexCoord1.y, 1.0 );\n"
+ " float3 TanEyeAngleB = float3 ( TexCoord2.x, TexCoord2.y, 1.0 );\n"
+
+ // Accurate time warp lerp vs. faster
+#if 1
+ // Apply the two 3x3 timewarp rotations to these vectors.
+ " float3 TransformedRStart = mul ( TanEyeAngleR, EyeRotationStart );\n"
+ " float3 TransformedGStart = mul ( TanEyeAngleG, EyeRotationStart );\n"
+ " float3 TransformedBStart = mul ( TanEyeAngleB, EyeRotationStart );\n"
+ " float3 TransformedREnd = mul ( TanEyeAngleR, EyeRotationEnd );\n"
+ " float3 TransformedGEnd = mul ( TanEyeAngleG, EyeRotationEnd );\n"
+ " float3 TransformedBEnd = mul ( TanEyeAngleB, EyeRotationEnd );\n"
+ // And blend between them.
+ " float3 TransformedR = lerp ( TransformedRStart, TransformedREnd, Color.a );\n"
+ " float3 TransformedG = lerp ( TransformedGStart, TransformedGEnd, Color.a );\n"
+ " float3 TransformedB = lerp ( TransformedBStart, TransformedBEnd, Color.a );\n"
+#else
+ " float3x3 EyeRotation = lerp ( EyeRotationStart, EyeRotationEnd, Color.a );\n"
+ " float3 TransformedR = mul ( TanEyeAngleR, EyeRotation );\n"
+ " float3 TransformedG = mul ( TanEyeAngleG, EyeRotation );\n"
+ " float3 TransformedB = mul ( TanEyeAngleB, EyeRotation );\n"
+#endif
+
+ // Project them back onto the Z=1 plane of the rendered images.
+ " float RecipZR = rcp ( TransformedR.z );\n"
+ " float RecipZG = rcp ( TransformedG.z );\n"
+ " float RecipZB = rcp ( TransformedB.z );\n"
+ " float2 FlattenedR = float2 ( TransformedR.x * RecipZR, TransformedR.y * RecipZR );\n"
+ " float2 FlattenedG = float2 ( TransformedG.x * RecipZG, TransformedG.y * RecipZG );\n"
+ " float2 FlattenedB = float2 ( TransformedB.x * RecipZB, TransformedB.y * RecipZB );\n"
+
+ // These are now still in TanEyeAngle space.
+ // Scale them into the correct [0-1],[0-1] UV lookup space (depending on eye)
+ " float2 SrcCoordR = FlattenedR * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
+ " float2 SrcCoordG = FlattenedG * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
+ " float2 SrcCoordB = FlattenedB * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
+ " oTexCoord0 = SrcCoordR;\n"
+ " oTexCoord1 = SrcCoordG;\n"
+ " oTexCoord2 = SrcCoordB;\n"
+ " oColor = Color.r;\n" // Used for vignette fade.
+ "}\n";
+
+static const char* PostProcessMeshTimewarpPixelShaderSrc =
"Texture2D Texture : register(t0);\n"
"SamplerState Linear : register(s0);\n"
- "float2 LensCenter;\n"
- "float2 ScreenCenter;\n"
- "float2 Scale;\n"
- "float2 ScaleIn;\n"
- "float4 HmdWarpParam;\n"
- "float4 ChromAbParam;\n"
"\n"
+ "float4 main(in float4 oPosition : SV_Position, in float4 oColor : COLOR,\n"
+ " in float2 oTexCoord0 : TEXCOORD0, in float2 oTexCoord1 : TEXCOORD1, in float2 oTexCoord2 : TEXCOORD2) : SV_Target\n"
+ "{\n"
+ " float ResultR = Texture.Sample(Linear, oTexCoord0).r;\n"
+ " float ResultG = Texture.Sample(Linear, oTexCoord1).g;\n"
+ " float ResultB = Texture.Sample(Linear, oTexCoord2).b;\n"
+ " return float4(ResultR * oColor.r, ResultG * oColor.g, ResultB * oColor.b, 1.0);\n"
+ "}\n";
- // Scales input texture coordinates for distortion.
- // ScaleIn maps texture coordinates to Scales to ([-1, 1]), although top/bottom will be
- // larger due to aspect ratio.
+//----------------------------------------------------------------------------
+// Pixel shader is very simple - does three texture reads.
+// Vertex shader does all the hard work.
+// Used for mesh-based distortion with positional timewarp.
+
+static const char* PostProcessMeshPositionalTimewarpVertexShaderSrc =
+ "Texture2DMS<float,4> DepthTexture : register(t0);\n"
+ // Padding because we are uploading "standard uniform buffer" constants
+ "float4x4 Padding1;\n"
+ "float4x4 Padding2;\n"
+ "float2 EyeToSourceUVScale;\n"
+ "float2 EyeToSourceUVOffset;\n"
+ "float2 DepthProjector;\n"
+ "float2 DepthDimSize;\n"
+ "float4x4 EyeRotationStart;\n"
+ "float4x4 EyeRotationEnd;\n"
+
+ "float4 PositionFromDepth(float2 inTexCoord)\n"
+ "{\n"
+ " float2 eyeToSourceTexCoord = inTexCoord * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
+ " float depth = DepthTexture.Load(int2(eyeToSourceTexCoord * DepthDimSize), 0).x;\n"
+ " float linearDepth = DepthProjector.y / (depth - DepthProjector.x);\n"
+ " float4 retVal = float4(inTexCoord, 1, 1);\n"
+ " retVal.xyz *= linearDepth;\n"
+ " return retVal;\n"
+ "}\n"
+
+ "float2 TimewarpTexCoordToWarpedPos(float2 inTexCoord, float4x4 rotMat)\n"
+ "{\n"
+ // Vertex inputs are in TanEyeAngle space for the R,G,B channels (i.e. after chromatic aberration and distortion).
+ // These are now "real world" vectors in direction (x,y,1) relative to the eye of the HMD.
+ // Apply the 4x4 timewarp rotation to these vectors.
+ " float4 inputPos = PositionFromDepth(inTexCoord);\n"
+ " float3 transformed = float3( mul ( rotMat, inputPos ).xyz);\n"
+ // Project them back onto the Z=1 plane of the rendered images.
+ " float2 flattened = transformed.xy / transformed.z;\n"
+ // Scale them into ([0,0.5],[0,1]) or ([0.5,0],[0,1]) UV lookup space (depending on eye)
+ " float2 noDepthUV = flattened * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
+ //" float depth = DepthTexture.SampleLevel(Linear, noDepthUV, 0).r;\n"
+ " return noDepthUV.xy;\n"
+ "}\n"
+
+ "void main( in float2 Position : POSITION, in float4 Color : COLOR0, in float2 TexCoord0 : TEXCOORD0,\n"
+ " in float2 TexCoord1 : TEXCOORD1, in float2 TexCoord2 : TEXCOORD2,\n"
+ " out float4 oPosition : SV_Position, out float4 oColor : COLOR,\n"
+ " out float2 oTexCoord0 : TEXCOORD0, out float2 oTexCoord1 : TEXCOORD1, out float2 oTexCoord2 : TEXCOORD2)\n"
+ "{\n"
+ " oPosition.x = Position.x;\n"
+ " oPosition.y = Position.y;\n"
+ " oPosition.z = 0.5;\n"
+ " oPosition.w = 1.0;\n"
+
+ " float timewarpLerpFactor = Color.a;\n"
+ " float4x4 lerpedEyeRot = lerp(EyeRotationStart, EyeRotationEnd, timewarpLerpFactor);\n"
+ //" float4x4 lerpedEyeRot = EyeRotationStart;\n"
+
+ // warped positions are a bit more involved, hence a separate function
+ " oTexCoord0 = TimewarpTexCoordToWarpedPos(TexCoord0, lerpedEyeRot);\n"
+ " oTexCoord1 = TimewarpTexCoordToWarpedPos(TexCoord1, lerpedEyeRot);\n"
+ " oTexCoord2 = TimewarpTexCoordToWarpedPos(TexCoord2, lerpedEyeRot);\n"
+
+ " oColor = Color.r; // Used for vignette fade.\n"
+ "}\n";
+
+static const char* PostProcessMeshPositionalTimewarpPixelShaderSrc =
+ "Texture2D Texture : register(t0);\n"
+ "SamplerState Linear : register(s0);\n"
+ "float2 DepthDimSize;\n"
+ "\n"
"float4 main(in float4 oPosition : SV_Position, in float4 oColor : COLOR,\n"
- " in float2 oTexCoord : TEXCOORD0) : SV_Target\n"
+ " in float2 oTexCoord0 : TEXCOORD0, in float2 oTexCoord1 : TEXCOORD1, in float2 oTexCoord2 : TEXCOORD2) : SV_Target\n"
"{\n"
- " float2 theta = (oTexCoord - LensCenter) * ScaleIn;\n" // Scales to [-1, 1]
- " float rSq = theta.x * theta.x + theta.y * theta.y;\n"
- " float2 theta1 = theta * (HmdWarpParam.x + HmdWarpParam.y * rSq + "
- " HmdWarpParam.z * rSq * rSq + HmdWarpParam.w * rSq * rSq * rSq);\n"
- " \n"
- " // Detect whether blue texture coordinates are out of range since these will scaled out the furthest.\n"
- " float2 thetaBlue = theta1 * (ChromAbParam.z + ChromAbParam.w * rSq);\n"
- " float2 tcBlue = LensCenter + Scale * thetaBlue;\n"
- " if (any(clamp(tcBlue, ScreenCenter-float2(0.25,0.5), ScreenCenter+float2(0.25, 0.5)) - tcBlue))\n"
- " return 0;\n"
- " \n"
- " // Now do blue texture lookup.\n"
- " float blue = Texture.Sample(Linear, tcBlue).b;\n"
- " \n"
- " // Do green lookup (no scaling).\n"
- " float2 tcGreen = LensCenter + Scale * theta1;\n"
- " float4 greenColor = Texture.Sample(Linear, tcGreen);\n"
- " float green = greenColor.g;\n"
- " float alpha = greenColor.a;\n"
- " \n"
- " // Do red scale and lookup.\n"
- " float2 thetaRed = theta1 * (ChromAbParam.x + ChromAbParam.y * rSq);\n"
- " float2 tcRed = LensCenter + Scale * thetaRed;\n"
- " float red = Texture.Sample(Linear, tcRed).r;\n"
- " \n"
- " return float4(red, green, blue, alpha);\n"
+ " float3 result;\n"
+ " result.r = Texture.Sample(Linear, oTexCoord0).r;\n"
+ " result.g = Texture.Sample(Linear, oTexCoord1).g;\n"
+ " result.b = Texture.Sample(Linear, oTexCoord2).b;\n"
+ " return float4(result * oColor, 1.0);\n"
"}\n";
+//----------------------------------------------------------------------------
static const char* VShaderSrcs[VShader_Count] =
{
DirectVertexShaderSrc,
StdVertexShaderSrc,
- PostProcessVertexShaderSrc
+ PostProcessVertexShaderSrc,
+ PostProcessMeshVertexShaderSrc,
+ PostProcessMeshTimewarpVertexShaderSrc,
+ PostProcessMeshPositionalTimewarpVertexShaderSrc
};
static const char* FShaderSrcs[FShader_Count] =
{
@@ -309,11 +519,13 @@ static const char* FShaderSrcs[FShader_Count] =
GouraudPixelShaderSrc,
TexturePixelShaderSrc,
AlphaTexturePixelShaderSrc,
- PostProcessPixelShaderSrc,
PostProcessPixelShaderWithChromAbSrc,
LitSolidPixelShaderSrc,
LitTexturePixelShaderSrc,
- MultiTexturePixelShaderSrc
+ MultiTexturePixelShaderSrc,
+ PostProcessMeshPixelShaderSrc,
+ PostProcessMeshTimewarpPixelShaderSrc,
+ PostProcessMeshPositionalTimewarpPixelShaderSrc
};
RenderDevice::RenderDevice(const RendererParams& p, HWND window)
@@ -322,8 +534,8 @@ RenderDevice::RenderDevice(const RendererParams& p, HWND window)
GetClientRect(window, &rc);
UINT width = rc.right - rc.left;
UINT height = rc.bottom - rc.top;
- WindowWidth = width;
- WindowHeight = height;
+ ::OVR::Render::RenderDevice::SetWindowSize(width, height);
+
Window = window;
Params = p;
@@ -359,17 +571,18 @@ RenderDevice::RenderDevice(const RendererParams& p, HWND window)
UpdateMonitorOutputs();
}
- int flags = 0;
+ int flags = D3D10_CREATE_DEVICE_BGRA_SUPPORT; //0;
#if (OVR_D3D_VERSION == 10)
- hr = D3D10CreateDevice(Adapter, D3D10_DRIVER_TYPE_HARDWARE, NULL, flags, D3D1x_(SDK_VERSION),
+ hr = D3D10CreateDevice1(Adapter, D3D10_DRIVER_TYPE_HARDWARE, NULL, flags, D3D10_FEATURE_LEVEL_10_1, D3D10_1_SDK_VERSION,
&Device.GetRawRef());
Context = Device;
Context->AddRef();
#else //11
+ D3D_FEATURE_LEVEL featureLevel; // TODO: Limit certain features based on D3D feature level
hr = D3D11CreateDevice(Adapter, Adapter ? D3D_DRIVER_TYPE_UNKNOWN : D3D_DRIVER_TYPE_HARDWARE,
NULL, flags, NULL, 0, D3D1x_(SDK_VERSION),
- &Device.GetRawRef(), NULL, &Context.GetRawRef());
+ &Device.GetRawRef(), &featureLevel, &Context.GetRawRef());
#endif
if (FAILED(hr))
return;
@@ -387,25 +600,43 @@ RenderDevice::RenderDevice(const RendererParams& p, HWND window)
MaxTextureSet[i] = 0;
}
- ID3D10Blob* vsData = CompileShader("vs_4_0", DirectVertexShaderSrc);
+ ID3D10Blob* vsData = CompileShader("vs_4_1", DirectVertexShaderSrc);
VertexShaders[VShader_MV] = *new VertexShader(this, vsData);
for(int i = 1; i < VShader_Count; i++)
{
- VertexShaders[i] = *new VertexShader(this, CompileShader("vs_4_0", VShaderSrcs[i]));
+ OVR_ASSERT ( VShaderSrcs[i] != NULL ); // You forgot a shader!
+ ID3D10Blob *pShader = CompileShader("vs_4_1", VShaderSrcs[i]);
+ VertexShaders[i] = NULL;
+ if ( pShader != NULL )
+ {
+ VertexShaders[i] = *new VertexShader(this, pShader);
+ }
}
for(int i = 0; i < FShader_Count; i++)
{
- PixelShaders[i] = *new PixelShader(this, CompileShader("ps_4_0", FShaderSrcs[i]));
+ OVR_ASSERT ( FShaderSrcs[i] != NULL ); // You forgot a shader!
+ ID3D10Blob *pShader = CompileShader("ps_4_1", FShaderSrcs[i]);
+ PixelShaders[i] = NULL;
+ if ( pShader != NULL )
+ {
+ PixelShaders[i] = *new PixelShader(this, pShader);
+ }
}
SPInt bufferSize = vsData->GetBufferSize();
const void* buffer = vsData->GetBufferPointer();
ID3D1xInputLayout** objRef = &ModelVertexIL.GetRawRef();
-
- HRESULT validate = Device->CreateInputLayout(ModelVertexDesc, 5, buffer, bufferSize, objRef);
+ HRESULT validate = Device->CreateInputLayout(ModelVertexDesc, sizeof(ModelVertexDesc)/sizeof(ModelVertexDesc[0]), buffer, bufferSize, objRef);
OVR_UNUSED(validate);
+ ID3D10Blob* vsData2 = CompileShader("vs_4_1", PostProcessMeshVertexShaderSrc);
+ SPInt bufferSize2 = vsData2->GetBufferSize();
+ const void* buffer2 = vsData2->GetBufferPointer();
+ ID3D1xInputLayout** objRef2 = &DistortionVertexIL.GetRawRef();
+ HRESULT validate2 = Device->CreateInputLayout(DistortionVertexDesc, sizeof(DistortionVertexDesc)/sizeof(DistortionVertexDesc[0]), buffer2, bufferSize2, objRef2);
+ OVR_UNUSED(validate2);
+
Ptr<ShaderSet> gouraudShaders = *new ShaderSet();
gouraudShaders->SetShader(VertexShaders[VShader_MVP]);
gouraudShaders->SetShader(PixelShaders[FShader_Gouraud]);
@@ -433,7 +664,7 @@ RenderDevice::RenderDevice(const RendererParams& p, HWND window)
D3D1x_(RASTERIZER_DESC) rs;
memset(&rs, 0, sizeof(rs));
- rs.AntialiasedLineEnable = true;
+ rs.AntialiasedLineEnable = false; // You can't just turn this on - it needs alpha modes etc setting up and doesn't work with Z buffers.
rs.CullMode = D3D1x_(CULL_BACK);
// rs.CullMode = D3D1x_(CULL_NONE);
rs.DepthClipEnable = true;
@@ -568,10 +799,11 @@ bool RenderDevice::RecreateSwapChain()
DXGI_SWAP_CHAIN_DESC scDesc;
memset(&scDesc, 0, sizeof(scDesc));
scDesc.BufferCount = 1;
- scDesc.BufferDesc.Width = WindowWidth;
+ scDesc.BufferDesc.Width = WindowWidth;
scDesc.BufferDesc.Height = WindowHeight;
scDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
- scDesc.BufferDesc.RefreshRate.Numerator = 60;
+ // Use default refresh rate; switching rate on CC prototype can cause screen lockup.
+ scDesc.BufferDesc.RefreshRate.Numerator = 0;
scDesc.BufferDesc.RefreshRate.Denominator = 1;
scDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
scDesc.OutputWindow = Window;
@@ -621,18 +853,60 @@ bool RenderDevice::SetParams(const RendererParams& newParams)
UpdateMonitorOutputs(true);
}
- // Cause this to be recreated with the new multisample mode.
- pSceneColorTex = NULL;
return RecreateSwapChain();
}
+
+ovrRenderAPIConfig RenderDevice::Get_ovrRenderAPIConfig() const
+{
+#if (OVR_D3D_VERSION == 10)
+ static ovrD3D10Config cfg;
+ cfg.D3D10.Header.API = ovrRenderAPI_D3D10;
+ cfg.D3D10.Header.RTSize = Sizei(WindowWidth, WindowHeight);
+ cfg.D3D10.Header.Multisample = Params.Multisample;
+ cfg.D3D10.pDevice = Device;
+ cfg.D3D10.pBackBufferRT = BackBufferRT;
+ cfg.D3D10.pSwapChain = SwapChain;
+#else
+ static ovrD3D11Config cfg;
+ cfg.D3D11.Header.API = ovrRenderAPI_D3D11;
+ cfg.D3D11.Header.RTSize = Sizei(WindowWidth, WindowHeight);
+ cfg.D3D11.Header.Multisample = Params.Multisample;
+ cfg.D3D11.pDevice = Device;
+ cfg.D3D11.pDeviceContext = Context;
+ cfg.D3D11.pBackBufferRT = BackBufferRT;
+ cfg.D3D11.pSwapChain = SwapChain;
+#endif
+ return cfg.Config;
+}
+
+ovrTexture Texture::Get_ovrTexture()
+{
+ ovrTexture tex;
+
+ OVR::Sizei newRTSize(Width, Height);
+
+#if (OVR_D3D_VERSION == 10)
+ ovrD3D10TextureData* texData = (ovrD3D10TextureData*)&tex;
+ texData->Header.API = ovrRenderAPI_D3D10;
+#else
+ ovrD3D11TextureData* texData = (ovrD3D11TextureData*)&tex;
+ texData->Header.API = ovrRenderAPI_D3D11;
+#endif
+ texData->Header.TextureSize = newRTSize;
+ texData->Header.RenderViewport = Recti(newRTSize);
+ texData->pTexture = Tex;
+ texData->pSRView = TexSv;
+
+ return tex;
+}
void RenderDevice::SetWindowSize(int w, int h)
{
if (w == WindowWidth && h == WindowHeight)
return;
- WindowWidth = w;
- WindowHeight = h;
+ ::OVR::Render::RenderDevice::SetWindowSize(w, h);
+
Context->OMSetRenderTargets(0, NULL, NULL);
BackBuffer = NULL;
BackBufferRT = NULL;
@@ -698,32 +972,24 @@ bool RenderDevice::SetFullscreen(DisplayMode fullscreen)
return true;
}
-void RenderDevice::SetMultipleViewports(int n, const Viewport* vps)
+void RenderDevice::SetViewport(const Recti& vp)
{
- if (n > 2)
- {
- n = 2;
- }
- for(int i = 0; i < n; i++)
- {
#if (OVR_D3D_VERSION == 10)
- Viewports[i].Width = vps[i].w;
- Viewports[i].Height = vps[i].h;
- Viewports[i].MinDepth = 0;
- Viewports[i].MaxDepth = 1;
- Viewports[i].TopLeftX = vps[i].x;
- Viewports[i].TopLeftY = vps[i].y;
+ D3DViewport.Width = vp.w;
+ D3DViewport.Height = vp.h;
+ D3DViewport.MinDepth = 0;
+ D3DViewport.MaxDepth = 1;
+ D3DViewport.TopLeftX = vp.x;
+ D3DViewport.TopLeftY = vp.y;
#else
- Viewports[i].Width = (float)vps[i].w;
- Viewports[i].Height = (float)vps[i].h;
- Viewports[i].MinDepth = 0;
- Viewports[i].MaxDepth = 1;
- Viewports[i].TopLeftX = (float)vps[i].x;
- Viewports[i].TopLeftY = (float)vps[i].y;
+ D3DViewport.Width = (float)vp.w;
+ D3DViewport.Height = (float)vp.h;
+ D3DViewport.MinDepth = 0;
+ D3DViewport.MaxDepth = 1;
+ D3DViewport.TopLeftX = (float)vp.x;
+ D3DViewport.TopLeftY = (float)vp.y;
#endif
- }
- NumViewports = n;
- Context->RSSetViewports(n, Viewports);
+ Context->RSSetViewports(1,&D3DViewport);
}
static int GetDepthStateIndex(bool enable, bool write, RenderDevice::CompareFunc func)
@@ -754,7 +1020,7 @@ void RenderDevice::SetDepthMode(bool enable, bool write, CompareFunc func)
case Compare_Less: dss.DepthFunc = D3D1x_(COMPARISON_LESS); break;
case Compare_Greater: dss.DepthFunc = D3D1x_(COMPARISON_GREATER); break;
default:
- assert(0);
+ OVR_ASSERT(0);
}
dss.DepthWriteMask = write ? D3D1x_(DEPTH_WRITE_MASK_ALL) : D3D1x_(DEPTH_WRITE_MASK_ZERO);
Device->CreateDepthStencilState(&dss, &DepthStates[index].GetRawRef());
@@ -782,70 +1048,27 @@ Texture* RenderDevice::GetDepthBuffer(int w, int h, int ms)
return newDepth.GetPtr();
}
-void RenderDevice::Clear(float r, float g, float b, float a, float depth)
+void RenderDevice::Clear(float r /*= 0*/, float g /*= 0*/, float b /*= 0*/, float a /*= 1*/,
+ float depth /*= 1*/,
+ bool clearColor /*= true*/, bool clearDepth /*= true*/)
{
- const float color[] = {r, g, b, a};
-
- // save state that is affected by clearing this way
- ID3D1xDepthStencilState* oldDepthState = CurDepthState;
- StandardUniformData clearUniforms;
-
- SetDepthMode(true, true, Compare_Always);
-
- Context->IASetInputLayout(ModelVertexIL);
-#if (OVR_D3D_VERSION == 10)
- Context->GSSetShader(NULL);
-#else
- Context->GSSetShader(NULL, NULL, 0);
-#endif
- //Shader<Shader_Geometry,ID3D1xGeometryShader> NullGS(this,(ID3D1xGeometryShader*)NULL);
- //NullGS.Set(Prim_TriangleStrip);
-
- ID3D1xShaderResourceView* sv[8] = {0, 0, 0, 0, 0, 0, 0, 0};
- if (MaxTextureSet[Shader_Fragment])
- {
- Context->PSSetShaderResources(0, MaxTextureSet[Shader_Fragment], sv);
- }
-
- ID3D1xBuffer* vertexBuffer = QuadVertexBuffer->GetBuffer();
- UINT vertexStride = sizeof(Vertex);
- UINT vertexOffset = 0;
- Context->IASetVertexBuffers(0, 1, &vertexBuffer, &vertexStride, &vertexOffset);
-
- clearUniforms.View = Matrix4f(2, 0, 0, 0,
- 0, 2, 0, 0,
- 0, 0, 0, 0,
- -1, -1, depth, 1);
- UniformBuffers[Shader_Vertex]->Data(Buffer_Uniform, &clearUniforms, sizeof(clearUniforms));
-
- ID3D1xBuffer* vertexConstants = UniformBuffers[Shader_Vertex]->GetBuffer();
- Context->VSSetConstantBuffers(0, 1, &vertexConstants);
- Context->IASetPrimitiveTopology(D3D1x_(PRIMITIVE_TOPOLOGY_TRIANGLESTRIP));
- VertexShaders[VShader_MV]->Set(Prim_TriangleStrip);
- PixelShaders[FShader_Solid]->Set(Prim_TriangleStrip);
-
- UniformBuffers[Shader_Pixel]->Data(Buffer_Uniform, color, sizeof(color));
- PixelShaders[FShader_Solid]->SetUniformBuffer(UniformBuffers[Shader_Pixel]);
-
- if (NumViewports > 1)
+ if ( clearColor )
{
- for(int i = 0; i < NumViewports; i++)
+ const float color[] = {r, g, b, a};
+ if ( CurRenderTarget == NULL )
+ {
+ Context->ClearRenderTargetView ( BackBufferRT.GetRawRef(), color );
+ }
+ else
{
- Context->RSSetViewports(1, &Viewports[i]);
- Context->OMSetBlendState(NULL, NULL, 0xffffffff);
- Context->Draw(4, 0);
+ Context->ClearRenderTargetView ( CurRenderTarget->TexRtv, color );
}
- Context->RSSetViewports(NumViewports, Viewports);
}
- else
+
+ if ( clearDepth )
{
- Context->OMSetBlendState(NULL, NULL, 0xffffffff);
- Context->Draw(4, 0);
+ Context->ClearDepthStencilView ( CurDepthBuffer->TexDsv, D3D10_CLEAR_DEPTH | D3D10_CLEAR_STENCIL, depth, 0 );
}
-
- // reset
- CurDepthState = oldDepthState;
- Context->OMSetDepthStencilState(CurDepthState, 0);
}
// Buffers
@@ -1280,6 +1503,11 @@ Texture::Texture(RenderDevice* ren, int fmt, int w, int h) : Ren(ren), Tex(NULL)
Sampler = Ren->GetSamplerState(0);
}
+void* Texture::GetInternalImplementation()
+{
+ return Tex;
+}
+
Texture::~Texture()
{
}
@@ -1312,6 +1540,10 @@ void RenderDevice::SetTexture(Render::ShaderStage stage, int slot, const Texture
case Shader_Vertex:
Context->VSSetShaderResources(slot, 1, &sv);
+ if (t)
+ {
+ Context->VSSetSamplers(slot, 1, &t->Sampler.GetRawRef());
+ }
break;
}
}
@@ -1501,10 +1733,22 @@ Texture* RenderDevice::CreateTexture(int format, int width, int height, const vo
}
else
{
+ int samples = (format & Texture_SamplesMask);
+ if (samples < 1)
+ {
+ samples = 1;
+ }
+
+ bool createDepthSrv = (format & Texture_SampleDepth) > 0;
+
DXGI_FORMAT d3dformat;
int bpp;
switch(format & Texture_TypeMask)
{
+ case Texture_BGRA:
+ bpp = 4;
+ d3dformat = DXGI_FORMAT_B8G8R8A8_UNORM;
+ break;
case Texture_RGBA:
bpp = 4;
d3dformat = DXGI_FORMAT_R8G8B8A8_UNORM;
@@ -1513,30 +1757,28 @@ Texture* RenderDevice::CreateTexture(int format, int width, int height, const vo
bpp = 1;
d3dformat = DXGI_FORMAT_R8_UNORM;
break;
+ case Texture_A:
+ bpp = 1;
+ d3dformat = DXGI_FORMAT_A8_UNORM;
+ break;
case Texture_Depth:
bpp = 0;
- d3dformat = DXGI_FORMAT_D32_FLOAT;
+ d3dformat = createDepthSrv ? DXGI_FORMAT_R32_TYPELESS : DXGI_FORMAT_D32_FLOAT;
break;
default:
return NULL;
}
- int samples = (format & Texture_SamplesMask);
- if (samples < 1)
- {
- samples = 1;
- }
-
Texture* NewTex = new Texture(this, format, width, height);
NewTex->Samples = samples;
D3D1x_(TEXTURE2D_DESC) dsDesc;
- dsDesc.Width = width;
- dsDesc.Height = height;
+ dsDesc.Width = width;
+ dsDesc.Height = height;
dsDesc.MipLevels = (format == (Texture_RGBA | Texture_GenMipmaps) && data) ? GetNumMipLevels(width, height) : 1;
dsDesc.ArraySize = 1;
dsDesc.Format = d3dformat;
- dsDesc.SampleDesc.Count = samples;
+ dsDesc.SampleDesc.Count = samples;
dsDesc.SampleDesc.Quality = 0;
dsDesc.Usage = D3D1x_(USAGE_DEFAULT);
dsDesc.BindFlags = D3D1x_(BIND_SHADER_RESOURCE);
@@ -1546,9 +1788,8 @@ Texture* RenderDevice::CreateTexture(int format, int width, int height, const vo
if (format & Texture_RenderTarget)
{
if ((format & Texture_TypeMask) == Texture_Depth)
- // We don't use depth textures, and creating them in d3d10 requires different options.
{
- dsDesc.BindFlags = D3D1x_(BIND_DEPTH_STENCIL);
+ dsDesc.BindFlags = createDepthSrv ? (dsDesc.BindFlags | D3D1x_(BIND_DEPTH_STENCIL)) : D3D1x_(BIND_DEPTH_STENCIL);
}
else
{
@@ -1565,7 +1806,19 @@ Texture* RenderDevice::CreateTexture(int format, int width, int height, const vo
}
if (dsDesc.BindFlags & D3D1x_(BIND_SHADER_RESOURCE))
{
- Device->CreateShaderResourceView(NewTex->Tex, NULL, &NewTex->TexSv.GetRawRef());
+ if((dsDesc.BindFlags & D3D1x_(BIND_DEPTH_STENCIL)) > 0 && createDepthSrv)
+ {
+ D3D1x_(SHADER_RESOURCE_VIEW_DESC) depthSrv;
+ depthSrv.Format = DXGI_FORMAT_R32_FLOAT;
+ depthSrv.ViewDimension = samples > 1 ? D3D1x_(SRV_DIMENSION_TEXTURE2DMS) : D3D1x_(SRV_DIMENSION_TEXTURE2D);
+ depthSrv.Texture2D.MostDetailedMip = 0;
+ depthSrv.Texture2D.MipLevels = dsDesc.MipLevels;
+ Device->CreateShaderResourceView(NewTex->Tex, &depthSrv, &NewTex->TexSv.GetRawRef());
+ }
+ else
+ {
+ Device->CreateShaderResourceView(NewTex->Tex, NULL, &NewTex->TexSv.GetRawRef());
+ }
}
if (data)
@@ -1611,7 +1864,12 @@ Texture* RenderDevice::CreateTexture(int format, int width, int height, const vo
{
if ((format & Texture_TypeMask) == Texture_Depth)
{
- Device->CreateDepthStencilView(NewTex->Tex, NULL, &NewTex->TexDsv.GetRawRef());
+ D3D1x_(DEPTH_STENCIL_VIEW_DESC) depthDsv;
+ ZeroMemory(&depthDsv, sizeof(depthDsv));
+ depthDsv.Format = DXGI_FORMAT_D32_FLOAT;
+ depthDsv.ViewDimension = samples > 1 ? D3D1x_(DSV_DIMENSION_TEXTURE2DMS) : D3D1x_(DSV_DIMENSION_TEXTURE2D);
+ depthDsv.Texture2D.MipSlice = 0;
+ Device->CreateDepthStencilView(NewTex->Tex, createDepthSrv ? &depthDsv : NULL, &NewTex->TexDsv.GetRawRef());
}
else
{
@@ -1703,38 +1961,54 @@ void RenderDevice::RenderWithAlpha( const Fill* fill, Render::Buffer* vertices,
}
void RenderDevice::Render(const Fill* fill, Render::Buffer* vertices, Render::Buffer* indices,
- const Matrix4f& matrix, int offset, int count, PrimitiveType rprim)
+ const Matrix4f& matrix, int offset, int count, PrimitiveType rprim, bool useDistortionVertex/* = false*/)
{
- Context->IASetInputLayout(ModelVertexIL);
+ ID3D1xBuffer* vertexBuffer = ((Buffer*)vertices)->GetBuffer();
+ UINT vertexOffset = offset;
+ UINT vertexStride = sizeof(Vertex);
+ if ( useDistortionVertex )
+ {
+ Context->IASetInputLayout(DistortionVertexIL);
+ vertexStride = sizeof(DistortionVertex);
+ }
+ else
+ {
+ Context->IASetInputLayout(ModelVertexIL);
+ vertexStride = sizeof(Vertex);
+ }
+ Context->IASetVertexBuffers(0, 1, &vertexBuffer, &vertexStride, &vertexOffset);
+
if (indices)
{
Context->IASetIndexBuffer(((Buffer*)indices)->GetBuffer(), DXGI_FORMAT_R16_UINT, 0);
}
- ID3D1xBuffer* vertexBuffer = ((Buffer*)vertices)->GetBuffer();
- UINT vertexStride = sizeof(Vertex);
- UINT vertexOffset = offset;
- Context->IASetVertexBuffers(0, 1, &vertexBuffer, &vertexStride, &vertexOffset);
-
ShaderSet* shaders = ((ShaderFill*)fill)->GetShaders();
ShaderBase* vshader = ((ShaderBase*)shaders->GetShader(Shader_Vertex));
unsigned char* vertexData = vshader->UniformData;
- if (vertexData)
+ if ( vertexData != NULL )
{
- StandardUniformData* stdUniforms = (StandardUniformData*) vertexData;
- stdUniforms->View = matrix.Transposed();
- stdUniforms->Proj = StdUniforms.Proj;
+ // TODO: some VSes don't start with StandardUniformData!
+ if ( vshader->UniformsSize >= sizeof(StandardUniformData) )
+ {
+ StandardUniformData* stdUniforms = (StandardUniformData*) vertexData;
+ stdUniforms->View = matrix.Transposed();
+ stdUniforms->Proj = StdUniforms.Proj;
+ }
+
UniformBuffers[Shader_Vertex]->Data(Buffer_Uniform, vertexData, vshader->UniformsSize);
vshader->SetUniformBuffer(UniformBuffers[Shader_Vertex]);
}
for(int i = Shader_Vertex + 1; i < Shader_Count; i++)
+ {
if (shaders->GetShader(i))
{
((ShaderBase*)shaders->GetShader(i))->UpdateBuffer(UniformBuffers[i]);
((ShaderBase*)shaders->GetShader(i))->SetUniformBuffer(UniformBuffers[i]);
}
+ }
D3D1x_(PRIMITIVE_TOPOLOGY) prim;
switch(rprim)
@@ -1749,7 +2023,7 @@ void RenderDevice::Render(const Fill* fill, Render::Buffer* vertices, Render::Bu
prim = D3D1x_(PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
break;
default:
- assert(0);
+ OVR_ASSERT(0);
return;
}
Context->IASetPrimitiveTopology(prim);
@@ -1782,20 +2056,40 @@ UPInt RenderDevice::QueryGPUMemorySize()
}
-void RenderDevice::Present()
+void RenderDevice::Present ( bool withVsync )
{
- SwapChain->Present(0, 0);
+ if( OVR::Util::ImageWindow::GlobalWindow() )
+ {
+ OVR::Util::ImageWindow::GlobalWindow()->Process();
+ }
+
+ if ( withVsync )
+ {
+ SwapChain->Present(1, 0);
+ }
+ else
+ {
+ // Immediate present
+ SwapChain->Present(0, 0);
+ }
}
-void RenderDevice::ForceFlushGPU()
+void RenderDevice::WaitUntilGpuIdle()
{
+#if 0
+ // If enabling this option and using an NVIDIA GPU,
+ // then make sure your "max pre-rendered frames" is set to 1 under the NVIDIA GPU settings.
+
+ // Flush GPU data and don't stall CPU waiting for GPU to complete
+ Context->Flush();
+#else
+ // Flush and Stall CPU while waiting for GPU to complete rendering all of the queued draw calls
D3D1x_QUERY_DESC queryDesc = { D3D1x_(QUERY_EVENT), 0 };
Ptr<ID3D1xQuery> query;
BOOL done = FALSE;
if (Device->CreateQuery(&queryDesc, &query.GetRawRef()) == S_OK)
{
-
#if (OVR_D3D_VERSION == 10)
// Begin() not used for EVENT query.
query->End();
@@ -1808,10 +2102,10 @@ void RenderDevice::ForceFlushGPU()
do { }
while(!done && !FAILED(Context->GetData(query, &done, sizeof(BOOL), 0)));
#endif
-
}
-}
+#endif
+}
void RenderDevice::FillRect(float left, float top, float right, float bottom, Color c)
{
@@ -1841,5 +2135,27 @@ void RenderDevice::RenderImage(float left, float top, float right, float bottom,
Context->OMSetBlendState(NULL, NULL, 0xffffffff);
}
+void RenderDevice::BeginGpuEvent(const char* markerText, UInt32 markerColor)
+{
+#if GPU_PROFILING
+ WCHAR wStr[255];
+ size_t newStrLen = 0;
+ mbstowcs_s(&newStrLen, wStr, markerText, 255);
+ LPCWSTR pwStr = wStr;
+
+ D3DPERF_BeginEvent(markerColor, pwStr);
+#else
+ OVR_UNUSED(markerText);
+ OVR_UNUSED(markerColor);
+#endif
+}
+
+void RenderDevice::EndGpuEvent()
+{
+#if GPU_PROFILING
+ D3DPERF_EndEvent();
+#endif
+}
+
}}}
diff --git a/Samples/CommonSrc/Render/Render_D3D1X_Device.h b/Samples/CommonSrc/Render/Render_D3D1X_Device.h
index b615e2b..e06bcda 100644
--- a/Samples/CommonSrc/Render/Render_D3D1X_Device.h
+++ b/Samples/CommonSrc/Render/Render_D3D1X_Device.h
@@ -42,7 +42,7 @@ limitations under the License.
#if (OVR_D3D_VERSION == 10)
#define _OVR_RENDERER_D3D10
-#include <d3d10.h>
+#include <d3d10_1.h>
namespace OVR { namespace Render { namespace D3D10 {
@@ -64,8 +64,8 @@ class RenderDevice;
#endif
#if (OVR_D3D_VERSION == 10)
-typedef ID3D10Device ID3D1xDevice;
-typedef ID3D10Device ID3D1xDeviceContext;
+typedef ID3D10Device1 ID3D1xDevice;
+typedef ID3D10Device1 ID3D1xDeviceContext;
typedef ID3D10RenderTargetView ID3D1xRenderTargetView;
typedef ID3D10Texture2D ID3D1xTexture2D;
typedef ID3D10ShaderResourceView ID3D1xShaderResourceView;
@@ -73,6 +73,7 @@ typedef ID3D10DepthStencilView ID3D1xDepthStencilView;
typedef ID3D10DepthStencilState ID3D1xDepthStencilState;
typedef ID3D10InputLayout ID3D1xInputLayout;
typedef ID3D10Buffer ID3D1xBuffer;
+typedef ID3D10Resource ID3D1xResource;
typedef ID3D10VertexShader ID3D1xVertexShader;
typedef ID3D10PixelShader ID3D1xPixelShader;
typedef ID3D10GeometryShader ID3D1xGeometryShader;
@@ -96,6 +97,7 @@ typedef ID3D11DepthStencilView ID3D1xDepthStencilView;
typedef ID3D11DepthStencilState ID3D1xDepthStencilState;
typedef ID3D11InputLayout ID3D1xInputLayout;
typedef ID3D11Buffer ID3D1xBuffer;
+typedef ID3D11Resource ID3D1xResource;
typedef ID3D10Blob ID3D1xBlob;
typedef ID3D11VertexShader ID3D1xVertexShader;
typedef ID3D11PixelShader ID3D1xPixelShader;
@@ -201,11 +203,12 @@ public:
class Texture : public Render::Texture
{
public:
- RenderDevice* Ren;
+ RenderDevice* Ren;
Ptr<ID3D1xTexture2D> Tex;
Ptr<ID3D1xShaderResourceView> TexSv;
Ptr<ID3D1xRenderTargetView> TexRtv;
Ptr<ID3D1xDepthStencilView> TexDsv;
+ Ptr<ID3D1xTexture2D> TexStaging;
mutable Ptr<ID3D1xSamplerState> Sampler;
int Width, Height;
int Samples;
@@ -229,6 +232,11 @@ public:
virtual void SetSampleMode(int sm);
virtual void Set(int slot, Render::ShaderStage stage = Render::Shader_Fragment) const;
+
+ virtual ovrTexture Get_ovrTexture();
+
+ virtual void* GetInternalImplementation();
+
};
class RenderDevice : public Render::RenderDevice
@@ -251,12 +259,12 @@ public:
Ptr<Texture> CurDepthBuffer;
Ptr<ID3D1xRasterizerState> Rasterizer;
Ptr<ID3D1xBlendState> BlendState;
- int NumViewports;
- D3D1x_VIEWPORT Viewports[2];
+ D3D1x_VIEWPORT D3DViewport;
Ptr<ID3D1xDepthStencilState> DepthStates[1 + 2 * Compare_Count];
Ptr<ID3D1xDepthStencilState> CurDepthState;
Ptr<ID3D1xInputLayout> ModelVertexIL;
+ Ptr<ID3D1xInputLayout> DistortionVertexIL;
Ptr<ID3D1xSamplerState> SamplerStates[Sample_Count];
@@ -292,18 +300,22 @@ public:
// and it should be recreated.
void UpdateMonitorOutputs(bool needRecreate = false);
- virtual void SetMultipleViewports(int n, const Viewport* vps);
+ virtual void SetViewport(const Recti& vp);
virtual void SetWindowSize(int w, int h);
virtual bool SetParams(const RendererParams& newParams);
- //virtual void SetScissor(int x, int y, int w, int h);
- virtual void Present();
- virtual void ForceFlushGPU();
+ // Returns details needed by CAPI distortion rendering.
+ virtual ovrRenderAPIConfig Get_ovrRenderAPIConfig() const;
+
+ virtual void Present ( bool withVsync );
+ virtual void WaitUntilGpuIdle();
virtual bool SetFullscreen(DisplayMode fullscreen);
virtual UPInt QueryGPUMemorySize();
- virtual void Clear(float r = 0, float g = 0, float b = 0, float a = 1, float depth = 1);
+ virtual void Clear(float r = 0, float g = 0, float b = 0, float a = 1,
+ float depth = 1,
+ bool clearColor = true, bool clearDepth = true);
virtual void Rect(float left, float top, float right, float bottom)
{
OVR_UNUSED4(left, top, right, bottom);
@@ -331,7 +343,6 @@ public:
ExtraShaders = s;
}
-
// Overrident to apply proper blend state.
virtual void FillRect(float left, float top, float right, float bottom, Color c);
virtual void FillGradientRect(float left, float top, float right, float bottom, Color col_top, Color col_btm);
@@ -340,7 +351,7 @@ public:
virtual void Render(const Matrix4f& matrix, Model* model);
virtual void Render(const Fill* fill, Render::Buffer* vertices, Render::Buffer* indices,
- const Matrix4f& matrix, int offset, int count, PrimitiveType prim = Prim_Triangles);
+ const Matrix4f& matrix, int offset, int count, PrimitiveType prim = Prim_Triangles, bool useDistortionVertex = false);
virtual void RenderWithAlpha( const Fill* fill, Render::Buffer* vertices, Render::Buffer* indices,
const Matrix4f& matrix, int offset, int count, PrimitiveType prim = Prim_Triangles);
@@ -355,6 +366,10 @@ public:
ID3D1xSamplerState* GetSamplerState(int sm);
void SetTexture(Render::ShaderStage stage, int slot, const Texture* t);
+
+ // GPU Profiling
+ virtual void BeginGpuEvent(const char* markerText, UInt32 markerColor);
+ virtual void EndGpuEvent();
};
}}}
diff --git a/Samples/CommonSrc/Render/Render_Device.cpp b/Samples/CommonSrc/Render/Render_Device.cpp
index d0f3228..e917fb0 100644
--- a/Samples/CommonSrc/Render/Render_Device.cpp
+++ b/Samples/CommonSrc/Render/Render_Device.cpp
@@ -25,107 +25,112 @@ limitations under the License.
#include "../Render/Render_Font.h"
#include "Kernel/OVR_Log.h"
+#include "Util/Util_Render_Stereo.h"
+using namespace OVR::Util::Render;
namespace OVR { namespace Render {
-void Model::Render(const Matrix4f& ltw, RenderDevice* ren)
-{
- if(Visible)
- {
- Matrix4f m = ltw * GetMatrix();
- ren->Render(m, this);
- }
-}
-
-void Container::Render(const Matrix4f& ltw, RenderDevice* ren)
-{
- Matrix4f m = ltw * GetMatrix();
- for(unsigned i = 0; i < Nodes.GetSize(); i++)
- {
- Nodes[i]->Render(m, ren);
- }
-}
-
-Matrix4f SceneView::GetViewMatrix() const
-{
- Matrix4f view = Matrix4f(GetOrientation().Conj()) * Matrix4f::Translation(GetPosition());
- return view;
-}
-
-void LightingParams::Update(const Matrix4f& view, const Vector4f* SceneLightPos)
-{
- Version++;
- for (int i = 0; i < LightCount; i++)
- {
- LightPos[i] = view.Transform(SceneLightPos[i]);
- }
-}
-
-void Scene::Render(RenderDevice* ren, const Matrix4f& view)
-{
- Lighting.Update(view, LightPos);
-
- ren->SetLighting(&Lighting);
-
- World.Render(view, ren);
-}
-
-
-
-UInt16 CubeIndices[] =
-{
- 0, 1, 3,
- 3, 1, 2,
-
- 5, 4, 6,
- 6, 4, 7,
-
- 8, 9, 11,
- 11, 9, 10,
-
- 13, 12, 14,
- 14, 12, 15,
-
- 16, 17, 19,
- 19, 17, 18,
-
- 21, 20, 22,
- 22, 20, 23
-};
-
-// Colors are specified for planes perpendicular to the axis
-// For example, "xColor" is the color of the y-z plane
-Model* Model::CreateAxisFaceColorBox(float x1, float x2, Color xcolor,
- float y1, float y2, Color ycolor,
- float z1, float z2, Color zcolor)
-{
- float t;
-
- if(x1 > x2)
- {
- t = x1;
- x1 = x2;
- x2 = t;
- }
- if(y1 > y2)
- {
- t = y1;
- y1 = y2;
- y2 = t;
- }
- if(z1 > z2)
- {
- t = z1;
- z1 = z2;
- z2 = t;
- }
-
- Model* box = new Model();
-
- UInt16 startIndex = 0;
- // Cube
- startIndex =
- box->AddVertex(Vector3f(x1, y2, z1), ycolor);
+ void Model::Render(const Matrix4f& ltw, RenderDevice* ren)
+ {
+ if(Visible)
+ {
+ AutoGpuProf prof(ren, "Model_Render");
+ Matrix4f m = ltw * GetMatrix();
+ ren->Render(m, this);
+ }
+ }
+
+ void Container::Render(const Matrix4f& ltw, RenderDevice* ren)
+ {
+ Matrix4f m = ltw * GetMatrix();
+ for(unsigned i = 0; i < Nodes.GetSize(); i++)
+ {
+ Nodes[i]->Render(m, ren);
+ }
+ }
+
+ Matrix4f SceneView::GetViewMatrix() const
+ {
+ Matrix4f view = Matrix4f(GetOrientation().Conj()) * Matrix4f::Translation(GetPosition());
+ return view;
+ }
+
+ void LightingParams::Update(const Matrix4f& view, const Vector3f* SceneLightPos)
+ {
+ Version++;
+ for (int i = 0; i < LightCount; i++)
+ {
+ LightPos[i] = view.Transform(SceneLightPos[i]);
+ }
+ }
+
+ void Scene::Render(RenderDevice* ren, const Matrix4f& view)
+ {
+ AutoGpuProf prof(ren, "Scene_Render");
+
+ Lighting.Update(view, LightPos);
+
+ ren->SetLighting(&Lighting);
+
+ World.Render(view, ren);
+ }
+
+
+
+ UInt16 CubeIndices[] =
+ {
+ 0, 1, 3,
+ 3, 1, 2,
+
+ 5, 4, 6,
+ 6, 4, 7,
+
+ 8, 9, 11,
+ 11, 9, 10,
+
+ 13, 12, 14,
+ 14, 12, 15,
+
+ 16, 17, 19,
+ 19, 17, 18,
+
+ 21, 20, 22,
+ 22, 20, 23
+ };
+
+ // Colors are specified for planes perpendicular to the axis
+ // For example, "xColor" is the color of the y-z plane
+ Model* Model::CreateAxisFaceColorBox(float x1, float x2, Color xcolor,
+ float y1, float y2, Color ycolor,
+ float z1, float z2, Color zcolor)
+ {
+ float t;
+
+ if(x1 > x2)
+ {
+ t = x1;
+ x1 = x2;
+ x2 = t;
+ }
+ if(y1 > y2)
+ {
+ t = y1;
+ y1 = y2;
+ y2 = t;
+ }
+ if(z1 > z2)
+ {
+ t = z1;
+ z1 = z2;
+ z2 = t;
+ }
+
+ Model* box = new Model();
+
+ UInt16 startIndex = 0;
+ // Cube
+ startIndex =
+ box->AddVertex(Vector3f(x1, y2, z1), ycolor);
box->AddVertex(Vector3f(x2, y2, z1), ycolor);
box->AddVertex(Vector3f(x2, y2, z2), ycolor);
box->AddVertex(Vector3f(x1, y2, z2), ycolor);
@@ -156,960 +161,1233 @@ Model* Model::CreateAxisFaceColorBox(float x1, float x2, Color xcolor,
box->AddVertex(Vector3f(x1, y2, z2), zcolor);
- enum
- {
- // CubeVertexCount = sizeof(CubeVertices)/sizeof(CubeVertices[0]),
- CubeIndexCount = sizeof(CubeIndices) / sizeof(CubeIndices[0])
- };
-
- // Renumber indices
- for(int i = 0; i < CubeIndexCount / 3; i++)
- {
- box->AddTriangle(CubeIndices[i * 3] + startIndex,
- CubeIndices[i * 3 + 1] + startIndex,
- CubeIndices[i * 3 + 2] + startIndex);
- }
-
- return box;
-}
-
-void Model::AddSolidColorBox(float x1, float y1, float z1,
- float x2, float y2, float z2,
- Color c)
-{
- float t;
-
- if(x1 > x2)
- {
- t = x1;
- x1 = x2;
- x2 = t;
- }
- if(y1 > y2)
- {
- t = y1;
- y1 = y2;
- y2 = t;
- }
- if(z1 > z2)
- {
- t = z1;
- z1 = z2;
- z2 = t;
- }
-
- // Cube vertices and their normals.
- Vector3f CubeVertices[][3] =
- {
- Vector3f(x1, y2, z1), Vector3f(z1, x1), Vector3f(0.0f, 1.0f, 0.0f),
- Vector3f(x2, y2, z1), Vector3f(z1, x2), Vector3f(0.0f, 1.0f, 0.0f),
- Vector3f(x2, y2, z2), Vector3f(z2, x2), Vector3f(0.0f, 1.0f, 0.0f),
- Vector3f(x1, y2, z2), Vector3f(z2, x1), Vector3f(0.0f, 1.0f, 0.0f),
-
- Vector3f(x1, y1, z1), Vector3f(z1, x1), Vector3f(0.0f, -1.0f, 0.0f),
- Vector3f(x2, y1, z1), Vector3f(z1, x2), Vector3f(0.0f, -1.0f, 0.0f),
- Vector3f(x2, y1, z2), Vector3f(z2, x2), Vector3f(0.0f, -1.0f, 0.0f),
- Vector3f(x1, y1, z2), Vector3f(z2, x1), Vector3f(0.0f, -1.0f, 0.0f),
-
- Vector3f(x1, y1, z2), Vector3f(z2, y1), Vector3f(-1.0f, 0.0f, 0.0f),
- Vector3f(x1, y1, z1), Vector3f(z1, y1), Vector3f(-1.0f, 0.0f, 0.0f),
- Vector3f(x1, y2, z1), Vector3f(z1, y2), Vector3f(-1.0f, 0.0f, 0.0f),
- Vector3f(x1, y2, z2), Vector3f(z2, y2), Vector3f(-1.0f, 0.0f, 0.0f),
-
- Vector3f(x2, y1, z2), Vector3f(z2, y1), Vector3f(1.0f, 0.0f, 0.0f),
- Vector3f(x2, y1, z1), Vector3f(z1, y1), Vector3f(1.0f, 0.0f, 0.0f),
- Vector3f(x2, y2, z1), Vector3f(z1, y2), Vector3f(1.0f, 0.0f, 0.0f),
- Vector3f(x2, y2, z2), Vector3f(z2, y2), Vector3f(1.0f, 0.0f, 0.0f),
-
- Vector3f(x1, y1, z1), Vector3f(x1, y1), Vector3f(0.0f, 0.0f, -1.0f),
- Vector3f(x2, y1, z1), Vector3f(x2, y1), Vector3f(0.0f, 0.0f, -1.0f),
- Vector3f(x2, y2, z1), Vector3f(x2, y2), Vector3f(0.0f, 0.0f, -1.0f),
- Vector3f(x1, y2, z1), Vector3f(x1, y2), Vector3f(0.0f, 0.0f, -1.0f),
-
- Vector3f(x1, y1, z2), Vector3f(x1, y1), Vector3f(0.0f, 0.0f, 1.0f),
- Vector3f(x2, y1, z2), Vector3f(x2, y1), Vector3f(0.0f, 0.0f, 1.0f),
- Vector3f(x2, y2, z2), Vector3f(x2, y2), Vector3f(0.0f, 0.0f, 1.0f),
- Vector3f(x1, y2, z2), Vector3f(x1, y2), Vector3f(0.0f, 0.0f, 1.0f)
- };
-
-
- UInt16 startIndex = GetNextVertexIndex();
-
- enum
- {
- CubeVertexCount = sizeof(CubeVertices) / sizeof(CubeVertices[0]),
- CubeIndexCount = sizeof(CubeIndices) / sizeof(CubeIndices[0])
- };
-
- for(int v = 0; v < CubeVertexCount; v++)
- {
- AddVertex(Vertex(CubeVertices[v][0], c, CubeVertices[v][1].x, CubeVertices[v][1].y, CubeVertices[v][2]));
- }
-
- // Renumber indices
- for(int i = 0; i < CubeIndexCount / 3; i++)
- {
- AddTriangle(CubeIndices[i * 3] + startIndex,
- CubeIndices[i * 3 + 1] + startIndex,
- CubeIndices[i * 3 + 2] + startIndex);
- }
-}
-
-
-
-Model* Model::CreateBox(Color c, Vector3f origin, Vector3f size)
-{
- Model *box = new Model();
- Vector3f s = size * 0.5f;
-
- box->AddVertex(-s.x, s.y, -s.z, c, 0, 1, 0, 0, -1);
- box->AddVertex(s.x, s.y, -s.z, c, 1, 1, 0, 0, -1);
- box->AddVertex(s.x, -s.y, -s.z, c, 1, 0, 0, 0, -1);
- box->AddVertex(-s.x, -s.y, -s.z, c, 0, 0, 0, 0, -1);
- box->AddTriangle(2, 1, 0);
- box->AddTriangle(0, 3, 2);
-
- box->AddVertex(s.x, s.y, s.z, c, 1, 1, 0, 0, 1);
- box->AddVertex(-s.x, s.y, s.z, c, 0, 1, 0, 0, 1);
- box->AddVertex(-s.x, -s.y, s.z, c, 0, 0, 0, 0, 1);
- box->AddVertex(s.x, -s.y, s.z, c, 1, 0, 0, 0, 1);
- box->AddTriangle(6, 5, 4);
- box->AddTriangle(4, 7, 6);
-
- box->AddVertex(-s.x, s.y, -s.z, c, 1, 0, -1, 0, 0);
- box->AddVertex(-s.x, s.y, s.z, c, 1, 1, -1, 0, 0);
- box->AddVertex(-s.x, -s.y, s.z, c, 0, 1, -1, 0, 0);
- box->AddVertex(-s.x, -s.y, -s.z, c, 0, 0, -1, 0, 0);
- box->AddTriangle(10, 11, 8);
- box->AddTriangle(8, 9, 10);
-
- box->AddVertex(s.x, s.y, -s.z, c, 1, 0, 1, 0, 0);
- box->AddVertex(s.x, -s.y, -s.z, c, 0, 0, 1, 0, 0);
- box->AddVertex(s.x, -s.y, s.z, c, 0, 1, 1, 0, 0);
- box->AddVertex(s.x, s.y, s.z, c, 1, 1, 1, 0, 0);
- box->AddTriangle(14, 15, 12);
- box->AddTriangle(12, 13, 14);
-
- box->AddVertex(-s.x, -s.y, s.z, c, 0, 1, 0, -1, 0);
- box->AddVertex(s.x, -s.y, s.z, c, 1, 1, 0, -1, 0);
- box->AddVertex(s.x, -s.y, -s.z, c, 1, 0, 0, -1, 0);
- box->AddVertex(-s.x, -s.y, -s.z, c, 0, 0, 0, -1, 0);
- box->AddTriangle(18, 19, 16);
- box->AddTriangle(16, 17, 18);
-
- box->AddVertex(-s.x, s.y, -s.z, c, 0, 0, 0, 1, 0);
- box->AddVertex(s.x, s.y, -s.z, c, 1, 0, 0, 1, 0);
- box->AddVertex(s.x, s.y, s.z, c, 1, 1, 0, 1, 0);
- box->AddVertex(-s.x, s.y, s.z, c, 0, 1, 0, 1, 0);
- box->AddTriangle(20, 21, 22);
- box->AddTriangle(22, 23, 20);
-
- box->SetPosition(origin);
- return box;
-}
-
-// Triangulation of a cylinder centered at the origin
-Model* Model::CreateCylinder(Color color, Vector3f origin, float height, float radius, int sides)
-{
- Model *cyl = new Model();
- float halfht = height * 0.5f;
- for(UInt16 i = 0; i < sides; i++)
- {
- float x = cosf(Math<float>::TwoPi * i / float(sides));
- float y = sinf(Math<float>::TwoPi * i / float(sides));
-
- cyl->AddVertex(radius * x, radius * y, halfht, color, x + 1, y, 0, 0, 1);
- cyl->AddVertex(radius * x, radius * y, -1.0f*halfht, color, x, y, 0, 0, -1);
-
- UInt16 j = 0;
- if(i < sides - 1)
- {
- j = i + 1;
- cyl->AddTriangle(0, i * 4 + 4, i * 4);
- cyl->AddTriangle(1, i * 4 + 1, i * 4 + 5);
- }
-
- float nx = cosf(Math<float>::Pi * (0.5f + 2.0f * i / float(sides)));
- float ny = sinf(Math<float>::Pi * (0.5f + 2.0f * i / float(sides)));
- cyl->AddVertex(radius * x, radius * y, halfht, color, x + 1, y, nx, ny, 0);
- cyl->AddVertex(radius * x, radius * y, -1.0f*halfht, color, x, y, nx, ny, 0);
-
- cyl->AddTriangle(i * 4 + 2, j * 4 + 2, i * 4 + 3);
- cyl->AddTriangle(i * 4 + 3, j * 4 + 2, j * 4 + 3);
- }
- cyl->SetPosition(origin);
- return cyl;
-};
-
-//Triangulation of a cone centered at the origin
-Model* Model::CreateCone(Color color, Vector3f origin, float height, float radius, int sides)
-{
- Model *cone = new Model();
- float halfht = height * 0.5f;
- cone->AddVertex(0.0f, 0.0f, -1.0f*halfht, color, 0, 0, 0, 0, -1);
-
- for(UInt16 i = 0; i < sides; i++)
- {
- float x = cosf(Math<float>::TwoPi * i / float(sides));
- float y = sinf(Math<float>::TwoPi * i / float(sides));
-
- cone->AddVertex(radius * x, radius * y, -1.0f*halfht, color, 0, 0, 0, 0, -1);
-
- UInt16 j = 1;
- if(i < sides - 1)
- {
- j = i + 1;
- }
-
- float next_x = cosf(Math<float>::TwoPi * j / float(sides));
- float next_y = sinf(Math<float>::TwoPi * j / float(sides));
-
- Vector3f normal = Vector3f(x, y, -halfht).Cross(Vector3f(next_x, next_y, -halfht));
-
- cone->AddVertex(0.0f, 0.0f, halfht, color, 1, 0, normal.x, normal.y, normal.z);
- cone->AddVertex(radius * x, radius * y, -1.0f*halfht, color, 0, 0, normal.x, normal.y, normal.z);
-
- cone->AddTriangle(0, 3*i + 1, 3*j + 1);
- cone->AddTriangle(3*i + 2, 3*j + 3, 3*i + 3);
- }
- cone->SetPosition(origin);
- return cone;
-};
-
-//Triangulation of a sphere centered at the origin
-Model* Model::CreateSphere(Color color, Vector3f origin, float radius, int sides)
-{
- Model *sphere = new Model();
- UInt16 usides = (UInt16) sides;
- UInt16 halfsides = usides/2;
-
- for(UInt16 k = 0; k < halfsides; k++) {
-
- float z = cosf(Math<float>::Pi * k / float(halfsides));
- float z_r = sinf(Math<float>::Pi * k / float(halfsides)); // the radius of the cross circle with coordinate z
-
- if (k == 0)
- { // add north and south poles
- sphere->AddVertex(0.0f, 0.0f, radius, color, 0, 0, 0, 0, 1);
- sphere->AddVertex(0.0f, 0.0f, -radius, color, 1, 1, 0, 0, -1);
- }
- else
- {
- for(UInt16 i = 0; i < sides; i++)
- {
- float x = cosf(Math<float>::TwoPi * i / float(sides)) * z_r;
- float y = sinf(Math<float>::TwoPi * i / float(sides)) * z_r;
-
- UInt16 j = 0;
- if(i < sides - 1)
- {
- j = i + 1;
- }
-
- sphere->AddVertex(radius * x, radius * y, radius * z, color, 0, 1, x, y, z);
-
- UInt16 indi = 2 + (k -1)*usides + i;
- UInt16 indj = 2 + (k -1)*usides + j;
- if (k == 1) // NorthPole
- sphere->AddTriangle(0, j + 2, i + 2);
- else if (k == halfsides - 1) //SouthPole
- {
- sphere->AddTriangle(1, indi, indj);
- sphere->AddTriangle(indi, indi - usides, indj);
- sphere->AddTriangle(indi - usides, indj - usides, indj);
- }
- else
- {
- sphere->AddTriangle(indi, indi - usides, indj);
- sphere->AddTriangle(indi - usides, indj - usides, indj);
- }
- }
- } // end else
- }
- sphere->SetPosition(origin);
- return sphere;
-};
-
-Model* Model::CreateGrid(Vector3f origin, Vector3f stepx, Vector3f stepy,
- int halfx, int halfy, int nmajor, Color minor, Color major)
-{
- Model* grid = new Model(Prim_Lines);
- float halfxf = (float)halfx;
- float halfyf = (float)halfy;
-
- for(int jn = 0; jn <= halfy; jn++)
- {
- float j = (float)jn;
-
- grid->AddLine(grid->AddVertex((stepx * -halfxf) + (stepy * j), (jn % nmajor) ? minor : major, 0, 0.5f),
- grid->AddVertex((stepx * halfxf) + (stepy * j), (jn % nmajor) ? minor : major, 1, 0.5f));
-
- if(j)
- grid->AddLine(grid->AddVertex((stepx * -halfxf) + (stepy * -j), (jn % nmajor) ? minor : major, 0, 0.5f),
- grid->AddVertex((stepx * halfxf) + (stepy * -j), (jn % nmajor) ? minor : major, 1, 0.5f));
- }
-
- for(int in = 0; in <= halfx; in++)
- {
- float i = (float)in;
-
- grid->AddLine(grid->AddVertex((stepx * i) + (stepy * -halfyf), (in % nmajor) ? minor : major, 0, 0.5f),
- grid->AddVertex((stepx * i) + (stepy * halfyf), (in % nmajor) ? minor : major, 1, 0.5f));
-
- if(i)
- grid->AddLine(grid->AddVertex((stepx * -i) + (stepy * -halfyf), (in % nmajor) ? minor : major, 0, 0.5f),
- grid->AddVertex((stepx * -i) + (stepy * halfyf), (in % nmajor) ? minor : major, 1, 0.5f));
- }
-
- grid->SetPosition(origin);
- return grid;
-}
-
-
-//-------------------------------------------------------------------------------------
-
-
-void ShaderFill::Set(PrimitiveType prim) const
-{
- Shaders->Set(prim);
- for(int i = 0; i < 8; i++)
- if(Textures[i])
- {
- Textures[i]->Set(i);
- }
-}
-
-
-
-//-------------------------------------------------------------------------------------
-// ***** Rendering
-
-
-RenderDevice::RenderDevice()
- : CurPostProcess(PostProcess_None),
- SceneColorTexW(0), SceneColorTexH(0),
- SceneRenderScale(1),
-
- Distortion(1.0f, 0.18f, 0.115f),
- DistortionClearColor(0, 0, 0),
- PostProcessShaderActive(PostProcessShader_DistortionAndChromAb),
- TotalTextureMemoryUsage(0)
-{
- PostProcessShaderRequested = PostProcessShaderActive;
-}
-
-Fill* RenderDevice::CreateTextureFill(Render::Texture* t, bool useAlpha)
-{
- ShaderSet* shaders = CreateShaderSet();
- shaders->SetShader(LoadBuiltinShader(Shader_Vertex, VShader_MVP));
- shaders->SetShader(LoadBuiltinShader(Shader_Fragment, useAlpha ? FShader_AlphaTexture : FShader_Texture));
- Fill* f = new ShaderFill(*shaders);
- f->SetTexture(0, t);
- return f;
-}
-
-void LightingParams::Set(ShaderSet* s) const
-{
- s->SetUniform4fv("Ambient", 1, &Ambient);
- s->SetUniform1f("LightCount", LightCount);
- s->SetUniform4fv("LightPos", (int)LightCount, LightPos);
- s->SetUniform4fv("LightColor", (int)LightCount, LightColor);
-}
-
-void RenderDevice::SetLighting(const LightingParams* lt)
-{
- if (!LightingBuffer)
- LightingBuffer = *CreateBuffer();
-
- LightingBuffer->Data(Buffer_Uniform, lt, sizeof(LightingParams));
- SetCommonUniformBuffer(1, LightingBuffer);
-}
-
-float RenderDevice::MeasureText(const Font* font, const char* str, float size, float* strsize)
-{
- UPInt length = strlen(str);
- float w = 0;
- float xp = 0;
- float yp = 0;
-
- for (UPInt i = 0; i < length; i++)
- {
- if(str[i] == '\n')
- {
- yp += font->lineheight;
- if(xp > w)
- {
- w = xp;
- }
- xp = 0;
- continue;
- }
-
- // Tab followed by a numbers sets position to specified offset.
- if(str[i] == '\t')
- {
- char *p = 0;
- float tabPixels = (float)OVR_strtoq(str + i + 1, &p, 10);
- i += p - (str + i + 1);
- xp = tabPixels;
- }
- else
- {
- const Font::Char* ch = &font->chars[str[i]];
- xp += ch->advance;
- }
- }
-
- if(xp > w)
- {
- w = xp;
- }
-
- if(strsize)
- {
- strsize[0] = (size / font->lineheight) * w;
- strsize[1] = (size / font->lineheight) * (yp + font->lineheight);
- }
- return (size / font->lineheight) * w;
-}
-
-void RenderDevice::RenderText(const Font* font, const char* str,
- float x, float y, float size, Color c)
-{
- if(!pTextVertexBuffer)
- {
- pTextVertexBuffer = *CreateBuffer();
- if(!pTextVertexBuffer)
- {
- return;
- }
- }
-
- if(!font->fill)
- {
- font->fill = CreateTextureFill(Ptr<Texture>(
- *CreateTexture(Texture_R, font->twidth, font->theight, font->tex)), true);
- }
-
- UPInt length = strlen(str);
-
- pTextVertexBuffer->Data(Buffer_Vertex, NULL, length * 6 * sizeof(Vertex));
- Vertex* vertices = (Vertex*)pTextVertexBuffer->Map(0, length * 6 * sizeof(Vertex), Map_Discard);
- if(!vertices)
- {
- return;
- }
+ enum
+ {
+ // CubeVertexCount = sizeof(CubeVertices)/sizeof(CubeVertices[0]),
+ CubeIndexCount = sizeof(CubeIndices) / sizeof(CubeIndices[0])
+ };
+
+ // Renumber indices
+ for(int i = 0; i < CubeIndexCount / 3; i++)
+ {
+ box->AddTriangle(CubeIndices[i * 3] + startIndex,
+ CubeIndices[i * 3 + 1] + startIndex,
+ CubeIndices[i * 3 + 2] + startIndex);
+ }
+
+ return box;
+ }
+
+ void Model::AddSolidColorBox(float x1, float y1, float z1,
+ float x2, float y2, float z2,
+ Color c)
+ {
+ float t;
+
+ if(x1 > x2)
+ {
+ t = x1;
+ x1 = x2;
+ x2 = t;
+ }
+ if(y1 > y2)
+ {
+ t = y1;
+ y1 = y2;
+ y2 = t;
+ }
+ if(z1 > z2)
+ {
+ t = z1;
+ z1 = z2;
+ z2 = t;
+ }
+
+ // Cube vertices and their normals.
+ Vector3f CubeVertices[][3] =
+ {
+ Vector3f(x1, y2, z1), Vector3f(z1, x1), Vector3f(0.0f, 1.0f, 0.0f),
+ Vector3f(x2, y2, z1), Vector3f(z1, x2), Vector3f(0.0f, 1.0f, 0.0f),
+ Vector3f(x2, y2, z2), Vector3f(z2, x2), Vector3f(0.0f, 1.0f, 0.0f),
+ Vector3f(x1, y2, z2), Vector3f(z2, x1), Vector3f(0.0f, 1.0f, 0.0f),
+
+ Vector3f(x1, y1, z1), Vector3f(z1, x1), Vector3f(0.0f, -1.0f, 0.0f),
+ Vector3f(x2, y1, z1), Vector3f(z1, x2), Vector3f(0.0f, -1.0f, 0.0f),
+ Vector3f(x2, y1, z2), Vector3f(z2, x2), Vector3f(0.0f, -1.0f, 0.0f),
+ Vector3f(x1, y1, z2), Vector3f(z2, x1), Vector3f(0.0f, -1.0f, 0.0f),
+
+ Vector3f(x1, y1, z2), Vector3f(z2, y1), Vector3f(-1.0f, 0.0f, 0.0f),
+ Vector3f(x1, y1, z1), Vector3f(z1, y1), Vector3f(-1.0f, 0.0f, 0.0f),
+ Vector3f(x1, y2, z1), Vector3f(z1, y2), Vector3f(-1.0f, 0.0f, 0.0f),
+ Vector3f(x1, y2, z2), Vector3f(z2, y2), Vector3f(-1.0f, 0.0f, 0.0f),
+
+ Vector3f(x2, y1, z2), Vector3f(z2, y1), Vector3f(1.0f, 0.0f, 0.0f),
+ Vector3f(x2, y1, z1), Vector3f(z1, y1), Vector3f(1.0f, 0.0f, 0.0f),
+ Vector3f(x2, y2, z1), Vector3f(z1, y2), Vector3f(1.0f, 0.0f, 0.0f),
+ Vector3f(x2, y2, z2), Vector3f(z2, y2), Vector3f(1.0f, 0.0f, 0.0f),
+
+ Vector3f(x1, y1, z1), Vector3f(x1, y1), Vector3f(0.0f, 0.0f, -1.0f),
+ Vector3f(x2, y1, z1), Vector3f(x2, y1), Vector3f(0.0f, 0.0f, -1.0f),
+ Vector3f(x2, y2, z1), Vector3f(x2, y2), Vector3f(0.0f, 0.0f, -1.0f),
+ Vector3f(x1, y2, z1), Vector3f(x1, y2), Vector3f(0.0f, 0.0f, -1.0f),
+
+ Vector3f(x1, y1, z2), Vector3f(x1, y1), Vector3f(0.0f, 0.0f, 1.0f),
+ Vector3f(x2, y1, z2), Vector3f(x2, y1), Vector3f(0.0f, 0.0f, 1.0f),
+ Vector3f(x2, y2, z2), Vector3f(x2, y2), Vector3f(0.0f, 0.0f, 1.0f),
+ Vector3f(x1, y2, z2), Vector3f(x1, y2), Vector3f(0.0f, 0.0f, 1.0f)
+ };
+
+
+ UInt16 startIndex = GetNextVertexIndex();
+
+ enum
+ {
+ CubeVertexCount = sizeof(CubeVertices) / sizeof(CubeVertices[0]),
+ CubeIndexCount = sizeof(CubeIndices) / sizeof(CubeIndices[0])
+ };
+
+ for(int v = 0; v < CubeVertexCount; v++)
+ {
+ AddVertex(Vertex(CubeVertices[v][0], c, CubeVertices[v][1].x, CubeVertices[v][1].y, CubeVertices[v][2]));
+ }
+
+ // Renumber indices
+ for(int i = 0; i < CubeIndexCount / 3; i++)
+ {
+ AddTriangle(CubeIndices[i * 3] + startIndex,
+ CubeIndices[i * 3 + 1] + startIndex,
+ CubeIndices[i * 3 + 2] + startIndex);
+ }
+ }
+
+ // Adds box at specified location to current vertices.
+ void Model::AddBox(Color c, Vector3f origin, Vector3f size)
+ {
+ Vector3f s = size * 0.5f;
+ Vector3f o = origin;
+ UInt16 i = GetNextVertexIndex();
+
+ AddVertex(-s.x + o.x, s.y + o.y, -s.z + o.z, c, 0, 1, 0, 0, -1);
+ AddVertex(s.x + o.x, s.y + o.y, -s.z + o.z, c, 1, 1, 0, 0, -1);
+ AddVertex(s.x + o.x, -s.y + o.y, -s.z + o.z, c, 1, 0, 0, 0, -1);
+ AddVertex(-s.x + o.x, -s.y + o.y, -s.z + o.z, c, 0, 0, 0, 0, -1);
+ AddTriangle(2 + i, 1 + i, 0 + i);
+ AddTriangle(0 + i, 3 + i, 2 + i);
+
+ AddVertex(s.x + o.x, s.y + o.y, s.z + o.z, c, 1, 1, 0, 0, 1);
+ AddVertex(-s.x+ o.x, s.y + o.y, s.z + o.z, c, 0, 1, 0, 0, 1);
+ AddVertex(-s.x+ o.x, -s.y + o.y, s.z + o.z, c, 0, 0, 0, 0, 1);
+ AddVertex(s.x + o.x, -s.y + o.y, s.z + o.z, c, 1, 0, 0, 0, 1);
+ AddTriangle(6 + i, 5 + i, 4 + i);
+ AddTriangle(4 + i, 7 + i, 6 + i);
+
+ AddVertex(-s.x + o.x, s.y + o.y, -s.z + o.z, c, 1, 0, -1, 0, 0);
+ AddVertex(-s.x + o.x, s.y + o.y, s.z + o.z, c, 1, 1, -1, 0, 0);
+ AddVertex(-s.x + o.x, -s.y + o.y, s.z + o.z, c, 0, 1, -1, 0, 0);
+ AddVertex(-s.x + o.x, -s.y + o.y, -s.z + o.z, c, 0, 0, -1, 0, 0);
+ AddTriangle(10 + i, 11 + i, 8 + i);
+ AddTriangle(8 + i, 9 + i, 10 + i);
+
+ AddVertex(s.x + o.x, s.y + o.y, -s.z + o.z, c, 1, 0, 1, 0, 0);
+ AddVertex(s.x + o.x, -s.y + o.y, -s.z + o.z, c, 0, 0, 1, 0, 0);
+ AddVertex(s.x + o.x, -s.y + o.y, s.z + o.z, c, 0, 1, 1, 0, 0);
+ AddVertex(s.x + o.x, s.y + o.y, s.z + o.z, c, 1, 1, 1, 0, 0);
+ AddTriangle(14 + i, 15 + i, 12 + i);
+ AddTriangle(12 + i, 13 + i, 14 + i);
+
+ AddVertex(-s.x+ o.x, -s.y + o.y, s.z + o.z, c, 0, 1, 0, -1, 0);
+ AddVertex(s.x + o.x, -s.y + o.y, s.z + o.z, c, 1, 1, 0, -1, 0);
+ AddVertex(s.x + o.x, -s.y + o.y, -s.z + o.z, c, 1, 0, 0, -1, 0);
+ AddVertex(-s.x+ o.x, -s.y + o.y, -s.z + o.z, c, 0, 0, 0, -1, 0);
+ AddTriangle(18 + i, 19 + i, 16 + i);
+ AddTriangle(16 + i, 17 + i, 18 + i);
+
+ AddVertex(-s.x + o.x, s.y + o.y, -s.z + o.z, c, 0, 0, 0, 1, 0);
+ AddVertex(s.x + o.x, s.y + o.y, -s.z + o.z, c, 1, 0, 0, 1, 0);
+ AddVertex(s.x + o.x, s.y + o.y, s.z + o.z, c, 1, 1, 0, 1, 0);
+ AddVertex(-s.x + o.x, s.y + o.y, s.z + o.z, c, 0, 1, 0, 1, 0);
+ AddTriangle(20 + i, 21 + i, 22 + i);
+ AddTriangle(22 + i, 23 + i, 20 + i);
+ }
+
+
+ Model* Model::CreateBox(Color c, Vector3f origin, Vector3f size)
+ {
+ Model *box = new Model();
+ box->AddBox(c, Vector3f(0), size);
+ box->SetPosition(origin);
+ return box;
+ }
+
+ // Triangulation of a cylinder centered at the origin
+ Model* Model::CreateCylinder(Color color, Vector3f origin, float height, float radius, int sides)
+ {
+ Model *cyl = new Model();
+ float halfht = height * 0.5f;
+ for(UInt16 i = 0; i < sides; i++)
+ {
+ float x = cosf(Math<float>::TwoPi * i / float(sides));
+ float y = sinf(Math<float>::TwoPi * i / float(sides));
+
+ cyl->AddVertex(radius * x, radius * y, halfht, color, x + 1, y, 0, 0, 1);
+ cyl->AddVertex(radius * x, radius * y, -1.0f*halfht, color, x, y, 0, 0, -1);
+
+ UInt16 j = 0;
+ if(i < sides - 1)
+ {
+ j = i + 1;
+ cyl->AddTriangle(0, i * 4 + 4, i * 4);
+ cyl->AddTriangle(1, i * 4 + 1, i * 4 + 5);
+ }
+
+ float nx = cosf(Math<float>::Pi * (0.5f + 2.0f * i / float(sides)));
+ float ny = sinf(Math<float>::Pi * (0.5f + 2.0f * i / float(sides)));
+ cyl->AddVertex(radius * x, radius * y, halfht, color, x + 1, y, nx, ny, 0);
+ cyl->AddVertex(radius * x, radius * y, -1.0f*halfht, color, x, y, nx, ny, 0);
+
+ cyl->AddTriangle(i * 4 + 2, j * 4 + 2, i * 4 + 3);
+ cyl->AddTriangle(i * 4 + 3, j * 4 + 2, j * 4 + 3);
+ }
+ cyl->SetPosition(origin);
+ return cyl;
+ };
+
+ //Triangulation of a cone centered at the origin
+ Model* Model::CreateCone(Color color, Vector3f origin, float height, float radius, int sides)
+ {
+ Model *cone = new Model();
+ float halfht = height * 0.5f;
+ cone->AddVertex(0.0f, 0.0f, -1.0f*halfht, color, 0, 0, 0, 0, -1);
+
+ for(UInt16 i = 0; i < sides; i++)
+ {
+ float x = cosf(Math<float>::TwoPi * i / float(sides));
+ float y = sinf(Math<float>::TwoPi * i / float(sides));
+
+ cone->AddVertex(radius * x, radius * y, -1.0f*halfht, color, 0, 0, 0, 0, -1);
+
+ UInt16 j = 1;
+ if(i < sides - 1)
+ {
+ j = i + 1;
+ }
+
+ float next_x = cosf(Math<float>::TwoPi * j / float(sides));
+ float next_y = sinf(Math<float>::TwoPi * j / float(sides));
+
+ Vector3f normal = Vector3f(x, y, -halfht).Cross(Vector3f(next_x, next_y, -halfht));
+
+ cone->AddVertex(0.0f, 0.0f, halfht, color, 1, 0, normal.x, normal.y, normal.z);
+ cone->AddVertex(radius * x, radius * y, -1.0f*halfht, color, 0, 0, normal.x, normal.y, normal.z);
+
+ cone->AddTriangle(0, 3*i + 1, 3*j + 1);
+ cone->AddTriangle(3*i + 2, 3*j + 3, 3*i + 3);
+ }
+ cone->SetPosition(origin);
+ return cone;
+ };
+
+ //Triangulation of a sphere centered at the origin
+ Model* Model::CreateSphere(Color color, Vector3f origin, float radius, int sides)
+ {
+ Model *sphere = new Model();
+ UInt16 usides = (UInt16) sides;
+ UInt16 halfsides = usides/2;
+
+ for(UInt16 k = 0; k < halfsides; k++) {
+
+ float z = cosf(Math<float>::Pi * k / float(halfsides));
+ float z_r = sinf(Math<float>::Pi * k / float(halfsides)); // the radius of the cross circle with coordinate z
+
+ if (k == 0)
+ { // add north and south poles
+ sphere->AddVertex(0.0f, 0.0f, radius, color, 0, 0, 0, 0, 1);
+ sphere->AddVertex(0.0f, 0.0f, -radius, color, 1, 1, 0, 0, -1);
+ }
+ else
+ {
+ for(UInt16 i = 0; i < sides; i++)
+ {
+ float x = cosf(Math<float>::TwoPi * i / float(sides)) * z_r;
+ float y = sinf(Math<float>::TwoPi * i / float(sides)) * z_r;
- Matrix4f m = Matrix4f(size / font->lineheight, 0, 0, 0,
- 0, size / font->lineheight, 0, 0,
- 0, 0, 0, 0,
- x, y, 0, 1).Transposed();
+ UInt16 j = 0;
+ if(i < sides - 1)
+ {
+ j = i + 1;
+ }
- float xp = 0, yp = (float)font->ascent;
- int ivertex = 0;
+ sphere->AddVertex(radius * x, radius * y, radius * z, color, 0, 1, x, y, z);
- for (UPInt i = 0; i < length; i++)
- {
- if(str[i] == '\n')
- {
- yp += font->lineheight;
- xp = 0;
- continue;
- }
- // Tab followed by a numbers sets position to specified offset.
- if(str[i] == '\t')
- {
- char *p = 0;
- float tabPixels = (float)OVR_strtoq(str + i + 1, &p, 10);
- i += p - (str + i + 1);
- xp = tabPixels;
- continue;
- }
-
- const Font::Char* ch = &font->chars[str[i]];
- Vertex* chv = &vertices[ivertex];
- for(int j = 0; j < 6; j++)
- {
- chv[j].C = c;
- }
- float x = xp + ch->x;
- float y = yp - ch->y;
- float cx = font->twidth * (ch->u2 - ch->u1);
- float cy = font->theight * (ch->v2 - ch->v1);
- chv[0] = Vertex(Vector3f(x, y, 0), c, ch->u1, ch->v1);
- chv[1] = Vertex(Vector3f(x + cx, y, 0), c, ch->u2, ch->v1);
- chv[2] = Vertex(Vector3f(x + cx, cy + y, 0), c, ch->u2, ch->v2);
- chv[3] = Vertex(Vector3f(x, y, 0), c, ch->u1, ch->v1);
- chv[4] = Vertex(Vector3f(x + cx, cy + y, 0), c, ch->u2, ch->v2);
- chv[5] = Vertex(Vector3f(x, y + cy, 0), c, ch->u1, ch->v2);
- ivertex += 6;
-
- xp += ch->advance;
- }
-
- pTextVertexBuffer->Unmap(vertices);
+ UInt16 indi = 2 + (k -1)*usides + i;
+ UInt16 indj = 2 + (k -1)*usides + j;
+ if (k == 1) // NorthPole
+ sphere->AddTriangle(0, j + 2, i + 2);
+ else if (k == halfsides - 1) //SouthPole
+ {
+ sphere->AddTriangle(1, indi, indj);
+ sphere->AddTriangle(indi, indi - usides, indj);
+ sphere->AddTriangle(indi - usides, indj - usides, indj);
+ }
+ else
+ {
+ sphere->AddTriangle(indi, indi - usides, indj);
+ sphere->AddTriangle(indi - usides, indj - usides, indj);
+ }
+ }
+ } // end else
+ }
+ sphere->SetPosition(origin);
+ return sphere;
+ };
- Render(font->fill, pTextVertexBuffer, NULL, m, 0, ivertex, Prim_Triangles);
-}
+ Model* Model::CreateGrid(Vector3f origin, Vector3f stepx, Vector3f stepy,
+ int halfx, int halfy, int nmajor, Color minor, Color major)
+ {
+ Model* grid = new Model(Prim_Lines);
+ float halfxf = (float)halfx;
+ float halfyf = (float)halfy;
-void RenderDevice::FillRect(float left, float top, float right, float bottom, Color c)
-{
- if(!pTextVertexBuffer)
- {
- pTextVertexBuffer = *CreateBuffer();
- if(!pTextVertexBuffer)
- {
- return;
- }
- }
+ for(int jn = 0; jn <= halfy; jn++)
+ {
+ float j = (float)jn;
- // Get!!
- Fill* fill = CreateSimpleFill();
+ grid->AddLine(grid->AddVertex((stepx * -halfxf) + (stepy * j), (jn % nmajor) ? minor : major, 0, 0.5f),
+ grid->AddVertex((stepx * halfxf) + (stepy * j), (jn % nmajor) ? minor : major, 1, 0.5f));
- pTextVertexBuffer->Data(Buffer_Vertex, NULL, 6 * sizeof(Vertex));
- Vertex* vertices = (Vertex*)pTextVertexBuffer->Map(0, 6 * sizeof(Vertex), Map_Discard);
- if(!vertices)
- {
- return;
- }
+ if(j)
+ grid->AddLine(grid->AddVertex((stepx * -halfxf) + (stepy * -j), (jn % nmajor) ? minor : major, 0, 0.5f),
+ grid->AddVertex((stepx * halfxf) + (stepy * -j), (jn % nmajor) ? minor : major, 1, 0.5f));
+ }
- vertices[0] = Vertex(Vector3f(left, top, 0.0f), c);
- vertices[1] = Vertex(Vector3f(right, top, 0), c);
- vertices[2] = Vertex(Vector3f(left, bottom, 0), c);
- vertices[3] = Vertex(Vector3f(left, bottom, 0), c);
- vertices[4] = Vertex(Vector3f(right, top, 0), c);
- vertices[5] = Vertex(Vector3f(right, bottom, 0), c);
+ for(int in = 0; in <= halfx; in++)
+ {
+ float i = (float)in;
- pTextVertexBuffer->Unmap(vertices);
+ grid->AddLine(grid->AddVertex((stepx * i) + (stepy * -halfyf), (in % nmajor) ? minor : major, 0, 0.5f),
+ grid->AddVertex((stepx * i) + (stepy * halfyf), (in % nmajor) ? minor : major, 1, 0.5f));
- Render(fill, pTextVertexBuffer, NULL, Matrix4f(), 0, 6, Prim_Triangles);
-}
+ if(i)
+ grid->AddLine(grid->AddVertex((stepx * -i) + (stepy * -halfyf), (in % nmajor) ? minor : major, 0, 0.5f),
+ grid->AddVertex((stepx * -i) + (stepy * halfyf), (in % nmajor) ? minor : major, 1, 0.5f));
+ }
-void RenderDevice::FillGradientRect(float left, float top, float right, float bottom, Color col_top, Color col_btm)
-{
- if(!pTextVertexBuffer)
- {
- pTextVertexBuffer = *CreateBuffer();
- if(!pTextVertexBuffer)
- {
- return;
- }
- }
+ grid->SetPosition(origin);
+ return grid;
+ }
- // Get!!
- Fill* fill = CreateSimpleFill();
- pTextVertexBuffer->Data(Buffer_Vertex, NULL, 6 * sizeof(Vertex));
- Vertex* vertices = (Vertex*)pTextVertexBuffer->Map(0, 6 * sizeof(Vertex), Map_Discard);
- if(!vertices)
- {
- return;
- }
+ //-------------------------------------------------------------------------------------
- vertices[0] = Vertex(Vector3f(left, top, 0.0f), col_top);
- vertices[1] = Vertex(Vector3f(right, top, 0), col_top);
- vertices[2] = Vertex(Vector3f(left, bottom, 0), col_btm);
- vertices[3] = Vertex(Vector3f(left, bottom, 0), col_btm);
- vertices[4] = Vertex(Vector3f(right, top, 0), col_top);
- vertices[5] = Vertex(Vector3f(right, bottom, 0), col_btm);
-
- pTextVertexBuffer->Unmap(vertices);
-
- Render(fill, pTextVertexBuffer, NULL, Matrix4f(), 0, 6, Prim_Triangles);
-}
-
-void RenderDevice::RenderImage(float left,
- float top,
- float right,
- float bottom,
- ShaderFill* image,
- unsigned char alpha)
-{
- /*
- if(!pTextVertexBuffer)
- {
- pTextVertexBuffer = *CreateBuffer();
- if(!pTextVertexBuffer)
- {
- return;
- }
- }
- pTextVertexBuffer->Data(Buffer_Vertex, NULL, 6 * sizeof(Vertex));
- Vertex* vertices = (Vertex*)pTextVertexBuffer->Map(0, 6 * sizeof(Vertex), Map_Discard);
- if(!vertices)
- {
- return;
- }
+ void ShaderFill::Set(PrimitiveType prim) const
+ {
+ Shaders->Set(prim);
- vertices[0] = Vertex(Vector3f(left, top, 0.0f), Color(255, 255, 255, 255));
- vertices[1] = Vertex(Vector3f(right, top, 0), Color(255, 255, 255, 255));
- vertices[2] = Vertex(Vector3f(left, bottom, 0), Color(255, 255, 255, 255));
- vertices[3] = Vertex(Vector3f(left, bottom, 0), Color(255, 255, 255, 255));
- vertices[4] = Vertex(Vector3f(right, top, 0), Color(255, 255, 255, 255));
- vertices[5] = Vertex(Vector3f(right, bottom, 0), Color(255, 255, 255, 255));
-
- pTextVertexBuffer->Unmap(vertices);
-
- Render(image, pTextVertexBuffer, NULL, Matrix4f(), 0, 6, Prim_Triangles);
- */
-
- Color c = Color(255, 255, 255, alpha);
- Ptr<Model> m = *new Model(Prim_Triangles);
- m->AddVertex(left, bottom, 0.0f, c, 0.0f, 0.0f);
- m->AddVertex(right, bottom, 0.0f, c, 1.0f, 0.0f);
- m->AddVertex(right, top, 0.0f, c, 1.0f, 1.0f);
- m->AddVertex(left, top, 0.0f, c, 0.0f, 1.0f);
- m->AddTriangle(2,1,0);
- m->AddTriangle(0,3,2);
- m->Fill = image;
-
- Render(Matrix4f(), m);
-}
-
-/*
-void RenderDevice::GetStereoViewports(const Viewport& in, Viewport* out) const
-{
- out[0] = out[1] = in;
- if (StereoBufferMode == Stereo_SplitH)
- {
- out[0].w = out[1].w = in.w / 2;
- out[1].x += WindowWidth / 2;
- }
-}
-*/
+ for(int i = 0; i < 8 && VtxTextures[i] != NULL; ++i)
+ VtxTextures[i]->Set(i, Shader_Vertex);
-void RenderDevice::SetSceneRenderScale(float ss)
-{
- SceneRenderScale = ss;
- pSceneColorTex = NULL;
-}
+ for (int i = 0; i < 8 && Textures[i] != NULL; ++i)
+ Textures[i]->Set(i);
+ }
-void RenderDevice::SetViewport(const Viewport& vp)
-{
- VP = vp;
- if(CurPostProcess == PostProcess_Distortion)
- {
- Viewport svp = vp;
- svp.w = (int)ceil(SceneRenderScale * vp.w);
- svp.h = (int)ceil(SceneRenderScale * vp.h);
- svp.x = (int)ceil(SceneRenderScale * vp.x);
- svp.y = (int)ceil(SceneRenderScale * vp.y);
- SetRealViewport(svp);
- }
- else
- {
- SetRealViewport(vp);
- }
-}
+ //-------------------------------------------------------------------------------------
+ // ***** Rendering
-bool RenderDevice::initPostProcessSupport(PostProcessType pptype)
-{
- if(pptype != PostProcess_Distortion)
- {
- return true;
- }
+ RenderDevice::RenderDevice()
+ : DistortionClearColor(0, 0, 0),
+ TotalTextureMemoryUsage(0),
+ FadeOutBorderFraction(0)
+ {
+ // Ensure these are different, so that the first time it's run, things actually get initialized.
+ PostProcessShaderActive = PostProcessShader_Count;
+ PostProcessShaderRequested = PostProcessShader_DistortionAndChromAb;
+ }
- if (PostProcessShaderRequested != PostProcessShaderActive)
+ void RenderDevice::Shutdown()
{
+ // This runs before the subclass's Shutdown(), where the context, etc, may be deleted.
+ pTextVertexBuffer.Clear();
pPostProcessShader.Clear();
- PostProcessShaderActive = PostProcessShaderRequested;
- }
-
- if (!pPostProcessShader)
- {
- Shader *vs = LoadBuiltinShader(Shader_Vertex, VShader_PostProcess);
-
- Shader *ppfs = NULL;
-
- if (PostProcessShaderActive == PostProcessShader_Distortion)
- {
- ppfs = LoadBuiltinShader(Shader_Fragment, FShader_PostProcess);
- }
- else if (PostProcessShaderActive == PostProcessShader_DistortionAndChromAb)
- {
- ppfs = LoadBuiltinShader(Shader_Fragment, FShader_PostProcessWithChromAb);
- }
- else
- OVR_ASSERT(false);
-
- pPostProcessShader = *CreateShaderSet();
- pPostProcessShader->SetShader(vs);
- pPostProcessShader->SetShader(ppfs);
- }
-
-
- int texw = (int)ceil(SceneRenderScale * WindowWidth),
- texh = (int)ceil(SceneRenderScale * WindowHeight);
-
- // If pSceneColorTex is already created and is of correct size, we are done.
- // It's important to check width/height in case window size changed.
- if (pSceneColorTex && (texw == SceneColorTexW) && (texh == SceneColorTexH))
- {
- return true;
- }
-
- pSceneColorTex = *CreateTexture(Texture_RGBA | Texture_RenderTarget | Params.Multisample,
- texw, texh, NULL);
- if(!pSceneColorTex)
- {
- return false;
- }
- SceneColorTexW = texw;
- SceneColorTexH = texh;
- pSceneColorTex->SetSampleMode(Sample_ClampBorder | Sample_Linear);
-
-
- if(!pFullScreenVertexBuffer)
- {
- pFullScreenVertexBuffer = *CreateBuffer();
- const Render::Vertex QuadVertices[] =
- {
- Vertex(Vector3f(0, 1, 0), Color(1, 1, 1, 1), 0, 0),
- Vertex(Vector3f(1, 1, 0), Color(1, 1, 1, 1), 1, 0),
- Vertex(Vector3f(0, 0, 0), Color(1, 1, 1, 1), 0, 1),
- Vertex(Vector3f(1, 0, 0), Color(1, 1, 1, 1), 1, 1)
- };
- pFullScreenVertexBuffer->Data(Buffer_Vertex, QuadVertices, sizeof(QuadVertices));
+ pFullScreenVertexBuffer.Clear();
+ pDistortionMeshVertexBuffer[0].Clear();
+ pDistortionMeshVertexBuffer[1].Clear();
+ pDistortionMeshIndexBuffer[0].Clear();
+ pDistortionMeshIndexBuffer[1].Clear();
+ LightingBuffer.Clear();
}
- return true;
-}
-
-void RenderDevice::SetProjection(const Matrix4f& proj)
-{
- Proj = proj;
- SetWorldUniforms(proj);
-}
-
-void RenderDevice::BeginScene(PostProcessType pptype)
-{
- BeginRendering();
-
- if((pptype != PostProcess_None) && initPostProcessSupport(pptype))
- {
- CurPostProcess = pptype;
- }
- else
- {
- CurPostProcess = PostProcess_None;
- }
-
- if(CurPostProcess == PostProcess_Distortion)
- {
- SetRenderTarget(pSceneColorTex);
- SetViewport(VP);
- }
- else
- {
- SetRenderTarget(0);
- }
-
- SetWorldUniforms(Proj);
- SetExtraShaders(NULL);
-}
-
-void RenderDevice::FinishScene()
-{
- SetExtraShaders(0);
- if(CurPostProcess == PostProcess_None)
- {
- return;
- }
-
- SetRenderTarget(0);
- SetRealViewport(VP);
- FinishScene1();
-
- CurPostProcess = PostProcess_None;
-}
-
+ Fill* RenderDevice::CreateTextureFill(Render::Texture* t, bool useAlpha)
+ {
+ ShaderSet* shaders = CreateShaderSet();
+ shaders->SetShader(LoadBuiltinShader(Shader_Vertex, VShader_MVP));
+ shaders->SetShader(LoadBuiltinShader(Shader_Fragment, useAlpha ? FShader_AlphaTexture : FShader_Texture));
+ Fill* f = new ShaderFill(*shaders);
+ f->SetTexture(0, t);
+ return f;
+ }
+
+ void LightingParams::Set(ShaderSet* s) const
+ {
+ s->SetUniform4fvArray("Ambient", 1, &Ambient);
+ s->SetUniform1f("LightCount", LightCount);
+ s->SetUniform4fvArray("LightPos", (int)LightCount, LightPos);
+ s->SetUniform4fvArray("LightColor", (int)LightCount, LightColor);
+ }
+
+ void RenderDevice::SetLighting(const LightingParams* lt)
+ {
+ if (!LightingBuffer)
+ LightingBuffer = *CreateBuffer();
+
+ LightingBuffer->Data(Buffer_Uniform, lt, sizeof(LightingParams));
+ SetCommonUniformBuffer(1, LightingBuffer);
+ }
+
+ float RenderDevice::MeasureText(const Font* font, const char* str, float size, float strsize[2],
+ const UPInt charRange[2], Vector2f charRangeRect[2])
+ {
+ UPInt length = strlen(str);
+ float w = 0;
+ float xp = 0;
+ float yp = 0;
+
+ for (UPInt i = 0; i < length; i++)
+ {
+ if (str[i] == '\n')
+ {
+ yp += font->lineheight;
+ if(xp > w)
+ {
+ w = xp;
+ }
+ xp = 0;
+ continue;
+ }
+
+ // Record top-left charRange rectangle coordinate.
+ if (charRange && charRangeRect && (i == charRange[0]))
+ charRangeRect[0] = Vector2f(xp, yp);
+
+ // Tab followed by a numbers sets position to specified offset.
+ if (str[i] == '\t')
+ {
+ char *p = 0;
+ float tabPixels = (float)OVR_strtoq(str + i + 1, &p, 10);
+ i += p - (str + i + 1);
+ xp = tabPixels;
+ }
+ else
+ {
+ const Font::Char* ch = &font->chars[str[i]];
+ xp += ch->advance;
+ }
+
+ // End of character range.
+ // Store 'xp' after advance, yp will advance later.
+ if (charRange && charRangeRect && (i == charRange[1]))
+ charRangeRect[1] = Vector2f(xp, yp);
+ }
+
+ if (xp > w)
+ {
+ w = xp;
+ }
+
+ float scale = (size / font->lineheight);
+
+ if (strsize)
+ {
+ strsize[0] = scale * w;
+ strsize[1] = scale * (yp + font->lineheight);
+ }
+
+ if (charRange && charRangeRect)
+ {
+ // Selection rectangle ends in teh bottom.
+ charRangeRect[1].y += font->lineheight;
+ charRangeRect[0] *= scale;
+ charRangeRect[1] *= scale;
+ }
+
+ return (size / font->lineheight) * w;
+ }
+
+
+
+
+
+ void RenderDevice::RenderText(const Font* font, const char* str,
+ float x, float y, float size, Color c)
+ {
+ if(!pTextVertexBuffer)
+ {
+ pTextVertexBuffer = *CreateBuffer();
+ if(!pTextVertexBuffer)
+ {
+ return;
+ }
+ }
+
+ if(!font->fill)
+ {
+ font->fill = CreateTextureFill(Ptr<Texture>(
+ *CreateTexture(Texture_R, font->twidth, font->theight, font->tex)), true);
+ }
+
+ UPInt length = strlen(str);
+
+ pTextVertexBuffer->Data(Buffer_Vertex, NULL, length * 6 * sizeof(Vertex));
+ Vertex* vertices = (Vertex*)pTextVertexBuffer->Map(0, length * 6 * sizeof(Vertex), Map_Discard);
+ if(!vertices)
+ {
+ return;
+ }
+
+ Matrix4f m = Matrix4f(size / font->lineheight, 0, 0, 0,
+ 0, size / font->lineheight, 0, 0,
+ 0, 0, 0, 0,
+ x, y, 0, 1).Transposed();
+
+ float xp = 0, yp = (float)font->ascent;
+ int ivertex = 0;
+
+ for (UPInt i = 0; i < length; i++)
+ {
+ if(str[i] == '\n')
+ {
+ yp += font->lineheight;
+ xp = 0;
+ continue;
+ }
+ // Tab followed by a numbers sets position to specified offset.
+ if(str[i] == '\t')
+ {
+ char *p = 0;
+ float tabPixels = (float)OVR_strtoq(str + i + 1, &p, 10);
+ i += p - (str + i + 1);
+ xp = tabPixels;
+ continue;
+ }
+
+ const Font::Char* ch = &font->chars[str[i]];
+ Vertex* chv = &vertices[ivertex];
+ for(int j = 0; j < 6; j++)
+ {
+ chv[j].C = c;
+ }
+ float x = xp + ch->x;
+ float y = yp - ch->y;
+ float cx = font->twidth * (ch->u2 - ch->u1);
+ float cy = font->theight * (ch->v2 - ch->v1);
+ chv[0] = Vertex(Vector3f(x, y, 0), c, ch->u1, ch->v1);
+ chv[1] = Vertex(Vector3f(x + cx, y, 0), c, ch->u2, ch->v1);
+ chv[2] = Vertex(Vector3f(x + cx, cy + y, 0), c, ch->u2, ch->v2);
+ chv[3] = Vertex(Vector3f(x, y, 0), c, ch->u1, ch->v1);
+ chv[4] = Vertex(Vector3f(x + cx, cy + y, 0), c, ch->u2, ch->v2);
+ chv[5] = Vertex(Vector3f(x, y + cy, 0), c, ch->u1, ch->v2);
+ ivertex += 6;
+
+ xp += ch->advance;
+ }
+
+ pTextVertexBuffer->Unmap(vertices);
+
+ Render(font->fill, pTextVertexBuffer, NULL, m, 0, ivertex, Prim_Triangles);
+ }
+
+ void RenderDevice::FillRect(float left, float top, float right, float bottom, Color c)
+ {
+ if(!pTextVertexBuffer)
+ {
+ pTextVertexBuffer = *CreateBuffer();
+ if(!pTextVertexBuffer)
+ {
+ return;
+ }
+ }
+
+ // Get!!
+ Fill* fill = CreateSimpleFill();
+
+ pTextVertexBuffer->Data(Buffer_Vertex, NULL, 6 * sizeof(Vertex));
+ Vertex* vertices = (Vertex*)pTextVertexBuffer->Map(0, 6 * sizeof(Vertex), Map_Discard);
+ if(!vertices)
+ {
+ return;
+ }
+
+ vertices[0] = Vertex(Vector3f(left, top, 0.0f), c);
+ vertices[1] = Vertex(Vector3f(right, top, 0.0f), c);
+ vertices[2] = Vertex(Vector3f(left, bottom, 0.0f), c);
+ vertices[3] = Vertex(Vector3f(left, bottom, 0.0f), c);
+ vertices[4] = Vertex(Vector3f(right, top, 0.0f), c);
+ vertices[5] = Vertex(Vector3f(right, bottom, 0.0f), c);
+
+ pTextVertexBuffer->Unmap(vertices);
+
+ Render(fill, pTextVertexBuffer, NULL, Matrix4f(), 0, 6, Prim_Triangles);
+ }
+
+
+
+ void RenderDevice::FillGradientRect(float left, float top, float right, float bottom, Color col_top, Color col_btm)
+ {
+ if(!pTextVertexBuffer)
+ {
+ pTextVertexBuffer = *CreateBuffer();
+ if(!pTextVertexBuffer)
+ {
+ return;
+ }
+ }
+
+ // Get!!
+ Fill* fill = CreateSimpleFill();
+
+ pTextVertexBuffer->Data(Buffer_Vertex, NULL, 6 * sizeof(Vertex));
+ Vertex* vertices = (Vertex*)pTextVertexBuffer->Map(0, 6 * sizeof(Vertex), Map_Discard);
+ if(!vertices)
+ {
+ return;
+ }
+
+ vertices[0] = Vertex(Vector3f(left, top, 0.0f), col_top);
+ vertices[1] = Vertex(Vector3f(right, top, 0.0f), col_top);
+ vertices[2] = Vertex(Vector3f(left, bottom, 0.0f), col_btm);
+ vertices[3] = Vertex(Vector3f(left, bottom, 0.0f), col_btm);
+ vertices[4] = Vertex(Vector3f(right, top, 0.0f), col_top);
+ vertices[5] = Vertex(Vector3f(right, bottom, 0.0f), col_btm);
+
+ pTextVertexBuffer->Unmap(vertices);
+
+ Render(fill, pTextVertexBuffer, NULL, Matrix4f(), 0, 6, Prim_Triangles);
+ }
+
+
+ void RenderDevice::FillTexturedRect(float left, float top, float right, float bottom, float ul, float vt, float ur, float vb, Color c, Ptr<Texture> tex)
+ {
+ if(!pTextVertexBuffer)
+ {
+ pTextVertexBuffer = *CreateBuffer();
+ if(!pTextVertexBuffer)
+ {
+ return;
+ }
+ }
+
+ static Fill *fill = NULL;
+ if ( fill == NULL )
+ {
+ fill = CreateTextureFill(tex, false);
+ }
+ fill->SetTexture ( 0, tex );
+
+ pTextVertexBuffer->Data(Buffer_Vertex, NULL, 6 * sizeof(Vertex));
+ Vertex* vertices = (Vertex*)pTextVertexBuffer->Map(0, 6 * sizeof(Vertex), Map_Discard);
+ if(!vertices)
+ {
+ return;
+ }
+
+ vertices[0] = Vertex(Vector3f(left, top, 0.0f), c, ul, vt);
+ vertices[1] = Vertex(Vector3f(right, top, 0.0f), c, ur, vt);
+ vertices[2] = Vertex(Vector3f(left, bottom, 0.0f), c, ul, vb);
+ vertices[3] = Vertex(Vector3f(left, bottom, 0.0f), c, ul, vb);
+ vertices[4] = Vertex(Vector3f(right, top, 0.0f), c, ur, vt);
+ vertices[5] = Vertex(Vector3f(right, bottom, 0.0f), c, ur, vb);
+
+ pTextVertexBuffer->Unmap(vertices);
+
+ Render(fill, pTextVertexBuffer, NULL, Matrix4f(), 0, 6, Prim_Triangles);
+ }
+
+
+ void RenderDevice::RenderLines ( int NumLines, Color c, float *x, float *y, float *z /*= NULL*/ )
+ {
+ OVR_ASSERT ( x != NULL );
+ OVR_ASSERT ( y != NULL );
+ // z can be NULL for 2D stuff.
+
+ if(!pTextVertexBuffer)
+ {
+ pTextVertexBuffer = *CreateBuffer();
+ if(!pTextVertexBuffer)
+ {
+ return;
+ }
+ }
+
+ // Get!!
+ Fill* fill = CreateSimpleFill();
+
+ int NumVerts = NumLines * 2;
+
+ pTextVertexBuffer->Data(Buffer_Vertex, NULL, NumVerts * sizeof(Vertex));
+ Vertex* vertices = (Vertex*)pTextVertexBuffer->Map(0, NumVerts * sizeof(Vertex), Map_Discard);
+ if(!vertices)
+ {
+ return;
+ }
+
+ if ( z != NULL )
+ {
+ for ( int VertNum = 0; VertNum < NumVerts; VertNum++ )
+ {
+ vertices[VertNum] = Vertex(Vector3f(x[VertNum], y[VertNum], z[VertNum]), c);
+ }
+ }
+ else
+ {
+ for ( int VertNum = 0; VertNum < NumVerts; VertNum++ )
+ {
+ vertices[VertNum] = Vertex(Vector3f(x[VertNum], y[VertNum], 1.0f), c);
+ }
+ }
+
+ pTextVertexBuffer->Unmap(vertices);
+
+ Render(fill, pTextVertexBuffer, NULL, Matrix4f(), 0, NumVerts, Prim_Lines);
+ }
+
+
+
+ void RenderDevice::RenderImage(float left,
+ float top,
+ float right,
+ float bottom,
+ ShaderFill* image,
+ unsigned char alpha)
+ {
+ Color c = Color(255, 255, 255, alpha);
+ Ptr<Model> m = *new Model(Prim_Triangles);
+ m->AddVertex(left, bottom, 0.0f, c, 0.0f, 0.0f);
+ m->AddVertex(right, bottom, 0.0f, c, 1.0f, 0.0f);
+ m->AddVertex(right, top, 0.0f, c, 1.0f, 1.0f);
+ m->AddVertex(left, top, 0.0f, c, 0.0f, 1.0f);
+ m->AddTriangle(2,1,0);
+ m->AddTriangle(0,3,2);
+ m->Fill = image;
+
+ Render(Matrix4f(), m);
+ }
+
+ bool RenderDevice::initPostProcessSupport(PostProcessType pptype)
+ {
+ if(pptype == PostProcess_None)
+ {
+ return true;
+ }
+
+
+ if (PostProcessShaderRequested != PostProcessShaderActive)
+ {
+ pPostProcessShader.Clear();
+ PostProcessShaderActive = PostProcessShaderRequested;
+ }
+
+ if (!pPostProcessShader)
+ {
+ Shader *vs = NULL;
+ Shader *ppfs = NULL;
+
+ if (PostProcessShaderActive == PostProcessShader_DistortionAndChromAb)
+ {
+ ppfs = LoadBuiltinShader(Shader_Fragment, FShader_PostProcessWithChromAb);
+ vs = LoadBuiltinShader(Shader_Vertex, VShader_PostProcess);
+ }
+ else if (PostProcessShaderActive == PostProcessShader_MeshDistortionAndChromAb)
+ {
+ ppfs = LoadBuiltinShader(Shader_Fragment, FShader_PostProcessMeshWithChromAb);
+ vs = LoadBuiltinShader(Shader_Vertex, VShader_PostProcessMesh);
+ }
+ else if (PostProcessShaderActive == PostProcessShader_MeshDistortionAndChromAbTimewarp)
+ {
+ ppfs = LoadBuiltinShader(Shader_Fragment, FShader_PostProcessMeshWithChromAbTimewarp);
+ vs = LoadBuiltinShader(Shader_Vertex, VShader_PostProcessMeshTimewarp);
+ }
+ else if (PostProcessShaderActive == PostProcessShader_MeshDistortionAndChromAbPositionalTimewarp)
+ {
+ ppfs = LoadBuiltinShader(Shader_Fragment, FShader_PostProcessMeshWithChromAbPositionalTimewarp);
+ vs = LoadBuiltinShader(Shader_Vertex, VShader_PostProcessMeshPositionalTimewarp);
+ }
+ else
+ {
+ OVR_ASSERT(false);
+ }
+ OVR_ASSERT(ppfs); // Means the shader failed to compile - look in the debug spew.
+ OVR_ASSERT(vs);
+
+ pPostProcessShader = *CreateShaderSet();
+ pPostProcessShader->SetShader(vs);
+ pPostProcessShader->SetShader(ppfs);
+ }
+
+
+ if(!pFullScreenVertexBuffer)
+ {
+ pFullScreenVertexBuffer = *CreateBuffer();
+ const Render::Vertex QuadVertices[] =
+ {
+ Vertex(Vector3f(0, 1, 0), Color(1, 1, 1, 1), 0, 0),
+ Vertex(Vector3f(1, 1, 0), Color(1, 1, 1, 1), 1, 0),
+ Vertex(Vector3f(0, 0, 0), Color(1, 1, 1, 1), 0, 1),
+ Vertex(Vector3f(1, 0, 0), Color(1, 1, 1, 1), 1, 1)
+ };
+ pFullScreenVertexBuffer->Data(Buffer_Vertex, QuadVertices, sizeof(QuadVertices));
+ }
+ return true;
+ }
+
+ void RenderDevice::SetProjection(const Matrix4f& proj)
+ {
+ Proj = proj;
+ SetWorldUniforms(proj);
+ }
+
+ void RenderDevice::BeginScene(PostProcessType pptype)
+ {
+ BeginRendering();
+ initPostProcessSupport(pptype);
+ SetViewport(VP);
+ SetWorldUniforms(Proj);
+ SetExtraShaders(NULL);
+ }
+
+ void RenderDevice::FinishScene()
+ {
+ SetExtraShaders(0);
+ SetRenderTarget(0);
+ }
+
+
+
+ void RenderDevice::PrecalculatePostProcess(PostProcessType pptype,
+ const StereoEyeParams &stereoParamsLeft, const StereoEyeParams &stereoParamsRight,
+ const HmdRenderInfo &hmdRenderInfo )
+ {
+ PostProcessingType = pptype;
+
+ if ( ( pptype == PostProcess_MeshDistortion ) ||
+ ( pptype == PostProcess_MeshDistortionTimewarp ) ||
+ ( pptype == PostProcess_MeshDistortionPositionalTimewarp ) )
+ {
+ for ( int eyeNum = 0; eyeNum < 2; eyeNum++ )
+ {
+ const StereoEyeParams &stereoParams = ( eyeNum == 0 ) ? stereoParamsLeft : stereoParamsRight;
+
+ // Get the mesh data.
+ int numVerts = 0;
+ int numTris = 0;
+ DistortionMeshVertexData *pRawVerts = NULL;
+ UInt16 *pIndices = NULL;
+ DistortionMeshCreate ( &pRawVerts, &pIndices, &numVerts, &numTris, stereoParams, hmdRenderInfo );
+ int numIndices = numTris * 3;
+
+ // Convert to final vertex data.
+ DistortionVertex *pVerts = (DistortionVertex*)OVR_ALLOC ( sizeof(DistortionVertex) * numVerts );
+ DistortionVertex *pCurVert = pVerts;
+ DistortionMeshVertexData *pCurRawVert = pRawVerts;
+ for ( int vertNum = 0; vertNum < numVerts; vertNum++ )
+ {
+ pCurVert->Pos.x = pCurRawVert->ScreenPosNDC.x;
+ pCurVert->Pos.y = pCurRawVert->ScreenPosNDC.y;
+ pCurVert->TexR = pCurRawVert->TanEyeAnglesR;
+ pCurVert->TexG = pCurRawVert->TanEyeAnglesG;
+ pCurVert->TexB = pCurRawVert->TanEyeAnglesB;
+ // Convert [0.0f,1.0f] to [0,255]
+ pCurVert->Col.R = (OVR::UByte)( floorf ( pCurRawVert->Shade * 255.999f ) );
+ pCurVert->Col.G = pCurVert->Col.R;
+ pCurVert->Col.B = pCurVert->Col.R;
+ pCurVert->Col.A = (OVR::UByte)( floorf ( pCurRawVert->TimewarpLerp * 255.999f ) );
+ pCurRawVert++;
+ pCurVert++;
+ }
-void RenderDevice::FinishScene1()
-{
- float r, g, b, a;
- DistortionClearColor.GetRGBA(&r, &g, &b, &a);
- Clear(r, g, b, a);
-
- float w = float(VP.w) / float(WindowWidth),
- h = float(VP.h) / float(WindowHeight),
- x = float(VP.x) / float(WindowWidth),
- y = float(VP.y) / float(WindowHeight);
-
- float as = float(VP.w) / float(VP.h);
-
- // We are using 1/4 of DistortionCenter offset value here, since it is
- // relative to [-1,1] range that gets mapped to [0, 0.5].
- pPostProcessShader->SetUniform2f("LensCenter",
- x + (w + Distortion.XCenterOffset * 0.5f)*0.5f, y + h*0.5f);
- pPostProcessShader->SetUniform2f("ScreenCenter", x + w*0.5f, y + h*0.5f);
-
- // MA: This is more correct but we would need higher-res texture vertically; we should adopt this
- // once we have asymmetric input texture scale.
- float scaleFactor = 1.0f / Distortion.Scale;
-
- pPostProcessShader->SetUniform2f("Scale", (w/2) * scaleFactor, (h/2) * scaleFactor * as);
- pPostProcessShader->SetUniform2f("ScaleIn", (2/w), (2/h) / as);
-
- pPostProcessShader->SetUniform4f("HmdWarpParam",
- Distortion.K[0], Distortion.K[1], Distortion.K[2], Distortion.K[3]);
-
- if (PostProcessShaderRequested == PostProcessShader_DistortionAndChromAb)
- {
- pPostProcessShader->SetUniform4f("ChromAbParam",
- Distortion.ChromaticAberration[0],
- Distortion.ChromaticAberration[1],
- Distortion.ChromaticAberration[2],
- Distortion.ChromaticAberration[3]);
- }
+ DistortionMeshNumTris[eyeNum] = numTris;
+ pDistortionMeshVertexBuffer[eyeNum] = *CreateBuffer();
+ pDistortionMeshVertexBuffer[eyeNum]->Data ( Buffer_Vertex, pVerts, sizeof(DistortionVertex) * numVerts );
+ pDistortionMeshIndexBuffer[eyeNum] = *CreateBuffer();
+ pDistortionMeshIndexBuffer[eyeNum]->Data ( Buffer_Index, pIndices, ( sizeof(UInt16) * numIndices ) );
+
+ DistortionMeshDestroy ( pRawVerts, pIndices );
+ OVR_FREE ( pVerts );
+ }
+ }
+ else
+ {
+ // ...no setup needed for other distortion types.
+ }
+ }
+
+
+ void RenderDevice::ApplyPostProcess(Matrix4f const &matNowFromWorldStart, Matrix4f const &matNowFromWorldEnd,
+ Matrix4f const &matRenderFromWorldLeft, Matrix4f const &matRenderFromWorldRight,
+ StereoEyeParams const &stereoParamsLeft, StereoEyeParams const &stereoParamsRight,
+ Ptr<Texture> pSourceTextureLeftOrOnly,
+ Ptr<Texture> pSourceTextureRight,
+ Ptr<Texture> pSourceTextureLeftOrOnlyDepth,
+ Ptr<Texture> pSourceTextureRightDepth)
+ {
+ SetExtraShaders(0);
+
+ if ( PostProcessingType == PostProcess_MeshDistortion )
+ {
+ Recti vp ( 0, 0, WindowWidth, WindowHeight );
+ SetViewport(vp);
+ float r, g, b, a;
+ DistortionClearColor.GetRGBA(&r, &g, &b, &a);
+ Clear(r, g, b, a);
+
+ Matrix4f dummy;
+ ShaderFill fill(pPostProcessShader);
+
+ fill.SetTexture ( 0, pSourceTextureLeftOrOnly );
+ pPostProcessShader->SetUniform2f("EyeToSourceUVScale", stereoParamsLeft.EyeToSourceUV.Scale.x, stereoParamsLeft.EyeToSourceUV.Scale.y );
+ pPostProcessShader->SetUniform2f("EyeToSourceUVOffset", stereoParamsLeft.EyeToSourceUV.Offset.x, stereoParamsLeft.EyeToSourceUV.Offset.y );
+ Render(&fill, pDistortionMeshVertexBuffer[0], pDistortionMeshIndexBuffer[0], dummy, 0, DistortionMeshNumTris[0] * 3, Prim_Triangles, true);
+
+ if ( pSourceTextureRight != NULL )
+ {
+ fill.SetTexture ( 0, pSourceTextureRight );
+ }
+ pPostProcessShader->SetUniform2f("EyeToSourceUVScale", stereoParamsRight.EyeToSourceUV.Scale.x, stereoParamsRight.EyeToSourceUV.Scale.y );
+ pPostProcessShader->SetUniform2f("EyeToSourceUVOffset", stereoParamsRight.EyeToSourceUV.Offset.x, stereoParamsRight.EyeToSourceUV.Offset.y );
+ Render(&fill, pDistortionMeshVertexBuffer[1], pDistortionMeshIndexBuffer[1], dummy, 0, DistortionMeshNumTris[1] * 3, Prim_Triangles, true);
+ }
+ else if ( PostProcessingType == PostProcess_MeshDistortionTimewarp )
+ {
+ Recti vp ( 0, 0, WindowWidth, WindowHeight );
+ SetViewport(vp);
+ float r, g, b, a;
+ DistortionClearColor.GetRGBA(&r, &g, &b, &a);
+ Clear(r, g, b, a);
+
+ ShaderFill fill(pPostProcessShader);
+ fill.SetTexture ( 0, pSourceTextureLeftOrOnly );
+
+ for ( int eyeNum = 0; eyeNum < 2; eyeNum++ )
+ {
+ Matrix4f const &matRenderFromWorld = ( eyeNum == 0 ) ? matRenderFromWorldLeft : matRenderFromWorldRight;
+ const StereoEyeParams &stereoParams = ( eyeNum == 0 ) ? stereoParamsLeft : stereoParamsRight;
+
+ Matrix4f matRenderFromNowStart = TimewarpComputePoseDelta ( matRenderFromWorld, matNowFromWorldStart );
+ Matrix4f matRenderFromNowEnd = TimewarpComputePoseDelta ( matRenderFromWorld, matNowFromWorldEnd );
+
+ pPostProcessShader->SetUniform2f("EyeToSourceUVScale", stereoParams.EyeToSourceUV.Scale.x, stereoParams.EyeToSourceUV.Scale.y );
+ pPostProcessShader->SetUniform2f("EyeToSourceUVOffset", stereoParams.EyeToSourceUV.Offset.x, stereoParams.EyeToSourceUV.Offset.y );
+ pPostProcessShader->SetUniform3x3f("EyeRotationStart", matRenderFromNowStart);
+ pPostProcessShader->SetUniform3x3f("EyeRotationEnd", matRenderFromNowEnd);
+
+ Matrix4f dummy;
+ if ( ( pSourceTextureRight != NULL ) && ( eyeNum == 1 ) )
+ {
+ fill.SetTexture ( 0, pSourceTextureRight );
+ }
+ Render(&fill, pDistortionMeshVertexBuffer[eyeNum], pDistortionMeshIndexBuffer[eyeNum], dummy, 0, DistortionMeshNumTris[eyeNum] * 3, Prim_Triangles, true);
+ }
+ }
+ else if ( PostProcessingType == PostProcess_MeshDistortionPositionalTimewarp )
+ {
+ Recti vp( 0, 0, WindowWidth, WindowHeight );
+ SetViewport(vp);
+ float r, g, b, a;
+ DistortionClearColor.GetRGBA(&r, &g, &b, &a);
+ Clear(r, g, b, a);
+
+ ShaderFill fill(pPostProcessShader);
+ fill.SetTexture ( 0, pSourceTextureLeftOrOnly );
+ fill.SetTexture ( 0, pSourceTextureLeftOrOnlyDepth, Shader_Vertex );
+
+ for ( int eyeNum = 0; eyeNum < 2; eyeNum++ )
+ {
+ Matrix4f const &matRenderFromWorld = ( eyeNum == 0 ) ? matRenderFromWorldLeft : matRenderFromWorldRight;
+ const StereoEyeParams &stereoParams = ( eyeNum == 0 ) ? stereoParamsLeft : stereoParamsRight;
+
+ Matrix4f matRenderFromNowStart = TimewarpComputePoseDelta ( matRenderFromWorld, matNowFromWorldStart );
+ Matrix4f matRenderFromNowEnd = TimewarpComputePoseDelta ( matRenderFromWorld, matNowFromWorldEnd );
+
+ pPostProcessShader->SetUniform2f("EyeToSourceUVScale", stereoParams.EyeToSourceUV.Scale.x, stereoParams.EyeToSourceUV.Scale.y );
+ pPostProcessShader->SetUniform2f("EyeToSourceUVOffset", stereoParams.EyeToSourceUV.Offset.x, stereoParams.EyeToSourceUV.Offset.y );
+
+ // DepthProjector values can also be calculated as:
+ // float DepthProjectorX = FarClip / (FarClip - NearClip);
+ // float DepthProjectorY = (-FarClip * NearClip) / (FarClip - NearClip);
+ pPostProcessShader->SetUniform2f("DepthProjector", -stereoParams.RenderedProjection.M[2][2], stereoParams.RenderedProjection.M[2][3]);
+ pPostProcessShader->SetUniform2f("DepthDimSize", (float)pSourceTextureLeftOrOnlyDepth->GetWidth(), (float)pSourceTextureLeftOrOnlyDepth->GetHeight());
+ pPostProcessShader->SetUniform4x4f("EyeRotationStart", matRenderFromNowStart);
+ pPostProcessShader->SetUniform4x4f("EyeRotationEnd", matRenderFromNowEnd);
+
+
+ Matrix4f dummy;
+ if ( ( pSourceTextureRight != NULL ) && ( eyeNum == 1 ) )
+ {
+ OVR_ASSERT(pSourceTextureRightDepth != NULL);
+ fill.SetTexture ( 0, pSourceTextureRight );
+ fill.SetTexture ( 0, pSourceTextureRightDepth, Shader_Vertex );
+ }
- Matrix4f texm(w, 0, 0, x,
- 0, h, 0, y,
- 0, 0, 0, 0,
- 0, 0, 0, 1);
- pPostProcessShader->SetUniform4x4f("Texm", texm);
-
- Matrix4f view(2, 0, 0, -1,
- 0, 2, 0, -1,
- 0, 0, 0, 0,
- 0, 0, 0, 1);
-
- ShaderFill fill(pPostProcessShader);
- fill.SetTexture(0, pSceneColorTex);
- RenderWithAlpha(&fill, pFullScreenVertexBuffer, NULL, view, 0, 4, Prim_TriangleStrip);
-}
-
-bool CollisionModel::TestPoint(const Vector3f& p) const
-{
- for(unsigned i = 0; i < Planes.GetSize(); i++)
- if(Planes[i].TestSide(p) > 0)
- {
- return 0;
- }
-
- return 1;
-}
-
-bool CollisionModel::TestRay(const Vector3f& origin, const Vector3f& norm, float& len, Planef* ph) const
-{
- if(TestPoint(origin))
- {
- len = 0;
- *ph = Planes[0];
- return true;
- }
- Vector3f fullMove = origin + norm * len;
+ Render(&fill, pDistortionMeshVertexBuffer[eyeNum], pDistortionMeshIndexBuffer[eyeNum], dummy, 0, DistortionMeshNumTris[eyeNum] * 3, Prim_Triangles, true);
+ }
+ }
+ else
+ {
+ if ( PostProcessingType == PostProcess_PixelDistortion )
+ {
+ float r, g, b, a;
+ DistortionClearColor.GetRGBA(&r, &g, &b, &a);
+ Clear(r, g, b, a);
+
+ for ( int eyeNum = 0; eyeNum < 2; eyeNum++ )
+ {
+ const StereoEyeParams &stereoParams = ( eyeNum == 0 ) ? stereoParamsLeft : stereoParamsRight;
+
+ // Always use the half-FB viewport, not the "current scene" VP which may be totally different.
+ SetViewport(stereoParams.DistortionViewport);
+
+ // TODO: precalc a bunch of things to make the shader faster.
+ // Note that the shader currently doesn't use Distortion.K[0], it hardwires it to 1.0.
+ pPostProcessShader->SetUniform4f("HmdWarpParam",
+ 1.0f,
+ stereoParams.Distortion.Lens.K[1],
+ stereoParams.Distortion.Lens.K[2],
+ stereoParams.Distortion.Lens.K[3]);
+ // We now only support one distortion type for shaders.
+ OVR_ASSERT ( stereoParams.Distortion.Lens.Eqn == Distortion_RecipPoly4 );
+
+ pPostProcessShader->SetUniform3f("DistortionClearColor",
+ DistortionClearColor.R,
+ DistortionClearColor.G,
+ DistortionClearColor.B );
+
+ // These are stored as deltas off the "main" distortion coefficients, but
+ // in the shader we use them as absolute values.
+ pPostProcessShader->SetUniform4f("ChromAbParam",
+ stereoParams.Distortion.Lens.ChromaticAberration[0] + 1.0f,
+ stereoParams.Distortion.Lens.ChromaticAberration[1],
+ stereoParams.Distortion.Lens.ChromaticAberration[2] + 1.0f,
+ stereoParams.Distortion.Lens.ChromaticAberration[3]);
+
+ // From [-1,1] space (for a single eye), offset by LensCenter, scaled to TanEyeAngle space.
+ // Done this way so that the shader can do a multiply-add, rather than a subtract-then-multiply.
+ Vector2f localTanEyeAngleOffset = -stereoParams.Distortion.LensCenter.EntrywiseMultiply(stereoParams.Distortion.TanEyeAngleScale);
+ pPostProcessShader->SetUniform2f("TanEyeAngleScale", stereoParams.Distortion.TanEyeAngleScale.x,
+ stereoParams.Distortion.TanEyeAngleScale.y);
+ pPostProcessShader->SetUniform2f("TanEyeAngleOffset", localTanEyeAngleOffset.x, localTanEyeAngleOffset.y);
+
+ // From TanEyeAngle space to the source the app rendered the standard projective scene to.
+ pPostProcessShader->SetUniform2f("EyeToSourceUVScale", stereoParams.EyeToSourceUV.Scale.x, stereoParams.EyeToSourceUV.Scale.y );
+ pPostProcessShader->SetUniform2f("EyeToSourceUVOffset", stereoParams.EyeToSourceUV.Offset.x, stereoParams.EyeToSourceUV.Offset.y );
+ pPostProcessShader->SetUniform2f("EyeToSourceNDCScale", stereoParams.EyeToSourceNDC.Scale.x, stereoParams.EyeToSourceNDC.Scale.y );
+ pPostProcessShader->SetUniform2f("EyeToSourceNDCOffset", stereoParams.EyeToSourceNDC.Offset.x, stereoParams.EyeToSourceNDC.Offset.y );
+
+ // Fade out towards the last bit of the edge, rather than having a sharp edge that attracts the eye.
+ pPostProcessShader->SetUniform1f("EdgeFadeScale", 1.0f / FadeOutBorderFraction );
+
+ // Vertex texture coordinates are (0,0) to (1,1). This moves them to (-1,-1),(1,1)
+ Matrix4f texm(2, 0, 0, -1,
+ 0, 2, 0, -1,
+ 0, 0, 0, 0,
+ 0, 0, 0, 1);
+ pPostProcessShader->SetUniform4x4f("Texm", texm);
+
+ // Input vertices are (0,0) to (1,1). This moves them to (-1,-1),(1,1), i.e. filling the viewport (which will be set to the correct half of the screen).
+ Matrix4f view(2, 0, 0, -1,
+ 0, 2, 0, -1,
+ 0, 0, 0, 0,
+ 0, 0, 0, 1);
+ ShaderFill fill(pPostProcessShader);
+
+ if ( ( pSourceTextureRight != NULL ) && ( eyeNum == 1 ) )
+ {
+ fill.SetTexture ( 0, pSourceTextureRight );
+ }
+ else
+ {
+ fill.SetTexture ( 0, pSourceTextureLeftOrOnly );
+ }
+ Render(&fill, pFullScreenVertexBuffer, NULL, view, 0, 4, Prim_TriangleStrip);
+ }
+ }
+ else if ( PostProcessingType == PostProcess_NoDistortion )
+ {
+ // Just splat the thing on the framebuffer with no distortion.
+ Clear ( 0.0f, 0.4f, 0.0f, 1.0f, 1.0f );
+ // 1:1 mapping to screen pixels.
+ Matrix4f ortho;
+ ortho.SetIdentity();
+ ortho.M[0][0] = 1.0f;
+ ortho.M[0][3] = 0.0f;
+ ortho.M[1][1] = -1.0f;
+ ortho.M[1][3] = 0.0f;
+ ortho.M[2][2] = 0;
+ SetProjection(ortho);
+ int rtWidth = pSourceTextureLeftOrOnly->GetWidth();
+ int rtHeight = pSourceTextureLeftOrOnly->GetHeight();
+
+ for ( int eyeNum = 0; eyeNum < 2; eyeNum++ )
+ {
+ const StereoEyeParams &stereoParams = ( eyeNum == 0 ) ? stereoParamsLeft : stereoParamsRight;
+ SetViewport ( stereoParams.DistortionViewport );
- int crossing = -1;
- float cdot1 = 0, cdot2 = 0;
+ Ptr<Texture> pTex;
+ if ( ( pSourceTextureRight != NULL ) && ( eyeNum == 1 ) )
+ {
+ pTex = pSourceTextureRight;
+ }
+ else
+ {
+ pTex = pSourceTextureLeftOrOnly;
+ }
- for(unsigned i = 0; i < Planes.GetSize(); ++i)
- {
- float dot2 = Planes[i].TestSide(fullMove);
- if(dot2 > 0)
- {
- return false;
- }
- float dot1 = Planes[i].TestSide(origin);
- if(dot1 > 0)
- {
- if(dot2 <= 0)
- {
- //assert(crossing==-1);
- if(crossing == -1)
- {
- crossing = i;
- cdot2 = dot2;
- cdot1 = dot1;
+ float ul = (float)( stereoParams.RenderedViewport.x ) / (float)rtWidth;
+ float ur = (float)( stereoParams.RenderedViewport.x + stereoParams.RenderedViewport.w ) / (float)rtWidth;
+ float vt = (float)( stereoParams.RenderedViewport.y ) / (float)rtHeight;
+ float vb = (float)( stereoParams.RenderedViewport.y + stereoParams.RenderedViewport.h ) / (float)rtHeight;
+ FillTexturedRect (
+ -1.0f, -1.0f, 1.0f, 1.0f,
+ ul, vt, ur, vb,
+ Color(255,255,255,255), pTex );
}
- else
+ }
+ else
+ {
+ OVR_ASSERT ( !"Unknown distortion type" );
+ }
+ }
+ }
+
+ bool CollisionModel::TestPoint(const Vector3f& p) const
+ {
+ for(unsigned i = 0; i < Planes.GetSize(); i++)
+ if(Planes[i].TestSide(p) > 0)
+ {
+ return 0;
+ }
+
+ return 1;
+ }
+
+ bool CollisionModel::TestRay(const Vector3f& origin, const Vector3f& norm, float& len, Planef* ph) const
+ {
+ if(TestPoint(origin))
+ {
+ len = 0;
+ *ph = Planes[0];
+ return true;
+ }
+ Vector3f fullMove = origin + norm * len;
+
+ int crossing = -1;
+ float cdot1 = 0, cdot2 = 0;
+
+ for(unsigned i = 0; i < Planes.GetSize(); ++i)
+ {
+ float dot2 = Planes[i].TestSide(fullMove);
+ if(dot2 > 0)
+ {
+ return false;
+ }
+ float dot1 = Planes[i].TestSide(origin);
+ if(dot1 > 0)
+ {
+ if(dot2 <= 0)
{
- if(dot2 > cdot2)
+ //OVR_ASSERT(crossing==-1);
+ if(crossing == -1)
{
crossing = i;
cdot2 = dot2;
cdot1 = dot1;
}
+ else
+ {
+ if(dot2 > cdot2)
+ {
+ crossing = i;
+ cdot2 = dot2;
+ cdot1 = dot1;
+ }
+ }
}
- }
- }
- }
-
- if(crossing < 0)
- {
- return false;
- }
-
- assert(TestPoint(origin + norm * len));
-
- len = len * cdot1 / (cdot1 - cdot2) - 0.05f;
- if(len < 0)
- {
- len = 0;
- }
- float tp = Planes[crossing].TestSide(origin + norm * len);
- OVR_ASSERT(fabsf(tp) < 0.05f + Mathf::Tolerance);
- OVR_UNUSED(tp);
-
- if(ph)
- {
- *ph = Planes[crossing];
- }
- return true;
-}
-
-int GetNumMipLevels(int w, int h)
-{
- int n = 1;
- while(w > 1 || h > 1)
- {
- w >>= 1;
- h >>= 1;
- n++;
- }
- return n;
-}
-
-void FilterRgba2x2(const UByte* src, int w, int h, UByte* dest)
-{
- for(int j = 0; j < (h & ~1); j += 2)
- {
- const UByte* psrc = src + (w * j * 4);
- UByte* pdest = dest + ((w >> 1) * (j >> 1) * 4);
-
- for(int i = 0; i < w >> 1; i++, psrc += 8, pdest += 4)
- {
- pdest[0] = (((int)psrc[0]) + psrc[4] + psrc[w * 4 + 0] + psrc[w * 4 + 4]) >> 2;
- pdest[1] = (((int)psrc[1]) + psrc[5] + psrc[w * 4 + 1] + psrc[w * 4 + 5]) >> 2;
- pdest[2] = (((int)psrc[2]) + psrc[6] + psrc[w * 4 + 2] + psrc[w * 4 + 6]) >> 2;
- pdest[3] = (((int)psrc[3]) + psrc[7] + psrc[w * 4 + 3] + psrc[w * 4 + 7]) >> 2;
- }
- }
-}
-
-int GetTextureSize(int format, int w, int h)
-{
- switch (format & Texture_TypeMask)
- {
- case Texture_R: return w*h;
- case Texture_RGBA: return w*h*4;
- case Texture_DXT1: {
- int bw = (w+3)/4, bh = (h+3)/4;
- return bw * bh * 8;
- }
- case Texture_DXT3:
- case Texture_DXT5: {
- int bw = (w+3)/4, bh = (h+3)/4;
- return bw * bh * 16;
- }
-
- default:
- OVR_ASSERT(0);
- }
- return 0;
-}
+ }
+ }
+
+ if(crossing < 0)
+ {
+ return false;
+ }
+
+ OVR_ASSERT(TestPoint(origin + norm * len));
+
+ len = len * cdot1 / (cdot1 - cdot2) - 0.05f;
+ if(len < 0)
+ {
+ len = 0;
+ }
+ float tp = Planes[crossing].TestSide(origin + norm * len);
+ OVR_ASSERT(fabsf(tp) < 0.05f + Mathf::Tolerance);
+ OVR_UNUSED(tp);
+
+ if(ph)
+ {
+ *ph = Planes[crossing];
+ }
+ return true;
+ }
+
+ int GetNumMipLevels(int w, int h)
+ {
+ int n = 1;
+ while(w > 1 || h > 1)
+ {
+ w >>= 1;
+ h >>= 1;
+ n++;
+ }
+ return n;
+ }
+
+ void FilterRgba2x2(const UByte* src, int w, int h, UByte* dest)
+ {
+ for(int j = 0; j < (h & ~1); j += 2)
+ {
+ const UByte* psrc = src + (w * j * 4);
+ UByte* pdest = dest + ((w >> 1) * (j >> 1) * 4);
+
+ for(int i = 0; i < w >> 1; i++, psrc += 8, pdest += 4)
+ {
+ pdest[0] = (((int)psrc[0]) + psrc[4] + psrc[w * 4 + 0] + psrc[w * 4 + 4]) >> 2;
+ pdest[1] = (((int)psrc[1]) + psrc[5] + psrc[w * 4 + 1] + psrc[w * 4 + 5]) >> 2;
+ pdest[2] = (((int)psrc[2]) + psrc[6] + psrc[w * 4 + 2] + psrc[w * 4 + 6]) >> 2;
+ pdest[3] = (((int)psrc[3]) + psrc[7] + psrc[w * 4 + 3] + psrc[w * 4 + 7]) >> 2;
+ }
+ }
+ }
+
+ int GetTextureSize(int format, int w, int h)
+ {
+ switch (format & Texture_TypeMask)
+ {
+ case Texture_R: return w*h;
+ case Texture_RGBA: return w*h*4;
+ case Texture_DXT1: {
+ int bw = (w+3)/4, bh = (h+3)/4;
+ return bw * bh * 8;
+ }
+ case Texture_DXT3:
+ case Texture_DXT5: {
+ int bw = (w+3)/4, bh = (h+3)/4;
+ return bw * bh * 16;
+ }
+
+ default:
+ OVR_ASSERT(0);
+ }
+ return 0;
+ }
}}
diff --git a/Samples/CommonSrc/Render/Render_Device.h b/Samples/CommonSrc/Render/Render_Device.h
index 028f282..f8a6dff 100644
--- a/Samples/CommonSrc/Render/Render_Device.h
+++ b/Samples/CommonSrc/Render/Render_Device.h
@@ -28,24 +28,31 @@ limitations under the License.
#include "Kernel/OVR_RefCount.h"
#include "Kernel/OVR_String.h"
#include "Kernel/OVR_File.h"
+#include "OVR_CAPI.h"
-#include "Util/Util_Render_Stereo.h"
+#include "OVR_Stereo.h"
namespace OVR { namespace Render {
-using namespace OVR::Util::Render;
-
class RenderDevice;
struct Font;
//-----------------------------------------------------------------------------------
+enum ShaderStage
+{
+ Shader_Vertex = 0,
+ Shader_Geometry = 1,
+ Shader_Fragment = 2,
+ Shader_Pixel = 2,
+ Shader_Count = 3,
+};
+
enum PrimitiveType
{
Prim_Triangles,
Prim_Lines,
Prim_TriangleStrip,
- Prim_Points,
Prim_Unknown,
Prim_Count
};
@@ -64,36 +71,32 @@ public:
virtual void Set(PrimitiveType prim = Prim_Unknown) const = 0;
virtual void Unset() const {}
- virtual void SetTexture(int i, class Texture* tex) { OVR_UNUSED2(i,tex); }
- virtual Texture* GetTexture(int i) { OVR_UNUSED(i); return 0; }
-};
-
-enum ShaderStage
-{
- Shader_Vertex = 0,
- Shader_Geometry = 1,
- Shader_Fragment = 2,
- Shader_Pixel = 2,
- Shader_Count = 3,
+ virtual void SetTexture(int i, class Texture* tex, ShaderStage stage = Shader_Pixel) { OVR_UNUSED3(i,tex,stage); }
+ virtual Texture* GetTexture(int i, ShaderStage stage = Shader_Pixel) { OVR_UNUSED2(i,stage); return 0; }
};
enum BuiltinShaders
{
- VShader_MV = 0,
- VShader_MVP = 1,
- VShader_PostProcess = 2,
- VShader_Count = 3,
-
- FShader_Solid = 0,
- FShader_Gouraud = 1,
- FShader_Texture = 2,
- FShader_AlphaTexture = 3,
- FShader_PostProcess = 4,
- FShader_PostProcessWithChromAb = 5,
- FShader_LitGouraud = 6,
- FShader_LitTexture = 7,
- FShader_MultiTexture = 8,
- FShader_Count = 9,
+ VShader_MV = 0,
+ VShader_MVP ,
+ VShader_PostProcess ,
+ VShader_PostProcessMesh ,
+ VShader_PostProcessMeshTimewarp ,
+ VShader_PostProcessMeshPositionalTimewarp ,
+ VShader_Count ,
+
+ FShader_Solid = 0,
+ FShader_Gouraud ,
+ FShader_Texture ,
+ FShader_AlphaTexture ,
+ FShader_PostProcessWithChromAb ,
+ FShader_LitGouraud ,
+ FShader_LitTexture ,
+ FShader_MultiTexture ,
+ FShader_PostProcessMeshWithChromAb ,
+ FShader_PostProcessMeshWithChromAbTimewarp ,
+ FShader_PostProcessMeshWithChromAbPositionalTimewarp ,
+ FShader_Count ,
};
@@ -119,6 +122,8 @@ enum TextureFormat
{
Texture_RGBA = 0x100,
Texture_R = 0x200,
+ Texture_A = 0x400,
+ Texture_BGRA = 0x800,
Texture_DXT1 = 0x1100,
Texture_DXT3 = 0x1200,
Texture_DXT5 = 0x1300,
@@ -126,8 +131,9 @@ enum TextureFormat
Texture_TypeMask = 0xff00,
Texture_Compressed = 0x1000,
Texture_SamplesMask = 0x00ff,
- Texture_RenderTarget = 0x10000,
- Texture_GenMipmaps = 0x20000,
+ Texture_RenderTarget = 0x10000,
+ Texture_SampleDepth = 0x20000,
+ Texture_GenMipmaps = 0x40000,
};
enum SampleMode
@@ -145,16 +151,14 @@ enum SampleMode
Sample_Count =13,
};
-// A vector with a dummy w component for alignment in uniform buffers (and for float colors).
-// The w component is not used in any calculations.
-struct Vector4f : public Vector3f
+struct Color4f
{
- float w;
+ float r, g, b, a;
- Vector4f() : w(1) {}
- Vector4f(const Vector3f& v) : Vector3f(v), w(1) {}
- Vector4f(float r, float g, float b, float a) : Vector3f(r,g,b), w(a) {}
+ Color4f() : r(0), g(0), b(0), a(1) {}
+ Color4f(const Vector3f& v) : r(v.x), g(v.y), b(v.z), a(1) {}
+ Color4f(float ir, float ig, float ib, float ia) : r(ir), g(ig), b(ib), a(ia) {}
};
@@ -231,24 +235,34 @@ public:
const float v[] = {x,y};
return SetUniform(name, 2, v);
}
+ bool SetUniform3f(const char* name, float x, float y, float z)
+ {
+ const float v[] = {x,y,z};
+ return SetUniform(name, 3, v);
+ }
bool SetUniform4f(const char* name, float x, float y, float z, float w = 1)
{
const float v[] = {x,y,z,w};
return SetUniform(name, 4, v);
}
- bool SetUniformv(const char* name, const Vector3f& v)
+ bool SetUniform4fv(const char* name, const Vector3f& v)
{
const float a[] = {v.x,v.y,v.z,1};
return SetUniform(name, 4, a);
}
- bool SetUniform4fv(const char* name, int n, const Vector4f* v)
+ bool SetUniform4fvArray(const char* name, int n, const Color4f* v)
{
- return SetUniform(name, 4*n, &v[0].x);
+ return SetUniform(name, 4*n, &v[0].r);
}
virtual bool SetUniform4x4f(const char* name, const Matrix4f& m)
{
return SetUniform(name, 16, &m.M[0][0]);
}
+ virtual bool SetUniform3x3f(const char* name, const Matrix4f& m)
+ {
+ // float3x3 is actually stored the same way as float4x3, with the last items ignored by the code.
+ return SetUniform(name, 12, &m.M[0][0]);
+ }
};
class ShaderSetMatrixTranspose : public ShaderSet
@@ -265,6 +279,7 @@ class ShaderFill : public Fill
{
Ptr<ShaderSet> Shaders;
Ptr<Texture> Textures[8];
+ Ptr<Texture> VtxTextures[8];
public:
ShaderFill(ShaderSet* sh) : Shaders(sh) { }
@@ -272,8 +287,28 @@ public:
void Set(PrimitiveType prim) const;
ShaderSet* GetShaders() { return Shaders; }
- virtual void SetTexture(int i, class Texture* tex) { if (i < 8) Textures[i] = tex; }
- virtual Texture* GetTexture(int i) { if (i < 8) return Textures[i]; else return 0; }
+ virtual void SetTexture(int i, class Texture* tex, ShaderStage stage = Shader_Pixel)
+ {
+ if (i < 8)
+ {
+ if(stage == Shader_Pixel) Textures[i] = tex;
+ else if(stage == Shader_Vertex) VtxTextures[i] = tex;
+ else OVR_ASSERT(false);
+ }
+ }
+ virtual Texture* GetTexture(int i, ShaderStage stage = Shader_Pixel)
+ {
+ if (i < 8)
+ {
+ if(stage == Shader_Pixel) return Textures[i];
+ else if(stage == Shader_Vertex) return VtxTextures[i];
+ else OVR_ASSERT(false); return 0;
+ }
+ else
+ {
+ return 0;
+ }
+ }
};
/* Buffer for vertex or index data. Some renderers require separate buffers, so that
@@ -313,6 +348,10 @@ public:
virtual void SetSampleMode(int sm) = 0;
virtual void Set(int slot, ShaderStage stage = Shader_Fragment) const = 0;
+
+ virtual ovrTexture Get_ovrTexture() = 0;
+
+ virtual void* GetInternalImplementation() { return NULL; };
};
@@ -379,7 +418,7 @@ public:
{
if (!MatCurrent)
{
- Mat = Rot;
+ Mat = Matrix4f(Rot);
Mat = Matrix4f::Translation(Pos) * Mat;
MatCurrent = 1;
}
@@ -413,18 +452,27 @@ struct Vertex
}
};
+struct DistortionVertex
+{
+ Vector2f Pos;
+ Vector2f TexR;
+ Vector2f TexG;
+ Vector2f TexB;
+ Color Col;
+};
+
// this is stored in a uniform buffer, don't change it without fixing all renderers
struct LightingParams
{
- Vector4f Ambient;
- Vector4f LightPos[8];
- Vector4f LightColor[8];
+ Color4f Ambient;
+ Color4f LightPos[8]; // Not actually colours, but we need the extra element of padding.
+ Color4f LightColor[8];
float LightCount;
int Version;
LightingParams() : LightCount(0), Version(0) {}
- void Update(const Matrix4f& view, const Vector4f* SceneLightPos);
+ void Update(const Matrix4f& view, const Vector3f* SceneLightPos);
void Set(ShaderSet* s) const;
};
@@ -472,10 +520,12 @@ public:
UInt16 AddVertex(const Vertex& v)
{
- assert(!VertexBuffer && !IndexBuffer);
- UInt16 index = (UInt16)Vertices.GetSize();
- Vertices.PushBack(v);
- return index;
+ OVR_ASSERT(!VertexBuffer && !IndexBuffer);
+ UPInt size = Vertices.GetSize();
+ OVR_ASSERT(size <= USHRT_MAX); // We only use a short to store vert indices.
+ UInt16 index = (UInt16) size;
+ Vertices.PushBack(v);
+ return index;
}
UInt16 AddVertex(const Vector3f& v, const Color& c, float u_ = 0, float v_ = 0)
{
@@ -528,6 +578,9 @@ public:
float z1, float z2, Color zcolor);
+ // Adds box at specified location to current vertices.
+ void AddBox(Color c, Vector3f origin, Vector3f size);
+
// Uses texture coordinates for exactly covering each surface once.
static Model* CreateBox(Color c, Vector3f origin, Vector3f size);
@@ -575,18 +628,18 @@ class Scene
{
public:
Container World;
- Vector4f LightPos[8];
+ Vector3f LightPos[8];
LightingParams Lighting;
Array<Ptr<Model> > Models;
public:
void Render(RenderDevice* ren, const Matrix4f& view);
- void SetAmbient(Vector4f color)
+ void SetAmbient(Color4f color)
{
Lighting.Ambient = color;
}
- void AddLight(Vector3f pos, Vector4f color)
+ void AddLight(Vector3f pos, Color4f color)
{
int n = (int)Lighting.LightCount;
OVR_ASSERT(n < 8);
@@ -599,7 +652,7 @@ public:
{
World.Clear();
Models.Clear();
- Lighting.Ambient = Vector4f(0.0f, 0.0f, 0.0f, 0.0f);
+ Lighting.Ambient = Color4f(0.0f, 0.0f, 0.0f, 0.0f);
Lighting.LightCount = 0;
}
@@ -624,11 +677,15 @@ enum RenderCaps
};
// Post-processing type to apply to scene after rendering. PostProcess_Distortion
-// applied distortion as described by DistortionConfig.
+// applied distortion as described by DistortionRenderDesc.
enum PostProcessType
{
PostProcess_None,
- PostProcess_Distortion
+ PostProcess_PixelDistortion,
+ PostProcess_MeshDistortion,
+ PostProcess_MeshDistortionTimewarp,
+ PostProcess_MeshDistortionPositionalTimewarp,
+ PostProcess_NoDistortion,
};
enum DisplayMode
@@ -688,29 +745,27 @@ class RenderDevice : public RefCountBase<RenderDevice>
protected:
int WindowWidth, WindowHeight;
RendererParams Params;
- Viewport VP;
+ Recti VP;
Matrix4f Proj;
Ptr<Buffer> pTextVertexBuffer;
-
// For rendering with lens warping
- PostProcessType CurPostProcess;
- Ptr<Texture> pSceneColorTex;
- int SceneColorTexW;
- int SceneColorTexH;
+ PostProcessType PostProcessingType;
+
Ptr<ShaderSet> pPostProcessShader;
Ptr<Buffer> pFullScreenVertexBuffer;
- float SceneRenderScale;
- DistortionConfig Distortion;
Color DistortionClearColor;
- UPInt TotalTextureMemoryUsage;
+ UPInt TotalTextureMemoryUsage;
+ float FadeOutBorderFraction;
+
+ int DistortionMeshNumTris[2];
+ Ptr<Buffer> pDistortionMeshVertexBuffer[2];
+ Ptr<Buffer> pDistortionMeshIndexBuffer[2];
// For lighting on platforms with uniform buffers
Ptr<Buffer> LightingBuffer;
- void FinishScene1();
-
public:
enum CompareFunc
{
@@ -728,41 +783,43 @@ public:
virtual void Init() {}
- virtual void Shutdown() {}
+ virtual void Shutdown();
virtual bool SetParams(const RendererParams&) { return 0; }
const RendererParams& GetParams() const { return Params; }
-
+ // Returns details needed by CAPI distortion rendering.
+ virtual ovrRenderAPIConfig Get_ovrRenderAPIConfig() const = 0;
+
// StereoParams apply Viewport, Projection and Distortion simultaneously,
// doing full configuration for one eye.
void ApplyStereoParams(const StereoEyeParams& params)
{
- SetViewport(params.VP);
- SetProjection(params.Projection);
- if (params.pDistortion)
- SetDistortionConfig(*params.pDistortion, params.Eye);
+ SetViewport(params.RenderedViewport);
+ SetProjection(params.RenderedProjection);
}
+ void ApplyStereoParams(const Recti& vp, const Matrix4f& projection)
+ {
+ SetViewport(vp);
+ SetProjection(projection);
+ }
// Apply "orthographic" stereo parameters used for rendering 2D HUD overlays.
- void ApplyStereoParams2D(const StereoEyeParams& params)
+ void ApplyStereoParams2D(StereoEyeParams const &params, Matrix4f const &ortho)
{
- SetViewport(params.VP);
- SetProjection(params.OrthoProjection);
- if (params.pDistortion)
- SetDistortionConfig(*params.pDistortion, params.Eye);
+ SetViewport(params.RenderedViewport);
+ SetProjection(ortho);
}
+
- virtual void SetViewport(const Viewport& vp);
- void SetViewport(int x, int y, int w, int h) { SetViewport(Viewport(x,y,w,h)); }
- //virtual void SetScissor(int x, int y, int w, int h) = 0;
- // Set viewport ignoring any adjustments used for the stereo mode.
- virtual void SetRealViewport(const Viewport& vp) { SetMultipleViewports(1, &vp); }
- virtual void SetMultipleViewports(int n, const Viewport* vps) { OVR_UNUSED2(n, vps); }
+ virtual void SetViewport(const Recti& vp) = 0;
+ void SetViewport(int x, int y, int w, int h) { SetViewport(Recti(x,y,w,h)); }
- virtual void Clear(float r = 0, float g = 0, float b = 0, float a = 1, float depth = 1) = 0;
+ virtual void Clear(float r = 0, float g = 0, float b = 0, float a = 1,
+ float depth = 1,
+ bool clearColor = true, bool clearDepth = true) = 0;
virtual void Rect(float left, float top, float right, float bottom) = 0;
inline void Clear(const Color &c, float depth = 1)
@@ -773,9 +830,9 @@ public:
}
virtual bool IsFullscreen() const { return Params.Fullscreen != Display_Window; }
- virtual void Present() = 0;
+ virtual void Present ( bool withVsync ) = 0;
// Waits for rendering to complete; important for reducing latency.
- virtual void ForceFlushGPU() { }
+ virtual void WaitUntilGpuIdle() { }
// Resources
virtual Buffer* CreateBuffer() { return NULL; }
@@ -789,12 +846,24 @@ public:
// Rendering
+
// Begin drawing directly to the currently selected render target, no post-processing.
virtual void BeginRendering() {}
- // Begin drawing the primary scene. This will have post-processing applied (if enabled)
- // during FinishScene.
- virtual void BeginScene(PostProcessType pp = PostProcess_None); //StereoDisplay disp = Stereo_Center);
- // Postprocess the scene and return to the screen render target.
+ // Begin drawing the primary scene, starting up whatever post-processing may be needed.
+ virtual void BeginScene(PostProcessType pp = PostProcess_None);
+ // Call when any of the stereo options change, so precalculation can happen.
+ virtual void PrecalculatePostProcess(PostProcessType pptype,
+ const StereoEyeParams &stereoParamsLeft, const StereoEyeParams &stereoParamsRight,
+ const HmdRenderInfo &hmdRenderInfo );
+ // Perform postprocessing
+ virtual void ApplyPostProcess(Matrix4f const &matNowFromWorldStart, Matrix4f const &matNowFromWorldEnd,
+ Matrix4f const &matRenderFromWorldLeft, Matrix4f const &matRenderFromWorldRight,
+ StereoEyeParams const &stereoParamsLeft, StereoEyeParams const &stereoParamsRight,
+ Ptr<Texture> pSourceTextureLeftOrOnly,
+ Ptr<Texture> pSourceTextureRight,
+ Ptr<Texture> pSourceTextureLeftOrOnlyDepth,
+ Ptr<Texture> pSourceTextureRightDepth);
+ // Finish scene.
virtual void FinishScene();
// Texture must have been created with Texture_RenderTarget. Use NULL for the default render target.
@@ -818,31 +887,25 @@ public:
virtual void Render(const Matrix4f& matrix, Model* model) = 0;
// offset is in bytes; indices can be null.
virtual void Render(const Fill* fill, Buffer* vertices, Buffer* indices,
- const Matrix4f& matrix, int offset, int count, PrimitiveType prim = Prim_Triangles) = 0;
+ const Matrix4f& matrix, int offset, int count, PrimitiveType prim = Prim_Triangles, bool useDistortionVertex = false) = 0;
virtual void RenderWithAlpha(const Fill* fill, Render::Buffer* vertices, Render::Buffer* indices,
const Matrix4f& matrix, int offset, int count, PrimitiveType prim = Prim_Triangles) = 0;
// Returns width of text in same units as drawing. If strsize is not null, stores width and height.
- float MeasureText(const Font* font, const char* str, float size, float* strsize = NULL);
+ // Can optionally return char-range selection rectangle.
+ float MeasureText(const Font* font, const char* str, float size, float strsize[2] = NULL,
+ const UPInt charRange[2] = 0, Vector2f charRangeRect[2] = 0);
virtual void RenderText(const Font* font, const char* str, float x, float y, float size, Color c);
virtual void FillRect(float left, float top, float right, float bottom, Color c);
+ virtual void RenderLines ( int NumLines, Color c, float *x, float *y, float *z = NULL );
+ virtual void FillTexturedRect(float left, float top, float right, float bottom, float ul, float vt, float ur, float vb, Color c, Ptr<Texture> tex);
virtual void FillGradientRect(float left, float top, float right, float bottom, Color col_top, Color col_btm);
virtual void RenderImage(float left, float top, float right, float bottom, ShaderFill* image, unsigned char alpha=255);
virtual Fill *CreateSimpleFill(int flags = Fill::F_Solid) = 0;
Fill * CreateTextureFill(Texture* tex, bool useAlpha = false);
- // PostProcess distortion
- void SetSceneRenderScale(float ss);
-
- void SetDistortionConfig(const DistortionConfig& config, StereoEye eye = StereoEye_Left)
- {
- Distortion = config;
- if (eye == StereoEye_Right)
- Distortion.XCenterOffset = -Distortion.XCenterOffset;
- }
-
// Sets the color that is applied around distortion.
void SetDistortionClearColor(Color clearColor)
{
@@ -851,7 +914,12 @@ public:
// Don't call these directly, use App/Platform instead
virtual bool SetFullscreen(DisplayMode fullscreen) { OVR_UNUSED(fullscreen); return false; }
- virtual void SetWindowSize(int w, int h) { WindowWidth = w; WindowHeight = h; }
+ virtual void SetWindowSize(int w, int h)
+ {
+ WindowWidth = w;
+ WindowHeight = h;
+ VP = Recti( 0, 0, WindowWidth, WindowHeight );
+ }
UPInt GetTotalTextureMemoryUsage() const
{
@@ -860,8 +928,10 @@ public:
enum PostProcessShader
{
- PostProcessShader_Distortion = 0,
- PostProcessShader_DistortionAndChromAb = 1,
+ PostProcessShader_DistortionAndChromAb = 0,
+ PostProcessShader_MeshDistortionAndChromAb,
+ PostProcessShader_MeshDistortionAndChromAbTimewarp,
+ PostProcessShader_MeshDistortionAndChromAbPositionalTimewarp,
PostProcessShader_Count
};
@@ -875,6 +945,16 @@ public:
PostProcessShaderRequested = newShader;
}
+ void SetFadeOutBorderFraction ( float newVal )
+ {
+ FadeOutBorderFraction = newVal;
+ }
+
+ // GPU Profiling
+ // using (void) to avoid "unused param" warnings
+ virtual void BeginGpuEvent(const char* markerText, UInt32 markerColor) { (void)markerText; (void)markerColor; }
+ virtual void EndGpuEvent() { }
+
protected:
// Stereo & post-processing
virtual bool initPostProcessSupport(PostProcessType pptype);
@@ -887,6 +967,34 @@ private:
PostProcessShader PostProcessShaderActive;
};
+//-----------------------------------------------------------------------------------
+// GPU profile marker helper to encapsulate a given scope block
+class AutoGpuProf
+{
+public:
+ AutoGpuProf(RenderDevice* device, const char* markerText, UInt32 color)
+ : mDevice(device)
+ { device->BeginGpuEvent(markerText, color); }
+
+ // Generates random color if one is not provided
+ AutoGpuProf(RenderDevice* device, const char* markerText)
+ : mDevice(device)
+ {
+ UInt32 color = ((rand() & 0xFF) << 24) +
+ ((rand() & 0xFF) << 16) +
+ ((rand() & 0xFF) << 8) +
+ (rand() & 0xFF);
+ device->BeginGpuEvent(markerText, color);
+ }
+
+ ~AutoGpuProf() { mDevice->EndGpuEvent(); }
+
+private:
+ RenderDevice* mDevice;
+ AutoGpuProf() { };
+};
+//-----------------------------------------------------------------------------------
+
int GetNumMipLevels(int w, int h);
int GetTextureSize(int format, int w, int h);
diff --git a/Samples/CommonSrc/Render/Render_GL_Device.cpp b/Samples/CommonSrc/Render/Render_GL_Device.cpp
index aaf1f0e..4b3ddec 100644
--- a/Samples/CommonSrc/Render/Render_GL_Device.cpp
+++ b/Samples/CommonSrc/Render/Render_GL_Device.cpp
@@ -23,9 +23,122 @@ limitations under the License.
#include "../Render/Render_GL_Device.h"
#include "Kernel/OVR_Log.h"
+#include "OVR_CAPI_GL.h"
namespace OVR { namespace Render { namespace GL {
+// GL Hooks for PC.
+#if defined(OVR_OS_WIN32)
+
+PFNWGLGETSWAPINTERVALEXTPROC wglGetSwapIntervalEXT;
+PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT;
+PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT;
+PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT;
+PFNGLDELETESHADERPROC glDeleteShader;
+PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT;
+PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glFramebufferRenderbufferEXT;
+PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT;
+PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT;
+PFNGLACTIVETEXTUREPROC glActiveTexture;
+PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray;
+PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
+PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray;
+PFNGLBINDBUFFERPROC glBindBuffer;
+PFNGLUNIFORMMATRIX3FVPROC glUniformMatrix3fv;
+PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv;
+PFNGLDELETEBUFFERSPROC glDeleteBuffers;
+PFNGLBUFFERDATAPROC glBufferData;
+PFNGLGENBUFFERSPROC glGenBuffers;
+PFNGLMAPBUFFERPROC glMapBuffer;
+PFNGLUNMAPBUFFERPROC glUnmapBuffer;
+PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog;
+PFNGLGETSHADERIVPROC glGetShaderiv;
+PFNGLCOMPILESHADERPROC glCompileShader;
+PFNGLSHADERSOURCEPROC glShaderSource;
+PFNGLCREATESHADERPROC glCreateShader;
+PFNGLCREATEPROGRAMPROC glCreateProgram;
+PFNGLATTACHSHADERPROC glAttachShader;
+PFNGLDETACHSHADERPROC glDetachShader;
+PFNGLDELETEPROGRAMPROC glDeleteProgram;
+PFNGLUNIFORM1IPROC glUniform1i;
+PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;
+PFNGLGETACTIVEUNIFORMPROC glGetActiveUniform;
+PFNGLUSEPROGRAMPROC glUseProgram;
+PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
+PFNGLGETPROGRAMIVPROC glGetProgramiv;
+PFNGLLINKPROGRAMPROC glLinkProgram;
+PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation;
+PFNGLUNIFORM4FVPROC glUniform4fv;
+PFNGLUNIFORM3FVPROC glUniform3fv;
+PFNGLUNIFORM2FVPROC glUniform2fv;
+PFNGLUNIFORM1FVPROC glUniform1fv;
+PFNGLCOMPRESSEDTEXIMAGE2DPROC glCompressedTexImage2D;
+PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT;
+PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT;
+PFNGLGENRENDERBUFFERSEXTPROC glGenRenderbuffersEXT;
+PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT;
+
+PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
+
+void InitGLExtensions()
+{
+ if (glGenFramebuffersEXT)
+ return;
+
+
+ wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALEXTPROC) wglGetProcAddress("wglGetSwapIntervalEXT");
+ wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC) wglGetProcAddress("wglSwapIntervalEXT");
+ glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) wglGetProcAddress("glGenFramebuffersEXT");
+ glDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC) wglGetProcAddress("glDeleteFramebuffersEXT");
+ glDeleteShader = (PFNGLDELETESHADERPROC) wglGetProcAddress("glDeleteShader");
+ glCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) wglGetProcAddress("glCheckFramebufferStatusEXT");
+ glFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) wglGetProcAddress("glFramebufferRenderbufferEXT");
+ glFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) wglGetProcAddress("glFramebufferTexture2DEXT");
+ glBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) wglGetProcAddress("glBindFramebufferEXT");
+ glActiveTexture = (PFNGLACTIVETEXTUREPROC) wglGetProcAddress("glActiveTexture");
+ glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC) wglGetProcAddress("glDisableVertexAttribArray");
+ glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) wglGetProcAddress("glVertexAttribPointer");
+ glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC) wglGetProcAddress("glEnableVertexAttribArray");
+ glBindBuffer = (PFNGLBINDBUFFERPROC) wglGetProcAddress("glBindBuffer");
+ glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC) wglGetProcAddress("glUniformMatrix3fv");
+ glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC) wglGetProcAddress("glUniformMatrix4fv");
+ glDeleteBuffers = (PFNGLDELETEBUFFERSPROC) wglGetProcAddress("glDeleteBuffers");
+ glBufferData = (PFNGLBUFFERDATAPROC) wglGetProcAddress("glBufferData");
+ glGenBuffers = (PFNGLGENBUFFERSPROC) wglGetProcAddress("glGenBuffers");
+ glMapBuffer = (PFNGLMAPBUFFERPROC) wglGetProcAddress("glMapBuffer");
+ glUnmapBuffer = (PFNGLUNMAPBUFFERPROC) wglGetProcAddress("glUnmapBuffer");
+ glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) wglGetProcAddress("glGetShaderInfoLog");
+ glGetShaderiv = (PFNGLGETSHADERIVPROC) wglGetProcAddress("glGetShaderiv");
+ glCompileShader = (PFNGLCOMPILESHADERPROC) wglGetProcAddress("glCompileShader");
+ glShaderSource = (PFNGLSHADERSOURCEPROC) wglGetProcAddress("glShaderSource");
+ glCreateShader = (PFNGLCREATESHADERPROC) wglGetProcAddress("glCreateShader");
+ glCreateProgram = (PFNGLCREATEPROGRAMPROC) wglGetProcAddress("glCreateProgram");
+ glAttachShader = (PFNGLATTACHSHADERPROC) wglGetProcAddress("glAttachShader");
+ glDetachShader = (PFNGLDETACHSHADERPROC) wglGetProcAddress("glDetachShader");
+ glDeleteProgram = (PFNGLDELETEPROGRAMPROC) wglGetProcAddress("glDeleteProgram");
+ glUniform1i = (PFNGLUNIFORM1IPROC) wglGetProcAddress("glUniform1i");
+ glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) wglGetProcAddress("glGetUniformLocation");
+ glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC) wglGetProcAddress("glGetActiveUniform");
+ glUseProgram = (PFNGLUSEPROGRAMPROC) wglGetProcAddress("glUseProgram");
+ glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) wglGetProcAddress("glGetProgramInfoLog");
+ glGetProgramiv = (PFNGLGETPROGRAMIVPROC) wglGetProcAddress("glGetProgramiv");
+ glLinkProgram = (PFNGLLINKPROGRAMPROC) wglGetProcAddress("glLinkProgram");
+ glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC) wglGetProcAddress("glBindAttribLocation");
+ glUniform4fv = (PFNGLUNIFORM4FVPROC) wglGetProcAddress("glUniform4fv");
+ glUniform3fv = (PFNGLUNIFORM3FVPROC) wglGetProcAddress("glUniform3fv");
+ glUniform2fv = (PFNGLUNIFORM2FVPROC) wglGetProcAddress("glUniform2fv");
+ glUniform1fv = (PFNGLUNIFORM1FVPROC) wglGetProcAddress("glUniform1fv");
+ glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC) wglGetProcAddress("glCompressedTexImage2D");
+ glRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) wglGetProcAddress("glRenderbufferStorageEXT");
+ glBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC) wglGetProcAddress("glBindRenderbufferEXT");
+ glGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC) wglGetProcAddress("glGenRenderbuffersEXT");
+ glDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC) wglGetProcAddress("glDeleteRenderbuffersEXT");
+
+
+ glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC) wglGetProcAddress("glGenVertexArrays");
+}
+
+#endif
static const char* StdVertexShaderSrc =
@@ -157,6 +270,53 @@ static const char* MultiTextureFragShaderSrc =
" gl_FragColor = color2;\n"
"}\n";
+static const char* PostProcessMeshFragShaderSrc =
+ "uniform sampler2D Texture;\n"
+ "varying vec4 oColor;\n"
+ "varying vec2 oTexCoord0;\n"
+ "varying vec2 oTexCoord1;\n"
+ "varying vec2 oTexCoord2;\n"
+ "\n"
+ "void main()\n"
+ "{\n"
+ " float ResultR = texture2D(Texture, oTexCoord0).r;\n"
+ " float ResultG = texture2D(Texture, oTexCoord1).g;\n"
+ " float ResultB = texture2D(Texture, oTexCoord2).b;\n"
+ " gl_FragColor = vec4(ResultR * oColor.r, ResultG * oColor.g, ResultB * oColor.b, 1.0);\n"
+ "}\n";
+
+static const char* PostProcessMeshTimewarpFragShaderSrc =
+ "uniform sampler2D Texture;\n"
+ "varying vec4 oColor;\n"
+ "varying vec2 oTexCoord0;\n"
+ "varying vec2 oTexCoord1;\n"
+ "varying vec2 oTexCoord2;\n"
+ "\n"
+ "void main()\n"
+ "{\n"
+ " float ResultR = texture2D(Texture, oTexCoord0).r;\n"
+ " float ResultG = texture2D(Texture, oTexCoord1).g;\n"
+ " float ResultB = texture2D(Texture, oTexCoord2).b;\n"
+ " gl_FragColor = vec4(ResultR * oColor.r, ResultG * oColor.g, ResultB * oColor.b, 1.0);\n"
+ "}\n";
+
+static const char* PostProcessMeshPositionalTimewarpFragShaderSrc =
+ "uniform sampler2D Texture0;\n"
+ "uniform sampler2D Texture1;\n"
+ "varying vec4 oColor;\n"
+ "varying vec2 oTexCoord0;\n"
+ "varying vec2 oTexCoord1;\n"
+ "varying vec2 oTexCoord2;\n"
+ "\n"
+ "void main()\n"
+ "{\n"
+ " gl_FragColor.r = oColor.r * texture2D(Texture1, oTexCoord0).r;\n"
+ " gl_FragColor.g = oColor.g * texture2D(Texture1, oTexCoord1).g;\n"
+ " gl_FragColor.b = oColor.b * texture2D(Texture1, oTexCoord2).b;\n"
+ " gl_FragColor.a = 1.0;\n"
+ "}\n";
+
+
static const char* PostProcessVertexShaderSrc =
"uniform mat4 View;\n"
"uniform mat4 Texm;\n"
@@ -167,85 +327,275 @@ static const char* PostProcessVertexShaderSrc =
"{\n"
" gl_Position = View * Position;\n"
" oTexCoord = vec2(Texm * vec4(TexCoord,0,1));\n"
- " oTexCoord.y = 1.0-oTexCoord.y;\n"
+ "}\n";
+
+static const char* PostProcessMeshVertexShaderSrc =
+ "uniform vec2 EyeToSourceUVScale;\n"
+ "uniform vec2 EyeToSourceUVOffset;\n"
+
+ "attribute vec2 Position;\n"
+ "attribute vec4 Color;\n"
+ "attribute vec2 TexCoord0;\n"
+ "attribute vec2 TexCoord1;\n"
+ "attribute vec2 TexCoord2;\n"
+
+ "varying vec4 oColor;\n"
+ "varying vec2 oTexCoord0;\n"
+ "varying vec2 oTexCoord1;\n"
+ "varying vec2 oTexCoord2;\n"
+
+ "void main()\n"
+ "{\n"
+ " gl_Position.x = Position.x;\n"
+ " gl_Position.y = Position.y;\n"
+ " gl_Position.z = 0.5;\n"
+ " gl_Position.w = 1.0;\n"
+ // Vertex inputs are in TanEyeAngle space for the R,G,B channels (i.e. after chromatic aberration and distortion).
+ // Scale them into the correct [0-1],[0-1] UV lookup space (depending on eye)
+ " oTexCoord0 = TexCoord0 * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
+ " oTexCoord0.y = 1-oTexCoord0.y;\n"
+ " oTexCoord1 = TexCoord1 * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
+ " oTexCoord1.y = 1-oTexCoord1.y;\n"
+ " oTexCoord2 = TexCoord2 * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
+ " oTexCoord2.y = 1-oTexCoord2.y;\n"
+ " oColor = Color;\n" // Used for vignette fade.
+ "}\n";
+
+static const char* PostProcessMeshTimewarpVertexShaderSrc =
+ "uniform vec2 EyeToSourceUVScale;\n"
+ "uniform vec2 EyeToSourceUVOffset;\n"
+ "uniform mat4 EyeRotationStart;\n"
+ "uniform mat4 EyeRotationEnd;\n"
+
+ "attribute vec2 Position;\n"
+ "attribute vec4 Color;\n"
+ "attribute vec2 TexCoord0;\n"
+ "attribute vec2 TexCoord1;\n"
+ "attribute vec2 TexCoord2;\n"
+
+ "varying vec4 oColor;\n"
+ "varying vec2 oTexCoord0;\n"
+ "varying vec2 oTexCoord1;\n"
+ "varying vec2 oTexCoord2;\n"
+
+ "void main()\n"
+ "{\n"
+ " gl_Position.x = Position.x;\n"
+ " gl_Position.y = Position.y;\n"
+ " gl_Position.z = 0.0;\n"
+ " gl_Position.w = 1.0;\n"
+
+ // Vertex inputs are in TanEyeAngle space for the R,G,B channels (i.e. after chromatic aberration and distortion).
+ // These are now "real world" vectors in direction (x,y,1) relative to the eye of the HMD.
+ " vec3 TanEyeAngleR = vec3 ( TexCoord0.x, TexCoord0.y, 1.0 );\n"
+ " vec3 TanEyeAngleG = vec3 ( TexCoord1.x, TexCoord1.y, 1.0 );\n"
+ " vec3 TanEyeAngleB = vec3 ( TexCoord2.x, TexCoord2.y, 1.0 );\n"
+
+ // Accurate time warp lerp vs. faster
+#if 1
+ // Apply the two 3x3 timewarp rotations to these vectors.
+ " vec3 TransformedRStart = (EyeRotationStart * vec4(TanEyeAngleR, 0)).xyz;\n"
+ " vec3 TransformedGStart = (EyeRotationStart * vec4(TanEyeAngleG, 0)).xyz;\n"
+ " vec3 TransformedBStart = (EyeRotationStart * vec4(TanEyeAngleB, 0)).xyz;\n"
+ " vec3 TransformedREnd = (EyeRotationEnd * vec4(TanEyeAngleR, 0)).xyz;\n"
+ " vec3 TransformedGEnd = (EyeRotationEnd * vec4(TanEyeAngleG, 0)).xyz;\n"
+ " vec3 TransformedBEnd = (EyeRotationEnd * vec4(TanEyeAngleB, 0)).xyz;\n"
+ // And blend between them.
+ " vec3 TransformedR = mix ( TransformedRStart, TransformedREnd, Color.a );\n"
+ " vec3 TransformedG = mix ( TransformedGStart, TransformedGEnd, Color.a );\n"
+ " vec3 TransformedB = mix ( TransformedBStart, TransformedBEnd, Color.a );\n"
+#else
+ " mat3 EyeRotation = mix ( EyeRotationStart, EyeRotationEnd, Color.a );\n"
+ " vec3 TransformedR = EyeRotation * TanEyeAngleR;\n"
+ " vec3 TransformedG = EyeRotation * TanEyeAngleG;\n"
+ " vec3 TransformedB = EyeRotation * TanEyeAngleB;\n"
+#endif
+
+ // Project them back onto the Z=1 plane of the rendered images.
+ " float RecipZR = 1.0 / TransformedR.z;\n"
+ " float RecipZG = 1.0 / TransformedG.z;\n"
+ " float RecipZB = 1.0 / TransformedB.z;\n"
+ " vec2 FlattenedR = vec2 ( TransformedR.x * RecipZR, TransformedR.y * RecipZR );\n"
+ " vec2 FlattenedG = vec2 ( TransformedG.x * RecipZG, TransformedG.y * RecipZG );\n"
+ " vec2 FlattenedB = vec2 ( TransformedB.x * RecipZB, TransformedB.y * RecipZB );\n"
+
+ // These are now still in TanEyeAngle space.
+ // Scale them into the correct [0-1],[0-1] UV lookup space (depending on eye)
+ " vec2 SrcCoordR = FlattenedR * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
+ " vec2 SrcCoordG = FlattenedG * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
+ " vec2 SrcCoordB = FlattenedB * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
+ " oTexCoord0 = SrcCoordR;\n"
+ " oTexCoord0.y = 1-oTexCoord0.y;\n"
+ " oTexCoord1 = SrcCoordG;\n"
+ " oTexCoord1.y = 1-oTexCoord1.y;\n"
+ " oTexCoord2 = SrcCoordB;\n"
+ " oTexCoord2.y = 1-oTexCoord2.y;\n"
+ " oColor = Color.r;\n" // Used for vignette fade.
+ "}\n";
+
+static const char* PostProcessMeshPositionalTimewarpVertexShaderSrc =
+ "#version 150\n"
+ "uniform sampler2D Texture0;\n"
+ "uniform vec2 EyeToSourceUVScale;\n"
+ "uniform vec2 EyeToSourceUVOffset;\n"
+ "uniform vec2 DepthProjector;\n"
+ "uniform vec2 DepthDimSize;\n"
+ "uniform mat4 EyeRotationStart;\n"
+ "uniform mat4 EyeRotationEnd;\n"
+
+ "in vec2 Position;\n"
+ "in vec4 Color;\n"
+ "in vec2 TexCoord0;\n"
+ "in vec2 TexCoord1;\n"
+ "in vec2 TexCoord2;\n"
+
+ "out vec4 oColor;\n"
+ "out vec2 oTexCoord0;\n"
+ "out vec2 oTexCoord1;\n"
+ "out vec2 oTexCoord2;\n"
+
+ "vec4 PositionFromDepth(vec2 inTexCoord)\n"
+ "{\n"
+ " vec2 eyeToSourceTexCoord = inTexCoord * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
+ " eyeToSourceTexCoord.y = 1 - eyeToSourceTexCoord.y;\n"
+ " float depth = texelFetch(Texture0, ivec2(eyeToSourceTexCoord * DepthDimSize), 0).x;\n"
+ " float linearDepth = DepthProjector.y / (depth - DepthProjector.x);\n"
+ " vec4 retVal = vec4(inTexCoord, 1, 1);\n"
+ " retVal.xyz *= linearDepth;\n"
+ " return retVal;\n"
+ "}\n"
+
+ "vec2 TimewarpTexCoordToWarpedPos(vec2 inTexCoord, float a)\n"
+ "{\n"
+ // Vertex inputs are in TanEyeAngle space for the R,G,B channels (i.e. after chromatic aberration and distortion).
+ // These are now "real world" vectors in direction (x,y,1) relative to the eye of the HMD.
+ // Apply the 4x4 timewarp rotation to these vectors.
+ " vec4 inputPos = PositionFromDepth(inTexCoord);\n"
+ " vec3 transformed = mix ( EyeRotationStart * inputPos, EyeRotationEnd * inputPos, a ).xyz;\n"
+ // Project them back onto the Z=1 plane of the rendered images.
+ " vec2 flattened = transformed.xy / transformed.z;\n"
+ // Scale them into ([0,0.5],[0,1]) or ([0.5,0],[0,1]) UV lookup space (depending on eye)
+ " vec2 noDepthUV = flattened * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
+ //" float depth = texture2DLod(Texture0, noDepthUV, 0).r;\n"
+ " return noDepthUV.xy;\n"
+ "}\n"
+
+ "void main()\n"
+ "{\n"
+ " gl_Position.x = Position.x;\n"
+ " gl_Position.y = Position.y;\n"
+ " gl_Position.z = 0.0;\n"
+ " gl_Position.w = 1.0;\n"
+
+ // warped positions are a bit more involved, hence a separate function
+ " oTexCoord0 = TimewarpTexCoordToWarpedPos(TexCoord0, Color.a);\n"
+ " oTexCoord0.y = 1-oTexCoord0.y;\n"
+ " oTexCoord1 = TimewarpTexCoordToWarpedPos(TexCoord1, Color.a);\n"
+ " oTexCoord1.y = 1-oTexCoord1.y;\n"
+ " oTexCoord2 = TimewarpTexCoordToWarpedPos(TexCoord2, Color.a);\n"
+ " oTexCoord2.y = 1-oTexCoord2.y;\n"
+
+ " oColor = vec4(Color.r); // Used for vignette fade.\n"
"}\n";
static const char* PostProcessFragShaderSrc =
"uniform vec2 LensCenter;\n"
"uniform vec2 ScreenCenter;\n"
- "uniform vec2 Scale;\n"
- "uniform vec2 ScaleIn;\n"
+ "uniform vec2 EyeToSourceUVScale;\n"
+ "uniform vec2 EyeToSourceNDCScale;\n"
"uniform vec4 HmdWarpParam;\n"
- "uniform sampler2D Texture0;\n"
+ "uniform sampler2D Texture1;\n"
+
"varying vec2 oTexCoord;\n"
- "\n"
+
"vec2 HmdWarp(vec2 in01)\n"
"{\n"
- " vec2 theta = (in01 - LensCenter) * ScaleIn;\n" // Scales to [-1, 1]
+ " vec2 theta = (in01 - LensCenter) * EyeToSourceNDCScale;\n" // Scales to [-1, 1]
" float rSq = theta.x * theta.x + theta.y * theta.y;\n"
" vec2 theta1 = theta * (HmdWarpParam.x + HmdWarpParam.y * rSq + "
" HmdWarpParam.z * rSq * rSq + HmdWarpParam.w * rSq * rSq * rSq);\n"
- " return LensCenter + Scale * theta1;\n"
+ " return LensCenter + EyeToSourceUVScale * theta1;\n"
"}\n"
+
"void main()\n"
"{\n"
" vec2 tc = HmdWarp(oTexCoord);\n"
" if (!all(equal(clamp(tc, ScreenCenter-vec2(0.25,0.5), ScreenCenter+vec2(0.25,0.5)), tc)))\n"
" gl_FragColor = vec4(0);\n"
" else\n"
- " gl_FragColor = texture2D(Texture0, tc);\n"
+ " gl_FragColor = texture2D(Texture1, tc);\n"
"}\n";
// Shader with lens distortion and chromatic aberration correction.
-static const char* PostProcessFullFragShaderSrc =
- "uniform vec2 LensCenter;\n"
- "uniform vec2 ScreenCenter;\n"
- "uniform vec2 Scale;\n"
- "uniform vec2 ScaleIn;\n"
+static const char* PostProcessFragShaderWithChromAbSrc =
+ "uniform sampler2D Texture;\n"
+ "uniform vec3 DistortionClearColor;\n"
+ "uniform float EdgeFadeScale;\n"
+ "uniform vec2 EyeToSourceUVScale;\n"
+ "uniform vec2 EyeToSourceUVOffset;\n"
+ "uniform vec2 EyeToSourceNDCScale;\n"
+ "uniform vec2 EyeToSourceNDCOffset;\n"
+ "uniform vec2 TanEyeAngleScale;\n"
+ "uniform vec2 TanEyeAngleOffset;\n"
"uniform vec4 HmdWarpParam;\n"
"uniform vec4 ChromAbParam;\n"
- "uniform sampler2D Texture0;\n"
+
+ "varying vec4 oPosition;\n"
"varying vec2 oTexCoord;\n"
- "\n"
- // Scales input texture coordinates for distortion.
- // ScaleIn maps texture coordinates to Scales to ([-1, 1]), although top/bottom will be
- // larger due to aspect ratio.
- "void main()\n"
+
+ "void main()\n"
"{\n"
- " vec2 theta = (oTexCoord - LensCenter) * ScaleIn;\n" // Scales to [-1, 1]
- " float rSq= theta.x * theta.x + theta.y * theta.y;\n"
- " vec2 theta1 = theta * (HmdWarpParam.x + HmdWarpParam.y * rSq + "
- " HmdWarpParam.z * rSq * rSq + HmdWarpParam.w * rSq * rSq * rSq);\n"
- " \n"
- " // Detect whether blue texture coordinates are out of range since these will scaled out the furthest.\n"
- " vec2 thetaBlue = theta1 * (ChromAbParam.z + ChromAbParam.w * rSq);\n"
- " vec2 tcBlue = LensCenter + Scale * thetaBlue;\n"
- " if (!all(equal(clamp(tcBlue, ScreenCenter-vec2(0.25,0.5), ScreenCenter+vec2(0.25,0.5)), tcBlue)))\n"
+ // Input oTexCoord is [-1,1] across the half of the screen used for a single eye.
+ " vec2 TanEyeAngleDistorted = oTexCoord * TanEyeAngleScale + TanEyeAngleOffset;\n" // Scales to tan(thetaX),tan(thetaY), but still distorted (i.e. only the center is correct)
+ " float RadiusSq = TanEyeAngleDistorted.x * TanEyeAngleDistorted.x + TanEyeAngleDistorted.y * TanEyeAngleDistorted.y;\n"
+ " float Distort = 1.0 / ( 1.0 + RadiusSq * ( HmdWarpParam.y + RadiusSq * ( HmdWarpParam.z + RadiusSq * ( HmdWarpParam.w ) ) ) );\n"
+ " float DistortR = Distort * ( ChromAbParam.x + RadiusSq * ChromAbParam.y );\n"
+ " float DistortG = Distort;\n"
+ " float DistortB = Distort * ( ChromAbParam.z + RadiusSq * ChromAbParam.w );\n"
+ " vec2 TanEyeAngleR = DistortR * TanEyeAngleDistorted;\n"
+ " vec2 TanEyeAngleG = DistortG * TanEyeAngleDistorted;\n"
+ " vec2 TanEyeAngleB = DistortB * TanEyeAngleDistorted;\n"
+
+ // These are now in "TanEyeAngle" space.
+ // The vectors (TanEyeAngleRGB.x, TanEyeAngleRGB.y, 1.0) are real-world vectors pointing from the eye to where the components of the pixel appear to be.
+ // If you had a raytracer, you could just use them directly.
+
+ // Scale them into ([0,0.5],[0,1]) or ([0.5,0],[0,1]) UV lookup space (depending on eye)
+ " vec2 SourceCoordR = TanEyeAngleR * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
+ " SourceCoordR.y = 1 - SourceCoordR.y;\n"
+ " vec2 SourceCoordG = TanEyeAngleG * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
+ " SourceCoordG.y = 1 - SourceCoordG.y;\n"
+ " vec2 SourceCoordB = TanEyeAngleB * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
+ " SourceCoordB.y = 1 - SourceCoordB.y;\n"
+
+ // Find the distance to the nearest edge.
+ " vec2 NDCCoord = TanEyeAngleG * EyeToSourceNDCScale + EyeToSourceNDCOffset;\n"
+ " float EdgeFadeIn = clamp ( EdgeFadeScale, 0, 1e5 ) * ( 1.0 - max ( abs ( NDCCoord.x ), abs ( NDCCoord.y ) ) );\n"
+ " if ( EdgeFadeIn < 0.0 )\n"
" {\n"
- " gl_FragColor = vec4(0);\n"
- " return;\n"
+ " gl_FragColor = vec4(DistortionClearColor.r, DistortionClearColor.g, DistortionClearColor.b, 1.0);\n"
+ " return;\n"
" }\n"
- " \n"
- " // Now do blue texture lookup.\n"
- " float blue = texture2D(Texture0, tcBlue).b;\n"
- " \n"
- " // Do green lookup (no scaling).\n"
- " vec2 tcGreen = LensCenter + Scale * theta1;\n"
- " vec4 center = texture2D(Texture0, tcGreen);\n"
- " \n"
- " // Do red scale and lookup.\n"
- " vec2 thetaRed = theta1 * (ChromAbParam.x + ChromAbParam.y * rSq);\n"
- " vec2 tcRed = LensCenter + Scale * thetaRed;\n"
- " float red = texture2D(Texture0, tcRed).r;\n"
- " \n"
- " gl_FragColor = vec4(red, center.g, blue, center.a);\n"
+ " EdgeFadeIn = clamp ( EdgeFadeIn, 0.0, 1.0 );\n"
+
+ // Actually do the lookups.
+ " float ResultR = texture2D(Texture, SourceCoordR).r;\n"
+ " float ResultG = texture2D(Texture, SourceCoordG).g;\n"
+ " float ResultB = texture2D(Texture, SourceCoordB).b;\n"
+
+ " gl_FragColor = vec4(ResultR * EdgeFadeIn, ResultG * EdgeFadeIn, ResultB * EdgeFadeIn, 1.0);\n"
"}\n";
+
+
static const char* VShaderSrcs[VShader_Count] =
{
DirectVertexShaderSrc,
StdVertexShaderSrc,
- PostProcessVertexShaderSrc
+ PostProcessVertexShaderSrc,
+ PostProcessMeshVertexShaderSrc,
+ PostProcessMeshTimewarpVertexShaderSrc,
+ PostProcessMeshPositionalTimewarpVertexShaderSrc
};
static const char* FShaderSrcs[FShader_Count] =
{
@@ -253,16 +603,17 @@ static const char* FShaderSrcs[FShader_Count] =
GouraudFragShaderSrc,
TextureFragShaderSrc,
AlphaTextureFragShaderSrc,
- PostProcessFragShaderSrc,
- PostProcessFullFragShaderSrc,
+ PostProcessFragShaderWithChromAbSrc,
LitSolidFragShaderSrc,
LitTextureFragShaderSrc,
- MultiTextureFragShaderSrc
+ MultiTextureFragShaderSrc,
+ PostProcessMeshFragShaderSrc,
+ PostProcessMeshTimewarpFragShaderSrc,
+ PostProcessMeshPositionalTimewarpFragShaderSrc
};
-
-RenderDevice::RenderDevice(const RendererParams& p)
+RenderDevice::RenderDevice(const RendererParams&)
{
for (int i = 0; i < VShader_Count; i++)
VertexShaders[i] = *new Shader(this, Shader_Vertex, VShaderSrcs[i]);
@@ -278,6 +629,37 @@ RenderDevice::RenderDevice(const RendererParams& p)
glGenFramebuffersEXT(1, &CurrentFbo);
}
+RenderDevice::~RenderDevice()
+{
+ Shutdown();
+}
+
+void RenderDevice::Shutdown()
+{
+ // Release any other resources first.
+ OVR::Render::RenderDevice::Shutdown();
+
+ // This runs before the subclass's Shutdown(), where the context, etc, may be deleted.
+
+ glDeleteFramebuffersEXT(1, &CurrentFbo);
+
+ for (int i = 0; i < VShader_Count; ++i)
+ VertexShaders[i].Clear();
+
+ for (int i = 0; i < FShader_Count; ++i)
+ FragShaders[i].Clear();
+
+ DefaultFill.Clear();
+ DepthBuffers.Clear();
+}
+
+
+void RenderDevice::FillTexturedRect(float left, float top, float right, float bottom, float ul, float vt, float ur, float vb, Color c, Ptr<OVR::Render::Texture> tex)
+{
+ Render::RenderDevice::FillTexturedRect(left, top, right, bottom, ul, vb, ur, vt, c, tex);
+}
+
+
Shader *RenderDevice::LoadBuiltinShader(ShaderStage stage, int shader)
{
switch (stage)
@@ -323,7 +705,7 @@ void RenderDevice::SetDepthMode(bool enable, bool write, CompareFunc func)
glDisable(GL_DEPTH_TEST);
}
-void RenderDevice::SetRealViewport(const Viewport& vp)
+void RenderDevice::SetViewport(const Recti& vp)
{
int wh;
if (CurRenderTarget)
@@ -332,30 +714,38 @@ void RenderDevice::SetRealViewport(const Viewport& vp)
wh = WindowHeight;
glViewport(vp.x, wh-vp.y-vp.h, vp.w, vp.h);
- glEnable(GL_SCISSOR_TEST);
- glScissor(vp.x, wh-vp.y-vp.h, vp.w, vp.h);
+ //glEnable(GL_SCISSOR_TEST);
+ //glScissor(vp.x, wh-vp.y-vp.h, vp.w, vp.h);
}
-void RenderDevice::Clear(float r, float g, float b, float a, float depth)
+void RenderDevice::WaitUntilGpuIdle()
{
- glClearColor(r,g,b,a);
- glClearDepth(depth);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
+ glFlush();
+ glFinish();
}
-RBuffer* RenderDevice::GetDepthBuffer(int w, int h, int ms)
+void RenderDevice::Clear(float r, float g, float b, float a, float depth, bool clearColor /*= true*/, bool clearDepth /*= true*/)
+{
+ glClearColor(r,g,b,a);
+ glClearDepth(depth);
+ glClear(
+ ( clearColor ? ( GL_COLOR_BUFFER_BIT ) : 0 ) |
+ ( clearDepth ? ( GL_DEPTH_BUFFER_BIT ) : 0 )
+ );
+}
+
+Texture* RenderDevice::GetDepthBuffer(int w, int h, int ms)
{
for (unsigned i = 0; i < DepthBuffers.GetSize(); i++)
- if (w == DepthBuffers[i]->Width && h == DepthBuffers[i]->Height)// && ms == DepthBuffers[i]->Samples)
+ if (w == DepthBuffers[i]->Width && h == DepthBuffers[i]->Height && ms == DepthBuffers[i]->GetSamples())
return DepthBuffers[i];
- //Ptr<Texture> newDepth = *CreateTexture(Texture_Depth|Texture_RenderTarget|ms, w, h, NULL);
- Ptr<RBuffer> newDepth = *new RBuffer(GL_DEPTH24_STENCIL8, w, h); // combined depth stencil
+ Ptr<Texture> newDepth = *CreateTexture(Texture_Depth|Texture_RenderTarget|ms, w, h, NULL);
DepthBuffers.PushBack(newDepth);
return newDepth.GetPtr();
}
-void RenderDevice::SetRenderTarget(Render::Texture* color, Render::Texture*, Render::Texture* stencil)
+void RenderDevice::SetRenderTarget(Render::Texture* color, Render::Texture* depth, Render::Texture* stencil)
{
OVR_UNUSED(stencil);
@@ -365,14 +755,14 @@ void RenderDevice::SetRenderTarget(Render::Texture* color, Render::Texture*, Ren
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
return;
}
- //if (depth == NULL)
- RBuffer* depth = GetDepthBuffer(color->GetWidth(), color->GetHeight(), 0); //CurRenderTarget->Samples);
+
+ if (depth == NULL)
+ depth = GetDepthBuffer(color->GetWidth(), color->GetHeight(), CurRenderTarget->GetSamples());
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, CurrentFbo);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, ((Texture*)color)->TexId, 0);
if (depth)
- //glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, ((Texture*)depth)->TexId, 0);
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, ((RBuffer*)depth)->BufId);
+ glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, ((Texture*)depth)->TexId, 0);
else
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0);
@@ -404,8 +794,7 @@ Fill* RenderDevice::CreateSimpleFill(int flags)
OVR_UNUSED(flags);
return DefaultFill;
}
-
-
+
void RenderDevice::Render(const Matrix4f& matrix, Model* model)
{
// Store data in buffers if not already
@@ -428,7 +817,7 @@ void RenderDevice::Render(const Matrix4f& matrix, Model* model)
}
void RenderDevice::Render(const Fill* fill, Render::Buffer* vertices, Render::Buffer* indices,
- const Matrix4f& matrix, int offset, int count, PrimitiveType rprim)
+ const Matrix4f& matrix, int offset, int count, PrimitiveType rprim, bool useDistortionVertex/* = false*/)
{
ShaderSet* shaders = (ShaderSet*) ((ShaderFill*)fill)->GetShaders();
@@ -461,15 +850,26 @@ void RenderDevice::Render(const Fill* fill, Render::Buffer* vertices, Render::Bu
Lighting->Set(shaders);
}
- glBindBuffer(GL_ARRAY_BUFFER, ((Buffer*)vertices)->GLBuffer);
- for (int i = 0; i < 5; i++)
- glEnableVertexAttribArray(i);
-
- glVertexAttribPointer(0, 3, GL_FLOAT, false, sizeof(Vertex), (char*)offset + offsetof(Vertex, Pos));
- glVertexAttribPointer(1, 4, GL_UNSIGNED_BYTE, true, sizeof(Vertex), (char*)offset + offsetof(Vertex, C));
- glVertexAttribPointer(2, 2, GL_FLOAT, false, sizeof(Vertex), (char*)offset + offsetof(Vertex, U));
- glVertexAttribPointer(3, 2, GL_FLOAT, false, sizeof(Vertex), (char*)offset + offsetof(Vertex, U2));
- glVertexAttribPointer(4, 3, GL_FLOAT, false, sizeof(Vertex), (char*)offset + offsetof(Vertex, Norm));
+ glBindBuffer(GL_ARRAY_BUFFER, ((Buffer*)vertices)->GLBuffer);
+ for (int i = 0; i < 5; i++)
+ glEnableVertexAttribArray(i);
+
+ if (useDistortionVertex)
+ {
+ glVertexAttribPointer(0, 2, GL_FLOAT, false, sizeof(DistortionVertex), (char*)offset + offsetof(DistortionVertex, Pos));
+ glVertexAttribPointer(1, 4, GL_UNSIGNED_BYTE, true, sizeof(DistortionVertex), (char*)offset + offsetof(DistortionVertex, Col));
+ glVertexAttribPointer(2, 2, GL_FLOAT, false, sizeof(DistortionVertex), (char*)offset + offsetof(DistortionVertex, TexR));
+ glVertexAttribPointer(3, 2, GL_FLOAT, false, sizeof(DistortionVertex), (char*)offset + offsetof(DistortionVertex, TexG));
+ glVertexAttribPointer(4, 2, GL_FLOAT, false, sizeof(DistortionVertex), (char*)offset + offsetof(DistortionVertex, TexB));
+ }
+ else
+ {
+ glVertexAttribPointer(0, 3, GL_FLOAT, false, sizeof(Vertex), (char*)offset + offsetof(Vertex, Pos));
+ glVertexAttribPointer(1, 4, GL_UNSIGNED_BYTE, true, sizeof(Vertex), (char*)offset + offsetof(Vertex, C));
+ glVertexAttribPointer(2, 2, GL_FLOAT, false, sizeof(Vertex), (char*)offset + offsetof(Vertex, U));
+ glVertexAttribPointer(3, 2, GL_FLOAT, false, sizeof(Vertex), (char*)offset + offsetof(Vertex, U2));
+ glVertexAttribPointer(4, 3, GL_FLOAT, false, sizeof(Vertex), (char*)offset + offsetof(Vertex, Norm));
+ }
if (indices)
{
@@ -482,8 +882,8 @@ void RenderDevice::Render(const Fill* fill, Render::Buffer* vertices, Render::Bu
glDrawArrays(prim, 0, count);
}
- for (int i = 0; i < 5; i++)
- glDisableVertexAttribArray(i);
+ for (int i = 0; i < 5; i++)
+ glDisableVertexAttribArray(i);
}
void RenderDevice::RenderWithAlpha(const Fill* fill, Render::Buffer* vertices, Render::Buffer* indices,
@@ -526,7 +926,7 @@ bool Buffer::Data(int use, const void* buffer, size_t size)
return 1;
}
-void* Buffer::Map(size_t start, size_t size, int flags)
+void* Buffer::Map(size_t, size_t, int)
{
int mode = GL_WRITE_ONLY;
//if (flags & Map_Unsynchronized)
@@ -543,7 +943,13 @@ bool Buffer::Unmap(void*)
glBindBuffer(Use, GLBuffer);
int r = glUnmapBuffer(Use);
glBindBuffer(Use, 0);
- return r;
+ return r != 0;
+}
+
+Shader::~Shader()
+{
+ if (GLShader)
+ glDeleteShader(GLShader);
}
bool Shader::Compile(const char* src)
@@ -576,6 +982,24 @@ ShaderSet::~ShaderSet()
glDeleteProgram(Prog);
}
+void ShaderSet::SetShader(Render::Shader *s)
+{
+ Shaders[s->GetStage()] = s;
+ Shader* gls = (Shader*)s;
+ glAttachShader(Prog, gls->GLShader);
+ if (Shaders[Shader_Vertex] && Shaders[Shader_Fragment])
+ Link();
+}
+
+void ShaderSet::UnsetShader(int stage)
+{
+ Shader* gls = (Shader*)(Render::Shader*)Shaders[stage];
+ if (gls)
+ glDetachShader(Prog, gls->GLShader);
+ Shaders[stage] = NULL;
+ Link();
+}
+
bool ShaderSet::Link()
{
glBindAttribLocation(Prog, 0, "Position");
@@ -600,14 +1024,19 @@ bool ShaderSet::Link()
UniformInfo.Clear();
LightingVer = 0;
UsesLighting = 0;
- GLuint i = 0;
- for(;; i++)
+
+ GLint uniformCount = 0;
+ glGetProgramiv(Prog, GL_ACTIVE_UNIFORMS, &uniformCount);
+ OVR_ASSERT(uniformCount >= 0);
+
+ for(GLuint i = 0; i < (GLuint)uniformCount; i++)
{
GLsizei namelen;
GLint size = 0;
GLenum type;
GLchar name[32];
glGetActiveUniform(Prog, i, sizeof(name), &namelen, &size, &type, name);
+
if (size)
{
int l = glGetUniformLocation(Prog, name);
@@ -628,6 +1057,7 @@ bool ShaderSet::Link()
case GL_FLOAT_VEC2: u.Type = 2; break;
case GL_FLOAT_VEC3: u.Type = 3; break;
case GL_FLOAT_VEC4: u.Type = 4; break;
+ case GL_FLOAT_MAT3: u.Type = 12; break;
case GL_FLOAT_MAT4: u.Type = 16; break;
default:
continue;
@@ -645,7 +1075,7 @@ bool ShaderSet::Link()
for (int i = 0; i < 8; i++)
{
char texv[32];
- sprintf(texv, "Texture%d", i);
+ OVR_sprintf(texv, 10, "Texture%d", i);
TexLoc[i] = glGetUniformLocation(Prog, texv);
if (TexLoc[i] < 0)
break;
@@ -664,7 +1094,7 @@ void ShaderSet::Set(PrimitiveType) const
bool ShaderSet::SetUniform(const char* name, int n, const float* v)
{
- for (int i = 0; i < UniformInfo.GetSize(); i++)
+ for (unsigned int i = 0; i < UniformInfo.GetSize(); i++)
if (!strcmp(UniformInfo[i].Name.ToCStr(), name))
{
OVR_ASSERT(UniformInfo[i].Location >= 0);
@@ -675,6 +1105,8 @@ bool ShaderSet::SetUniform(const char* name, int n, const float* v)
case 2: glUniform2fv(UniformInfo[i].Location, n/2, v); break;
case 3: glUniform3fv(UniformInfo[i].Location, n/3, v); break;
case 4: glUniform4fv(UniformInfo[i].Location, n/4, v); break;
+ case 12: glUniformMatrix3fv(UniformInfo[i].Location, 1, 1, v); break;
+ case 16: glUniformMatrix4fv(UniformInfo[i].Location, 1, 1, v); break;
default: OVR_ASSERT(0);
}
return 1;
@@ -686,7 +1118,7 @@ bool ShaderSet::SetUniform(const char* name, int n, const float* v)
bool ShaderSet::SetUniform4x4f(const char* name, const Matrix4f& m)
{
- for (int i = 0; i < UniformInfo.GetSize(); i++)
+ for (unsigned int i = 0; i < UniformInfo.GetSize(); i++)
if (!strcmp(UniformInfo[i].Name.ToCStr(), name))
{
glUseProgram(Prog);
@@ -722,7 +1154,7 @@ void Texture::SetSampleMode(int sm)
case Sample_Linear:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 0);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1);
break;
case Sample_Anisotropic:
@@ -734,7 +1166,7 @@ void Texture::SetSampleMode(int sm)
case Sample_Nearest:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 0);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1);
break;
}
@@ -758,6 +1190,20 @@ void Texture::SetSampleMode(int sm)
glBindTexture(GL_TEXTURE_2D, 0);
}
+ovrTexture Texture::Get_ovrTexture()
+{
+ ovrTexture tex;
+ OVR::Sizei newRTSize(Width, Height);
+
+ ovrGLTextureData* texData = (ovrGLTextureData*)&tex;
+ texData->Header.API = ovrRenderAPI_OpenGL;
+ texData->Header.TextureSize = newRTSize;
+ texData->Header.RenderViewport = Recti(newRTSize);
+ texData->TexId = TexId;
+
+ return tex;
+}
+
Texture* RenderDevice::CreateTexture(int format, int width, int height, const void* data, int mipcount)
{
GLenum glformat, gltype = GL_UNSIGNED_BYTE;
@@ -765,7 +1211,7 @@ Texture* RenderDevice::CreateTexture(int format, int width, int height, const vo
{
case Texture_RGBA: glformat = GL_RGBA; break;
case Texture_R: glformat = GL_ALPHA; break;
- case Texture_Depth: glformat = GL_DEPTH; gltype = GL_DEPTH_COMPONENT; break;
+ case Texture_Depth: glformat = GL_DEPTH_COMPONENT32F; gltype = GL_FLOAT; break;
case Texture_DXT1: glformat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; break;
case Texture_DXT3: glformat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; break;
case Texture_DXT5: glformat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; break;
@@ -774,7 +1220,7 @@ Texture* RenderDevice::CreateTexture(int format, int width, int height, const vo
}
Texture* NewTex = new Texture(this, width, height);
glBindTexture(GL_TEXTURE_2D, NewTex->TexId);
- glGetError();
+ OVR_ASSERT(!glGetError());
if (format & Texture_Compressed)
{
@@ -792,6 +1238,8 @@ Texture* RenderDevice::CreateTexture(int format, int width, int height, const vo
if (h < 1) h = 1;
}
}
+ else if (format & Texture_Depth)
+ glTexImage2D(GL_TEXTURE_2D, 0, glformat, width, height, 0, GL_DEPTH_COMPONENT, gltype, data);
else
glTexImage2D(GL_TEXTURE_2D, 0, glformat, width, height, 0, glformat, gltype, data);
@@ -831,12 +1279,6 @@ Texture* RenderDevice::CreateTexture(int format, int width, int height, const vo
return NewTex;
}
-bool RenderDevice::SetFullscreen(DisplayMode fullscreen)
-{
- Params.Fullscreen = fullscreen;
- return true;
-}
-
RBuffer::RBuffer(GLenum format, GLint w, GLint h)
{
Width = w;
@@ -849,7 +1291,8 @@ RBuffer::RBuffer(GLenum format, GLint w, GLint h)
RBuffer::~RBuffer()
{
- glDeleteRenderbuffersEXT(1, &BufId);
+ if (BufId)
+ glDeleteRenderbuffersEXT(1, &BufId);
}
}}}
diff --git a/Samples/CommonSrc/Render/Render_GL_Device.h b/Samples/CommonSrc/Render/Render_GL_Device.h
index 88eaff4..5d97eef 100644
--- a/Samples/CommonSrc/Render/Render_GL_Device.h
+++ b/Samples/CommonSrc/Render/Render_GL_Device.h
@@ -34,13 +34,76 @@ limitations under the License.
#include <OpenGL/gl.h>
#include <OpenGL/glext.h>
#else
+#ifndef GL_GLEXT_PROTOTYPES
#define GL_GLEXT_PROTOTYPES
+#endif
#include <GL/gl.h>
#include <GL/glext.h>
+#if defined(OVR_OS_WIN32)
+#include <GL/wglext.h>
+#endif
#endif
namespace OVR { namespace Render { namespace GL {
+// GL extension Hooks for PC.
+#if defined(OVR_OS_WIN32)
+
+extern PFNWGLGETSWAPINTERVALEXTPROC wglGetSwapIntervalEXT;
+extern PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT;
+extern PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT;
+extern PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT;
+extern PFNGLDELETESHADERPROC glDeleteShader;
+extern PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT;
+extern PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glFramebufferRenderbufferEXT;
+extern PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT;
+extern PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT;
+extern PFNGLACTIVETEXTUREPROC glActiveTexture;
+extern PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray;
+extern PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
+extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray;
+extern PFNGLBINDBUFFERPROC glBindBuffer;
+extern PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv;
+extern PFNGLDELETEBUFFERSPROC glDeleteBuffers;
+extern PFNGLBUFFERDATAPROC glBufferData;
+extern PFNGLGENBUFFERSPROC glGenBuffers;
+extern PFNGLMAPBUFFERPROC glMapBuffer;
+extern PFNGLUNMAPBUFFERPROC glUnmapBuffer;
+extern PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog;
+extern PFNGLGETSHADERIVPROC glGetShaderiv;
+extern PFNGLCOMPILESHADERPROC glCompileShader;
+extern PFNGLSHADERSOURCEPROC glShaderSource;
+extern PFNGLCREATESHADERPROC glCreateShader;
+extern PFNGLCREATEPROGRAMPROC glCreateProgram;
+extern PFNGLATTACHSHADERPROC glAttachShader;
+extern PFNGLDETACHSHADERPROC glDetachShader;
+extern PFNGLDELETEPROGRAMPROC glDeleteProgram;
+extern PFNGLUNIFORM1IPROC glUniform1i;
+extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;
+extern PFNGLGETACTIVEUNIFORMPROC glGetActiveUniform;
+extern PFNGLUSEPROGRAMPROC glUseProgram;
+extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
+extern PFNGLGETPROGRAMIVPROC glGetProgramiv;
+extern PFNGLLINKPROGRAMPROC glLinkProgram;
+extern PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation;
+extern PFNGLUNIFORM4FVPROC glUniform4fv;
+extern PFNGLUNIFORM3FVPROC glUniform3fv;
+extern PFNGLUNIFORM2FVPROC glUniform2fv;
+extern PFNGLUNIFORM1FVPROC glUniform1fv;
+extern PFNGLCOMPRESSEDTEXIMAGE2DPROC glCompressedTexImage2D;
+extern PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT;
+extern PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT;
+extern PFNGLGENRENDERBUFFERSEXTPROC glGenRenderbuffersEXT;
+extern PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT;
+
+// For testing
+extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
+
+extern void InitGLExtensions();
+
+#endif
+
+
class RenderDevice;
class Buffer : public Render::Buffer
@@ -77,6 +140,7 @@ public:
virtual int GetHeight() const { return Height; }
virtual void SetSampleMode(int);
+ virtual ovrTexture Get_ovrTexture();
virtual void Set(int slot, ShaderStage stage = Shader_Fragment) const;
};
@@ -91,11 +155,8 @@ public:
{
Compile(src);
}
- ~Shader()
- {
- if (GLShader)
- glDeleteShader(GLShader);
- }
+
+ ~Shader();
bool Compile(const char* src);
GLenum GLStage() const
@@ -133,22 +194,8 @@ public:
ShaderSet();
~ShaderSet();
- virtual void SetShader(Render::Shader *s)
- {
- Shaders[s->GetStage()] = s;
- Shader* gls = (Shader*)s;
- glAttachShader(Prog, gls->GLShader);
- if (Shaders[Shader_Vertex] && Shaders[Shader_Fragment])
- Link();
- }
- virtual void UnsetShader(int stage)
- {
- Shader* gls = (Shader*)(Render::Shader*)Shaders[stage];
- if (gls)
- glDetachShader(Prog, gls->GLShader);
- Shaders[stage] = NULL;
- Link();
- }
+ virtual void SetShader(Render::Shader *s);
+ virtual void UnsetShader(int stage);
virtual void Set(PrimitiveType prim) const;
@@ -161,7 +208,7 @@ public:
bool Link();
};
- class RBuffer : public RefCountBase<RBuffer>
+class RBuffer : public RefCountBase<RBuffer>
{
public:
int Width, Height;
@@ -180,28 +227,38 @@ class RenderDevice : public Render::RenderDevice
Matrix4f Proj;
+protected:
Ptr<Texture> CurRenderTarget;
- Array<Ptr<RBuffer> > DepthBuffers;
+ Array<Ptr<Texture> > DepthBuffers;
GLuint CurrentFbo;
const LightingParams* Lighting;
public:
RenderDevice(const RendererParams& p);
+ virtual ~RenderDevice();
- virtual void SetRealViewport(const Viewport& vp);
+ virtual void Shutdown();
+
+ virtual void FillTexturedRect(float left, float top, float right, float bottom, float ul, float vt, float ur, float vb, Color c, Ptr<OVR::Render::Texture> tex);
+
+ virtual void SetViewport(const Recti& vp);
//virtual void SetScissor(int x, int y, int w, int h);
+
+ virtual void WaitUntilGpuIdle();
- virtual void Clear(float r = 0, float g = 0, float b = 0, float a = 1, float depth = 1);
+ virtual void Clear(float r = 0, float g = 0, float b = 0, float a = 1, float depth = 1,
+ bool clearColor = true, bool clearDepth = true);
virtual void Rect(float left, float top, float right, float bottom) { OVR_UNUSED4(left,top,right,bottom); }
virtual void BeginRendering();
virtual void SetDepthMode(bool enable, bool write, CompareFunc func = Compare_Less);
virtual void SetWorldUniforms(const Matrix4f& proj);
- RBuffer* GetDepthBuffer(int w, int h, int ms);
+ Texture* GetDepthBuffer(int w, int h, int ms);
+ virtual void Present (bool withVsync){OVR_UNUSED(withVsync);};
virtual void SetRenderTarget(Render::Texture* color,
Render::Texture* depth = NULL, Render::Texture* stencil = NULL);
@@ -209,7 +266,7 @@ public:
virtual void Render(const Matrix4f& matrix, Model* model);
virtual void Render(const Fill* fill, Render::Buffer* vertices, Render::Buffer* indices,
- const Matrix4f& matrix, int offset, int count, PrimitiveType prim = Prim_Triangles);
+ const Matrix4f& matrix, int offset, int count, PrimitiveType prim = Prim_Triangles, bool useDistortionVertex = false);
virtual void RenderWithAlpha(const Fill* fill, Render::Buffer* vertices, Render::Buffer* indices,
const Matrix4f& matrix, int offset, int count, PrimitiveType prim = Prim_Triangles);
@@ -222,8 +279,6 @@ public:
virtual Shader *LoadBuiltinShader(ShaderStage stage, int shader);
void SetTexture(Render::ShaderStage, int slot, const Texture* t);
-
- virtual bool SetFullscreen(DisplayMode fullscreen);
};
}}}
diff --git a/Samples/CommonSrc/Render/Render_GL_Win32_Device.cpp b/Samples/CommonSrc/Render/Render_GL_Win32_Device.cpp
index 4f22a50..1065c98 100644
--- a/Samples/CommonSrc/Render/Render_GL_Win32_Device.cpp
+++ b/Samples/CommonSrc/Render/Render_GL_Win32_Device.cpp
@@ -3,7 +3,7 @@
Filename : Render_GL_Win32 Device.cpp
Content : Win32 OpenGL Device implementation
Created : September 10, 2012
-Authors : Andrew Reisse, Michael Antonov
+Authors : Andrew Reisse, Michael Antonov, David Borel
Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
@@ -22,16 +22,46 @@ limitations under the License.
************************************************************************************/
#include "Render_GL_Win32_Device.h"
+#include "OVR_CAPI_GL.h"
+
+#include <dwmapi.h>
namespace OVR { namespace Render { namespace GL { namespace Win32 {
+typedef HRESULT (__stdcall *PFNDWMENABLECOMPOSITIONPROC) (UINT);
+
+#pragma warning(disable : 4995)
+PFNDWMENABLECOMPOSITIONPROC DwmEnableComposition;
+
// ***** GL::Win32::RenderDevice
+
+RenderDevice::RenderDevice(const Render::RendererParams& p, HWND win, HDC dc, HGLRC gl)
+ : GL::RenderDevice(p)
+ , Window(win)
+ , WglContext(gl)
+ , GdiDc(dc)
+ , PreFullscreen(0, 0, 0, 0)
+ , HMonitor(0)
+ , FSDesktop(0, 0, 0, 0)
+{
+ OVR_UNUSED(p);
+}
// Implement static initializer function to create this class.
-Render::RenderDevice* RenderDevice::CreateDevice(const RendererParams&, void* oswnd)
+Render::RenderDevice* RenderDevice::CreateDevice(const RendererParams& rp, void* oswnd)
{
HWND hwnd = (HWND)oswnd;
+
+ if (!DwmEnableComposition)
+ {
+ HINSTANCE hInst = LoadLibrary( L"dwmapi.dll" );
+ OVR_ASSERT(hInst);
+ DwmEnableComposition = (PFNDWMENABLECOMPOSITIONPROC)GetProcAddress( hInst, "DwmEnableComposition" );
+ OVR_ASSERT(DwmEnableComposition);
+ }
+
+ DwmEnableComposition(DWM_EC_DISABLECOMPOSITION);
PIXELFORMATDESCRIPTOR pfd;
memset(&pfd, 0, sizeof(pfd));
@@ -63,18 +93,40 @@ Render::RenderDevice* RenderDevice::CreateDevice(const RendererParams&, void* os
return NULL;
}
- // return new RenderDevice(rp, hwnd, dc, context);
- return 0;
+ InitGLExtensions();
+
+ return new RenderDevice(rp, hwnd, dc, context);
}
+ovrRenderAPIConfig RenderDevice::Get_ovrRenderAPIConfig() const
+{
+ static ovrGLConfig cfg;
+ cfg.OGL.Header.API = ovrRenderAPI_OpenGL;
+ cfg.OGL.Header.RTSize = Sizei(WindowWidth, WindowHeight);
+ cfg.OGL.Header.Multisample = Params.Multisample;
+ cfg.OGL.WglContext = WglContext;
+ cfg.OGL.Window = Window;
+ cfg.OGL.GdiDc = GdiDc;
-void RenderDevice::Present()
+ return cfg.Config;
+}
+
+void RenderDevice::Present(bool useVsync)
{
- SwapBuffers(GdiDc);
+ BOOL success;
+ int swapInterval = (useVsync) ? 1 : 0;
+ if (wglGetSwapIntervalEXT() != swapInterval)
+ wglSwapIntervalEXT(swapInterval);
+
+ success = SwapBuffers(GdiDc);
+ OVR_ASSERT(success);
}
void RenderDevice::Shutdown()
{
+ //Release any remaining GL resources.
+ GL::RenderDevice::Shutdown();
+
if (WglContext)
{
wglMakeCurrent(NULL,NULL);
@@ -86,5 +138,189 @@ void RenderDevice::Shutdown()
}
}
+bool RenderDevice::SetParams(const RendererParams& newParams)
+{
+ Params = newParams;
+ //TODO: Apply changes now.
+ return true;
+}
+
+BOOL CALLBACK MonitorEnumFunc(HMONITOR hMonitor, HDC, LPRECT, LPARAM dwData)
+{
+ RenderDevice* renderer = (RenderDevice*)dwData;
+
+ MONITORINFOEX monitor;
+ monitor.cbSize = sizeof(monitor);
+
+ if (::GetMonitorInfo(hMonitor, &monitor) && monitor.szDevice[0])
+ {
+ DISPLAY_DEVICE dispDev;
+ memset(&dispDev, 0, sizeof(dispDev));
+ dispDev.cb = sizeof(dispDev);
+
+ if (::EnumDisplayDevices(monitor.szDevice, 0, &dispDev, 0))
+ {
+ if (strstr(String(dispDev.DeviceName).ToCStr(), renderer->GetParams().Display.MonitorName.ToCStr()))
+ {
+ renderer->HMonitor = hMonitor;
+ renderer->FSDesktop.x = monitor.rcMonitor.left;
+ renderer->FSDesktop.y = monitor.rcMonitor.top;
+ renderer->FSDesktop.w = monitor.rcMonitor.right - monitor.rcMonitor.left;
+ renderer->FSDesktop.h = monitor.rcMonitor.bottom - monitor.rcMonitor.top;
+ return FALSE;
+ }
+ }
+ }
+
+ return TRUE;
+}
+
+bool RenderDevice::SetFullscreen(DisplayMode fullscreen)
+{
+ if (fullscreen == Params.Fullscreen)
+ {
+ return true;
+ }
+
+ if (Params.Fullscreen == Display_FakeFullscreen)
+ {
+ SetWindowLong(Window, GWL_STYLE, WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPSIBLINGS);
+ SetWindowPos(Window, HWND_NOTOPMOST, PreFullscreen.x, PreFullscreen.y,
+ PreFullscreen.w, PreFullscreen.h, SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
+ }
+ else if (Params.Fullscreen == Display_Fullscreen)
+ {
+ {
+ // Find out the name of the device this window
+ // is on (this is for multi-monitor setups)
+ HMONITOR hMonitor = MonitorFromWindow(Window, MONITOR_DEFAULTTOPRIMARY);
+ MONITORINFOEX monInfo;
+ memset(&monInfo, 0, sizeof(MONITORINFOEX));
+ monInfo.cbSize = sizeof(MONITORINFOEX);
+ GetMonitorInfo(hMonitor, &monInfo);
+
+ // Restore the display resolution
+ ChangeDisplaySettingsEx(monInfo.szDevice, NULL, NULL, 0, NULL);
+ //ChangeDisplaySettings(NULL, 0);
+ }
+ {
+ // Restore the window styles
+ DWORD style = (DWORD)GetWindowLongPtr(Window, GWL_STYLE);
+ DWORD exstyle = (DWORD)GetWindowLongPtr(Window, GWL_EXSTYLE);
+ SetWindowLongPtr(Window, GWL_STYLE, style | WS_OVERLAPPEDWINDOW);
+ SetWindowLongPtr(Window, GWL_EXSTYLE, exstyle & (~(WS_EX_APPWINDOW | WS_EX_TOPMOST)));
+
+ MONITORINFOEX monInfo;
+ memset(&monInfo, 0, sizeof(MONITORINFOEX));
+ monInfo.cbSize = sizeof(MONITORINFOEX);
+ GetMonitorInfo(HMonitor, &monInfo);
+
+ // Restore the window size/position
+ SetWindowPos(Window, NULL, PreFullscreen.x, PreFullscreen.y, PreFullscreen.w, PreFullscreen.h,
+ SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_NOOWNERZORDER | SWP_NOREPOSITION | SWP_NOZORDER);
+ }
+ }
+
+
+ if (!Params.Display.MonitorName.IsEmpty())
+ {
+ EnumDisplayMonitors(0, 0, MonitorEnumFunc, (LPARAM)this);
+ }
+
+ if (fullscreen == Display_FakeFullscreen)
+ {
+ // Get WINDOWPLACEMENT before changing style to get OVERLAPPED coordinates,
+ // which we will restore.
+ WINDOWPLACEMENT wp;
+ wp.length = sizeof(wp);
+ GetWindowPlacement(Window, &wp);
+ PreFullscreen.w = wp.rcNormalPosition.right - wp.rcNormalPosition.left;
+ PreFullscreen.h = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top;
+ PreFullscreen.x = wp.rcNormalPosition.left;
+ PreFullscreen.y = wp.rcNormalPosition.top;
+ // Warning: SetWindowLong sends message computed based on old size (incorrect).
+ // A proper work-around would be to mask that message out during window frame change in Platform.
+ SetWindowLong(Window, GWL_STYLE, WS_OVERLAPPED | WS_VISIBLE | WS_CLIPSIBLINGS);
+ SetWindowPos(Window, NULL, FSDesktop.x, FSDesktop.y, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | SWP_FRAMECHANGED);
+
+ // Relocate cursor into the window to avoid losing focus on first click.
+ POINT oldCursor;
+ if (GetCursorPos(&oldCursor) &&
+ ((oldCursor.x < FSDesktop.x) || (oldCursor.x > (FSDesktop.x + PreFullscreen.w)) ||
+ (oldCursor.y < FSDesktop.y) || (oldCursor.x > (FSDesktop.y + PreFullscreen.h))))
+ {
+ // TBD: FullScreen window logic should really be in platform; it causes world rotation
+ // in relative mouse mode.
+ ::SetCursorPos(FSDesktop.x, FSDesktop.y);
+ }
+ }
+ else if (fullscreen == Display_Fullscreen)
+ {
+ // Find out the name of the device this window
+ // is on (this is for multi-monitor setups)
+ MONITORINFOEX monInfo;
+ memset(&monInfo, 0, sizeof(MONITORINFOEX));
+ monInfo.cbSize = sizeof(MONITORINFOEX);
+ GetMonitorInfo(HMonitor, &monInfo);
+
+ // Find the requested device mode
+ DEVMODE dmode;
+ bool foundMode = false;
+ memset(&dmode, 0, sizeof(DEVMODE));
+ dmode.dmSize = sizeof(DEVMODE);
+ Recti vp = VP;
+ for(int i=0 ; EnumDisplaySettings(monInfo.szDevice, i, &dmode); ++i)
+ {
+ foundMode = (dmode.dmPelsWidth==(DWORD)vp.w) &&
+ (dmode.dmPelsHeight==(DWORD)vp.h) &&
+ (dmode.dmBitsPerPel==(DWORD)32);
+ if (foundMode)
+ break;
+ }
+ if(!foundMode)
+ return false;
+
+ dmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
+
+ // Save the current window position/size
+ RECT rect;
+ GetWindowRect(Window, &rect);
+ PreFullscreen.x = rect.left;
+ PreFullscreen.y = rect.top;
+ PreFullscreen.w = rect.right - rect.left;
+ PreFullscreen.h = rect.bottom - rect.top;
+
+ // Save the window style and set it for fullscreen mode
+ DWORD style = (DWORD)GetWindowLongPtr(Window, GWL_STYLE);
+ DWORD exstyle = (DWORD)GetWindowLongPtr(Window, GWL_EXSTYLE);
+ SetWindowLongPtr(Window, GWL_STYLE, style & (~WS_OVERLAPPEDWINDOW));
+ SetWindowLongPtr(Window, GWL_EXSTYLE, exstyle | WS_EX_APPWINDOW | WS_EX_TOPMOST);
+
+ // Attempt to change the resolution
+ LONG ret = ChangeDisplaySettingsEx(monInfo.szDevice, &dmode, NULL, CDS_FULLSCREEN, NULL);
+ //LONG ret = ChangeDisplaySettings(&dmode, CDS_FULLSCREEN);
+
+ // If it failed, clean up and return.
+ if (ret != DISP_CHANGE_SUCCESSFUL)
+ {
+ SetWindowLongPtr(Window, GWL_STYLE, style);
+ SetWindowLongPtr(Window, GWL_EXSTYLE, exstyle);
+ return false;
+ }
+
+ // We need to call GetMonitorInfo() again becase
+ // details may have changed with the resolution
+ GetMonitorInfo(HMonitor, &monInfo);
+
+ // Set the window's size and position so
+ // that it covers the entire screen
+ SetWindowPos(Window, HWND_TOPMOST, monInfo.rcMonitor.left, monInfo.rcMonitor.top, vp.w, vp.h,
+ SWP_SHOWWINDOW | SWP_NOZORDER | SWP_FRAMECHANGED);
+ }
+
+ Params.Fullscreen = fullscreen;
+ return true;
+}
+
}}}}
diff --git a/Samples/CommonSrc/Render/Render_GL_Win32_Device.h b/Samples/CommonSrc/Render/Render_GL_Win32_Device.h
index f63b1d0..de81a80 100644
--- a/Samples/CommonSrc/Render/Render_GL_Win32_Device.h
+++ b/Samples/CommonSrc/Render/Render_GL_Win32_Device.h
@@ -3,7 +3,7 @@
Filename : Render_GL_Win32 Device.h
Content : Win32 OpenGL Device implementation header
Created : September 10, 2012
-Authors : Andrew Reisse, Michael Antonov
+Authors : Andrew Reisse, Michael Antonov, David Borel
Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
@@ -38,19 +38,29 @@ namespace OVR { namespace Render { namespace GL { namespace Win32 {
// Win32-Specific GL Render Device, used to create OpenGL under Windows.
class RenderDevice : public GL::RenderDevice
{
- HWND Window;
- HGLRC WglContext;
- HDC GdiDc;
+ friend BOOL CALLBACK MonitorEnumFunc(HMONITOR hMonitor, HDC, LPRECT, LPARAM dwData);
+
+ HWND Window;
+ HGLRC WglContext;
+ HDC GdiDc;
+ Recti PreFullscreen;
+ Recti FSDesktop;
+ HMONITOR HMonitor;
public:
- RenderDevice(const Render::RendererParams& p, HWND win, HDC dc, HGLRC gl)
- : GL::RenderDevice(p), Window(win), WglContext(gl), GdiDc(dc) { OVR_UNUSED(p); }
+ RenderDevice(const Render::RendererParams& p, HWND win, HDC dc, HGLRC gl);
+ virtual ~RenderDevice() { Shutdown(); }
// Implement static initializer function to create this class.
static Render::RenderDevice* CreateDevice(const RendererParams& rp, void* oswnd);
+
+ virtual ovrRenderAPIConfig Get_ovrRenderAPIConfig() const;
virtual void Shutdown();
- virtual void Present();
+ virtual void Present(bool withVsync);
+ bool SetParams(const RendererParams& newParams);
+
+ virtual bool SetFullscreen(DisplayMode fullscreen);
};
diff --git a/Samples/CommonSrc/Render/Render_LoadTextureDDS.cpp b/Samples/CommonSrc/Render/Render_LoadTextureDDS.cpp
index b2b4b31..5bbdb21 100644
--- a/Samples/CommonSrc/Render/Render_LoadTextureDDS.cpp
+++ b/Samples/CommonSrc/Render/Render_LoadTextureDDS.cpp
@@ -5,7 +5,7 @@ Content : A DDS file loader for cross-platform compressed texture support.
Created : March 5, 2013
Authors : Peter Hoff, Dan Goodman, Bryan Croteau
-Copyright : Copyright 2013 Oculus VR, Inc. All Rights reserved.
+Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -75,10 +75,10 @@ Texture* LoadTextureDDS(RenderDevice* ren, File* f)
f->Read((unsigned char*)(&header), sizeof(header));
- int width = header.Width;
+ int width = header.Width;
int height = header.Height;
- int format = 0;
+ int format = Texture_RGBA;
UInt32 mipCount = header.MipMapCount;
if(mipCount <= 0)
diff --git a/Samples/CommonSrc/Render/Render_XmlSceneLoader.cpp b/Samples/CommonSrc/Render/Render_XmlSceneLoader.cpp
index b2b1ac1..5f31250 100644
--- a/Samples/CommonSrc/Render/Render_XmlSceneLoader.cpp
+++ b/Samples/CommonSrc/Render/Render_XmlSceneLoader.cpp
@@ -5,7 +5,7 @@ Content : Imports and exports XML files - implementation
Created : January 21, 2013
Authors : Robotic Arm Software - Peter Hoff, Dan Goodman, Bryan Croteau
-Copyright : Copyright 2013 Oculus VR, Inc. All Rights reserved.
+Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -121,6 +121,7 @@ bool XmlHandler::ReadFile(const char* fileName, OVR::Render::RenderDevice* pRend
OVR_DEBUG_LOG_TEXT(("%i models remaining...", modelCount - i));
}
Models.PushBack(*new Model(Prim_Triangles));
+ const char* name = pXmlModel->Attribute("name");
bool isCollisionModel = false;
pXmlModel->QueryBoolAttribute("isCollisionModel", &isCollisionModel);
Models[i]->IsCollisionModel = isCollisionModel;
@@ -129,6 +130,8 @@ bool XmlHandler::ReadFile(const char* fileName, OVR::Render::RenderDevice* pRend
Models[i]->Visible = false;
}
+ bool tree_c = (strcmp(name, "tree_C") == 0) || (strcmp(name, "Object03") == 0);
+
//read the vertices
OVR::Array<Vector3f> *vertices = new OVR::Array<Vector3f>();
ParseVectorString(pXmlModel->FirstChildElement("vertices")->FirstChild()->
@@ -137,6 +140,11 @@ bool XmlHandler::ReadFile(const char* fileName, OVR::Render::RenderDevice* pRend
for (unsigned int vertexIndex = 0; vertexIndex < vertices->GetSize(); ++vertexIndex)
{
vertices->At(vertexIndex).x *= -1.0f;
+
+ if (tree_c)
+ { // Move the terrace tree closer to the house
+ vertices->At(vertexIndex).z += 0.5;
+ }
}
//read the normals
@@ -237,6 +245,7 @@ bool XmlHandler::ReadFile(const char* fileName, OVR::Render::RenderDevice* pRend
// Read the vertex indices for the triangles
const char* indexStr = pXmlModel->FirstChildElement("indices")->
FirstChild()->ToText()->Value();
+
UPInt stringLength = strlen(indexStr);
for(UPInt j = 0; j < stringLength; )
@@ -306,6 +315,8 @@ bool XmlHandler::ReadFile(const char* fileName, OVR::Render::RenderDevice* pRend
float D;
pXmlPlane->QueryFloatAttribute("d", &D);
D -= 0.5f;
+ if (i == 26)
+ D += 0.5f; // tighten the terrace collision so player can move right up to rail
Planef p(norm.z, norm.y, norm.x * -1.0f, D);
cm->Add(p);
pXmlPlane = pXmlPlane->NextSiblingElement("plane");
diff --git a/Samples/CommonSrc/Render/Render_XmlSceneLoader.h b/Samples/CommonSrc/Render/Render_XmlSceneLoader.h
index 694fc2e..7dff174 100644
--- a/Samples/CommonSrc/Render/Render_XmlSceneLoader.h
+++ b/Samples/CommonSrc/Render/Render_XmlSceneLoader.h
@@ -5,7 +5,7 @@ Content : Imports and exports XML files
Created : January 21, 2013
Authors : Robotic Arm Software - Peter Hoff, Dan Goodman, Bryan Croteau
-Copyright : Copyright 2013 Oculus VR, Inc. All Rights reserved.
+Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/Samples/LibOVR_Samples_Msvc2010.sln b/Samples/LibOVR_Samples_Msvc2010.sln
deleted file mode 100644
index 41da1d9..0000000
--- a/Samples/LibOVR_Samples_Msvc2010.sln
+++ /dev/null
@@ -1,43 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OculusWorldDemo", "OculusWorldDemo\OculusWorldDemo_Msvc2010.vcxproj", "{8051B877-2992-4F64-8C3B-FAF88B6D83AA}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SensorBoxTest", "SensorBox\SensorBoxTest_Msvc2010.vcxproj", "{8051B837-2982-4F64-8C3B-FAF88B6D83AB}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OculusRoomTiny", "OculusRoomTiny\OculusRoomTiny_Msvc2010.vcxproj", "{80523489-2881-4F64-8C3B-FAF88B60ABCD}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Debug|x64 = Debug|x64
- Release|Win32 = Release|Win32
- Release|x64 = Release|x64
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {8051B877-2992-4F64-8C3B-FAF88B6D83AA}.Debug|Win32.ActiveCfg = Debug|Win32
- {8051B877-2992-4F64-8C3B-FAF88B6D83AA}.Debug|Win32.Build.0 = Debug|Win32
- {8051B877-2992-4F64-8C3B-FAF88B6D83AA}.Debug|x64.ActiveCfg = Debug|x64
- {8051B877-2992-4F64-8C3B-FAF88B6D83AA}.Debug|x64.Build.0 = Debug|x64
- {8051B877-2992-4F64-8C3B-FAF88B6D83AA}.Release|Win32.ActiveCfg = Release|Win32
- {8051B877-2992-4F64-8C3B-FAF88B6D83AA}.Release|Win32.Build.0 = Release|Win32
- {8051B877-2992-4F64-8C3B-FAF88B6D83AA}.Release|x64.ActiveCfg = Release|x64
- {8051B877-2992-4F64-8C3B-FAF88B6D83AA}.Release|x64.Build.0 = Release|x64
- {8051B837-2982-4F64-8C3B-FAF88B6D83AB}.Debug|Win32.ActiveCfg = Debug|Win32
- {8051B837-2982-4F64-8C3B-FAF88B6D83AB}.Debug|Win32.Build.0 = Debug|Win32
- {8051B837-2982-4F64-8C3B-FAF88B6D83AB}.Debug|x64.ActiveCfg = Debug|Win32
- {8051B837-2982-4F64-8C3B-FAF88B6D83AB}.Release|Win32.ActiveCfg = Release|Win32
- {8051B837-2982-4F64-8C3B-FAF88B6D83AB}.Release|Win32.Build.0 = Release|Win32
- {8051B837-2982-4F64-8C3B-FAF88B6D83AB}.Release|x64.ActiveCfg = Release|Win32
- {80523489-2881-4F64-8C3B-FAF88B60ABCD}.Debug|Win32.ActiveCfg = Debug|Win32
- {80523489-2881-4F64-8C3B-FAF88B60ABCD}.Debug|Win32.Build.0 = Debug|Win32
- {80523489-2881-4F64-8C3B-FAF88B60ABCD}.Debug|x64.ActiveCfg = Debug|x64
- {80523489-2881-4F64-8C3B-FAF88B60ABCD}.Debug|x64.Build.0 = Debug|x64
- {80523489-2881-4F64-8C3B-FAF88B60ABCD}.Release|Win32.ActiveCfg = Release|Win32
- {80523489-2881-4F64-8C3B-FAF88B60ABCD}.Release|Win32.Build.0 = Release|Win32
- {80523489-2881-4F64-8C3B-FAF88B60ABCD}.Release|x64.ActiveCfg = Release|x64
- {80523489-2881-4F64-8C3B-FAF88B60ABCD}.Release|x64.Build.0 = Release|x64
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/Samples/LibOVR_Samples_VS2010.sln b/Samples/LibOVR_Samples_VS2010.sln
new file mode 100644
index 0000000..182c95e
--- /dev/null
+++ b/Samples/LibOVR_Samples_VS2010.sln
@@ -0,0 +1,35 @@
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OculusRoomTiny", "OculusRoomTiny\Projects\Win\VS2010\OculusRoomTiny.vcxproj", "{6C6ECAC4-DB5C-4301-8371-9C7CC8C623C2}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OculusWorldDemo", "OculusWorldDemo\Projects\Win\VS2010\OculusWorldDemo.vcxproj", "{456DA1F5-7D65-4B77-8336-277F3921639B}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
+ Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {6C6ECAC4-DB5C-4301-8371-9C7CC8C623C2}.Debug|Win32.ActiveCfg = Debug|Win32
+ {6C6ECAC4-DB5C-4301-8371-9C7CC8C623C2}.Debug|Win32.Build.0 = Debug|Win32
+ {6C6ECAC4-DB5C-4301-8371-9C7CC8C623C2}.Debug|x64.ActiveCfg = Debug|x64
+ {6C6ECAC4-DB5C-4301-8371-9C7CC8C623C2}.Debug|x64.Build.0 = Debug|x64
+ {6C6ECAC4-DB5C-4301-8371-9C7CC8C623C2}.Release|Win32.ActiveCfg = Release|Win32
+ {6C6ECAC4-DB5C-4301-8371-9C7CC8C623C2}.Release|Win32.Build.0 = Release|Win32
+ {6C6ECAC4-DB5C-4301-8371-9C7CC8C623C2}.Release|x64.ActiveCfg = Release|x64
+ {6C6ECAC4-DB5C-4301-8371-9C7CC8C623C2}.Release|x64.Build.0 = Release|x64
+ {456DA1F5-7D65-4B77-8336-277F3921639B}.Debug|Win32.ActiveCfg = Debug|Win32
+ {456DA1F5-7D65-4B77-8336-277F3921639B}.Debug|Win32.Build.0 = Debug|Win32
+ {456DA1F5-7D65-4B77-8336-277F3921639B}.Debug|x64.ActiveCfg = Debug|x64
+ {456DA1F5-7D65-4B77-8336-277F3921639B}.Debug|x64.Build.0 = Debug|x64
+ {456DA1F5-7D65-4B77-8336-277F3921639B}.Release|Win32.ActiveCfg = Release|Win32
+ {456DA1F5-7D65-4B77-8336-277F3921639B}.Release|Win32.Build.0 = Release|Win32
+ {456DA1F5-7D65-4B77-8336-277F3921639B}.Release|x64.ActiveCfg = Release|x64
+ {456DA1F5-7D65-4B77-8336-277F3921639B}.Release|x64.Build.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Samples/LibOVR_Samples_VS2012.sln b/Samples/LibOVR_Samples_VS2012.sln
new file mode 100644
index 0000000..5e2247c
--- /dev/null
+++ b/Samples/LibOVR_Samples_VS2012.sln
@@ -0,0 +1,43 @@
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OculusWorldDemo", "OculusWorldDemo\Projects\Win\VS2012\OculusWorldDemo.vcxproj", "{4F8C2B89-7CF1-4763-8EEF-E969FB760E32}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OculusRoomTiny", "OculusRoomTiny\Projects\Win\VS2012\OculusRoomTiny.vcxproj", "{5736727A-FEB0-49C0-B63A-36BF0FEB4FF3}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
+ Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {4F8C2B89-7CF1-4763-8EEF-E969FB760E32}.Debug|Win32.ActiveCfg = Debug|Win32
+ {4F8C2B89-7CF1-4763-8EEF-E969FB760E32}.Debug|Win32.Build.0 = Debug|Win32
+ {4F8C2B89-7CF1-4763-8EEF-E969FB760E32}.Debug|Win32.Deploy.0 = Debug|Win32
+ {4F8C2B89-7CF1-4763-8EEF-E969FB760E32}.Debug|x64.ActiveCfg = Debug|x64
+ {4F8C2B89-7CF1-4763-8EEF-E969FB760E32}.Debug|x64.Build.0 = Debug|x64
+ {4F8C2B89-7CF1-4763-8EEF-E969FB760E32}.Debug|x64.Deploy.0 = Debug|x64
+ {4F8C2B89-7CF1-4763-8EEF-E969FB760E32}.Release|Win32.ActiveCfg = Release|Win32
+ {4F8C2B89-7CF1-4763-8EEF-E969FB760E32}.Release|Win32.Build.0 = Release|Win32
+ {4F8C2B89-7CF1-4763-8EEF-E969FB760E32}.Release|Win32.Deploy.0 = Release|Win32
+ {4F8C2B89-7CF1-4763-8EEF-E969FB760E32}.Release|x64.ActiveCfg = Release|x64
+ {4F8C2B89-7CF1-4763-8EEF-E969FB760E32}.Release|x64.Build.0 = Release|x64
+ {4F8C2B89-7CF1-4763-8EEF-E969FB760E32}.Release|x64.Deploy.0 = Release|x64
+ {5736727A-FEB0-49C0-B63A-36BF0FEB4FF3}.Debug|Win32.ActiveCfg = Debug|Win32
+ {5736727A-FEB0-49C0-B63A-36BF0FEB4FF3}.Debug|Win32.Build.0 = Debug|Win32
+ {5736727A-FEB0-49C0-B63A-36BF0FEB4FF3}.Debug|Win32.Deploy.0 = Debug|Win32
+ {5736727A-FEB0-49C0-B63A-36BF0FEB4FF3}.Debug|x64.ActiveCfg = Debug|x64
+ {5736727A-FEB0-49C0-B63A-36BF0FEB4FF3}.Debug|x64.Build.0 = Debug|x64
+ {5736727A-FEB0-49C0-B63A-36BF0FEB4FF3}.Debug|x64.Deploy.0 = Debug|x64
+ {5736727A-FEB0-49C0-B63A-36BF0FEB4FF3}.Release|Win32.ActiveCfg = Release|Win32
+ {5736727A-FEB0-49C0-B63A-36BF0FEB4FF3}.Release|Win32.Build.0 = Release|Win32
+ {5736727A-FEB0-49C0-B63A-36BF0FEB4FF3}.Release|Win32.Deploy.0 = Release|Win32
+ {5736727A-FEB0-49C0-B63A-36BF0FEB4FF3}.Release|x64.ActiveCfg = Release|x64
+ {5736727A-FEB0-49C0-B63A-36BF0FEB4FF3}.Release|x64.Build.0 = Release|x64
+ {5736727A-FEB0-49C0-B63A-36BF0FEB4FF3}.Release|x64.Deploy.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Samples/LibOVR_Samples_VS2013.sln b/Samples/LibOVR_Samples_VS2013.sln
new file mode 100644
index 0000000..42b9e07
--- /dev/null
+++ b/Samples/LibOVR_Samples_VS2013.sln
@@ -0,0 +1,38 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.30110.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OculusRoomTiny", "OculusRoomTiny\Projects\Win\VS2013\OculusRoomTiny.vcxproj", "{394FF596-A90B-4C95-888B-B743834ED15B}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OculusWorldDemo", "OculusWorldDemo\Projects\Win\VS2013\OculusWorldDemo.vcxproj", "{CA4E4127-1BAD-447C-BFF9-5AF940EEC376}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
+ Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {394FF596-A90B-4C95-888B-B743834ED15B}.Debug|Win32.ActiveCfg = Debug|Win32
+ {394FF596-A90B-4C95-888B-B743834ED15B}.Debug|Win32.Build.0 = Debug|Win32
+ {394FF596-A90B-4C95-888B-B743834ED15B}.Debug|x64.ActiveCfg = Debug|x64
+ {394FF596-A90B-4C95-888B-B743834ED15B}.Debug|x64.Build.0 = Debug|x64
+ {394FF596-A90B-4C95-888B-B743834ED15B}.Release|Win32.ActiveCfg = Release|Win32
+ {394FF596-A90B-4C95-888B-B743834ED15B}.Release|Win32.Build.0 = Release|Win32
+ {394FF596-A90B-4C95-888B-B743834ED15B}.Release|x64.ActiveCfg = Release|x64
+ {394FF596-A90B-4C95-888B-B743834ED15B}.Release|x64.Build.0 = Release|x64
+ {CA4E4127-1BAD-447C-BFF9-5AF940EEC376}.Debug|Win32.ActiveCfg = Debug|Win32
+ {CA4E4127-1BAD-447C-BFF9-5AF940EEC376}.Debug|Win32.Build.0 = Debug|Win32
+ {CA4E4127-1BAD-447C-BFF9-5AF940EEC376}.Debug|x64.ActiveCfg = Debug|x64
+ {CA4E4127-1BAD-447C-BFF9-5AF940EEC376}.Debug|x64.Build.0 = Debug|x64
+ {CA4E4127-1BAD-447C-BFF9-5AF940EEC376}.Release|Win32.ActiveCfg = Release|Win32
+ {CA4E4127-1BAD-447C-BFF9-5AF940EEC376}.Release|Win32.Build.0 = Release|Win32
+ {CA4E4127-1BAD-447C-BFF9-5AF940EEC376}.Release|x64.ActiveCfg = Release|x64
+ {CA4E4127-1BAD-447C-BFF9-5AF940EEC376}.Release|x64.Build.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Samples/LibOVR_With_Samples.xcodeproj/OculusRoomTiny-Info.plist b/Samples/LibOVR_With_Samples.xcodeproj/OculusRoomTiny-Info.plist
deleted file mode 100644
index 644e6d8..0000000
--- a/Samples/LibOVR_With_Samples.xcodeproj/OculusRoomTiny-Info.plist
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>CFBundleDevelopmentRegion</key>
- <string>en</string>
- <key>CFBundleExecutable</key>
- <string>${EXECUTABLE_NAME}</string>
- <key>CFBundleIconFile</key>
- <string></string>
- <key>CFBundleIdentifier</key>
- <string>com.oculusvr.${PRODUCT_NAME:rfc1034identifier}</string>
- <key>CFBundleInfoDictionaryVersion</key>
- <string>6.0</string>
- <key>CFBundleName</key>
- <string>${PRODUCT_NAME}</string>
- <key>CFBundlePackageType</key>
- <string>APPL</string>
- <key>CFBundleShortVersionString</key>
- <string>1.0</string>
- <key>CFBundleSignature</key>
- <string>????</string>
- <key>CFBundleVersion</key>
- <string>1</string>
- <key>LSMinimumSystemVersion</key>
- <string>${MACOSX_DEPLOYMENT_TARGET}</string>
- <key>NSHumanReadableCopyright</key>
- <string>Copyright © 2013 Oculus VR. All rights reserved.</string>
- <key>NSMainNibFile</key>
- <string>MainMenu</string>
- <key>NSPrincipalClass</key>
- <string>NSApplication</string>
-</dict>
-</plist>
diff --git a/Samples/LibOVR_With_Samples.xcodeproj/OculusWorldDemo-Info.plist b/Samples/LibOVR_With_Samples.xcodeproj/OculusWorldDemo-Info.plist
deleted file mode 100644
index 23028a1..0000000
--- a/Samples/LibOVR_With_Samples.xcodeproj/OculusWorldDemo-Info.plist
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>CFBundleDevelopmentRegion</key>
- <string>en</string>
- <key>CFBundleExecutable</key>
- <string>${EXECUTABLE_NAME}</string>
- <key>CFBundleIconFile</key>
- <string>Oculus</string>
- <key>CFBundleIdentifier</key>
- <string>com.oculusvr.${PRODUCT_NAME:rfc1034identifier}</string>
- <key>CFBundleInfoDictionaryVersion</key>
- <string>6.0</string>
- <key>CFBundleName</key>
- <string>${PRODUCT_NAME}</string>
- <key>CFBundlePackageType</key>
- <string>APPL</string>
- <key>CFBundleShortVersionString</key>
- <string>1.0</string>
- <key>CFBundleSignature</key>
- <string>????</string>
- <key>CFBundleVersion</key>
- <string>1</string>
- <key>LSMinimumSystemVersion</key>
- <string>${MACOSX_DEPLOYMENT_TARGET}</string>
- <key>NSHumanReadableCopyright</key>
- <string>Copyright © 2013 Oculus VR. All rights reserved.</string>
- <key>NSMainNibFile</key>
- <string>MainMenu</string>
- <key>NSPrincipalClass</key>
- <string>NSApplication</string>
-</dict>
-</plist>
diff --git a/Samples/LibOVR_With_Samples.xcodeproj/SensorBoxTest-Info.plist b/Samples/LibOVR_With_Samples.xcodeproj/SensorBoxTest-Info.plist
deleted file mode 100644
index 23028a1..0000000
--- a/Samples/LibOVR_With_Samples.xcodeproj/SensorBoxTest-Info.plist
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>CFBundleDevelopmentRegion</key>
- <string>en</string>
- <key>CFBundleExecutable</key>
- <string>${EXECUTABLE_NAME}</string>
- <key>CFBundleIconFile</key>
- <string>Oculus</string>
- <key>CFBundleIdentifier</key>
- <string>com.oculusvr.${PRODUCT_NAME:rfc1034identifier}</string>
- <key>CFBundleInfoDictionaryVersion</key>
- <string>6.0</string>
- <key>CFBundleName</key>
- <string>${PRODUCT_NAME}</string>
- <key>CFBundlePackageType</key>
- <string>APPL</string>
- <key>CFBundleShortVersionString</key>
- <string>1.0</string>
- <key>CFBundleSignature</key>
- <string>????</string>
- <key>CFBundleVersion</key>
- <string>1</string>
- <key>LSMinimumSystemVersion</key>
- <string>${MACOSX_DEPLOYMENT_TARGET}</string>
- <key>NSHumanReadableCopyright</key>
- <string>Copyright © 2013 Oculus VR. All rights reserved.</string>
- <key>NSMainNibFile</key>
- <string>MainMenu</string>
- <key>NSPrincipalClass</key>
- <string>NSApplication</string>
-</dict>
-</plist>
diff --git a/Samples/LibOVR_With_Samples.xcodeproj/project.pbxproj b/Samples/LibOVR_With_Samples.xcodeproj/project.pbxproj
deleted file mode 100644
index a2bc2f1..0000000
--- a/Samples/LibOVR_With_Samples.xcodeproj/project.pbxproj
+++ /dev/null
@@ -1,1131 +0,0 @@
-// !$*UTF8*$!
-{
- archiveVersion = 1;
- classes = {
- };
- objectVersion = 46;
- objects = {
-
-/* Begin PBXBuildFile section */
- 37973B391739D78B0093BBB8 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4945072216E55A0300B9FF78 /* Cocoa.framework */; };
- 37973B501739E1B60093BBB8 /* OculusRoomModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37973B4F1739E1B60093BBB8 /* OculusRoomModel.cpp */; };
- 37973B531739E1D20093BBB8 /* RenderTiny_Device.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37973B511739E1D20093BBB8 /* RenderTiny_Device.cpp */; };
- 37973B561739E9230093BBB8 /* RenderTiny_GL_Device.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37973B541739E9230093BBB8 /* RenderTiny_GL_Device.cpp */; };
- 37973B591739E9E80093BBB8 /* OSX_OculusRoomTiny.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37973B581739E9E80093BBB8 /* OSX_OculusRoomTiny.mm */; };
- 37973B5C1739FA620093BBB8 /* libovr.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 49A5336D16E544BE0039CB59 /* libovr.a */; };
- 37973B5D1739FA920093BBB8 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 499ED4C516E6A179008EA2ED /* IOKit.framework */; };
- 37973B5E1739FAB60093BBB8 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4945071616E546F700B9FF78 /* OpenGL.framework */; };
- 37973B5F1739FAC80093BBB8 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 49DB65F01718B1E10097A8DD /* ApplicationServices.framework */; };
- 37973B601739FAD50093BBB8 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 499ED4C716E6A187008EA2ED /* CoreFoundation.framework */; };
- 439FE6E217BE2E21007EFD34 /* OSX_Gamepad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BB10AEF173C4918009ED618 /* OSX_Gamepad.cpp */; };
- 494506DD16E5461F00B9FF78 /* OVR_Alg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A5337116E544E30039CB59 /* OVR_Alg.cpp */; };
- 494506DF16E5461F00B9FF78 /* OVR_Allocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A5337316E544E30039CB59 /* OVR_Allocator.cpp */; };
- 494506E216E5461F00B9FF78 /* OVR_Atomic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A5337616E544E30039CB59 /* OVR_Atomic.cpp */; };
- 494506E616E5461F00B9FF78 /* OVR_File.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A5337A16E544E30039CB59 /* OVR_File.cpp */; };
- 494506E816E5461F00B9FF78 /* OVR_FileFILE.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A5337C16E544E30039CB59 /* OVR_FileFILE.cpp */; };
- 494506EC16E5461F00B9FF78 /* OVR_Log.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A5338016E544E30039CB59 /* OVR_Log.cpp */; };
- 494506EE16E5461F00B9FF78 /* OVR_Math.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A5338216E544E30039CB59 /* OVR_Math.cpp */; };
- 494506F016E5461F00B9FF78 /* OVR_RefCount.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A5338416E544E30039CB59 /* OVR_RefCount.cpp */; };
- 494506F216E5461F00B9FF78 /* OVR_Std.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A5338616E544E30039CB59 /* OVR_Std.cpp */; };
- 494506F416E5461F00B9FF78 /* OVR_String.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A5338816E544E30039CB59 /* OVR_String.cpp */; };
- 494506F616E5461F00B9FF78 /* OVR_String_FormatUtil.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A5338A16E544E30039CB59 /* OVR_String_FormatUtil.cpp */; };
- 494506F716E5461F00B9FF78 /* OVR_String_PathUtil.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A5338B16E544E30039CB59 /* OVR_String_PathUtil.cpp */; };
- 494506F916E5461F00B9FF78 /* OVR_SysFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A5338D16E544E30039CB59 /* OVR_SysFile.cpp */; };
- 494506FB16E5461F00B9FF78 /* OVR_System.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A5338F16E544E30039CB59 /* OVR_System.cpp */; };
- 494506FE16E5461F00B9FF78 /* OVR_ThreadsPthread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A5339216E544E30039CB59 /* OVR_ThreadsPthread.cpp */; };
- 494506FF16E5461F00B9FF78 /* OVR_Timer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A5339316E544E30039CB59 /* OVR_Timer.cpp */; };
- 4945070216E5461F00B9FF78 /* OVR_UTF8Util.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A5339616E544E30039CB59 /* OVR_UTF8Util.cpp */; };
- 4945070616E5462A00B9FF78 /* OVR_DeviceHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A5339B16E544E30039CB59 /* OVR_DeviceHandle.cpp */; };
- 4945070816E5462A00B9FF78 /* OVR_DeviceImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A5339D16E544E30039CB59 /* OVR_DeviceImpl.cpp */; };
- 4945070F16E5462A00B9FF78 /* OVR_SensorFusion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A533A416E544E30039CB59 /* OVR_SensorFusion.cpp */; };
- 4945071116E5462A00B9FF78 /* OVR_ThreadCommandQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A533A616E544E30039CB59 /* OVR_ThreadCommandQueue.cpp */; };
- 4985385E16ECFE92008D0727 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4945072216E55A0300B9FF78 /* Cocoa.framework */; };
- 4985387416ECFED8008D0727 /* Render_Device.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A5335016E527820039CB59 /* Render_Device.cpp */; };
- 4985387816ECFED8008D0727 /* Render_GL_Device.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A5335416E527820039CB59 /* Render_GL_Device.cpp */; };
- 4985387A16ECFED8008D0727 /* Render_LoadTextureTGA.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A5335816E527820039CB59 /* Render_LoadTextureTGA.cpp */; };
- 4985388016ECFEE5008D0727 /* Platform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A5334216E527820039CB59 /* Platform.cpp */; };
- 4985388616ECFF2D008D0727 /* OculusWorldDemo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4985388116ECFF23008D0727 /* OculusWorldDemo.cpp */; };
- 4985388716ECFF2D008D0727 /* Player.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4985388216ECFF23008D0727 /* Player.cpp */; };
- 4985388A16ECFF53008D0727 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 499ED4C716E6A187008EA2ED /* CoreFoundation.framework */; };
- 4985388C16ECFF53008D0727 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 499ED4C516E6A179008EA2ED /* IOKit.framework */; };
- 4985388D16ECFF53008D0727 /* IOSurface.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 499ED4C916E9880D008EA2ED /* IOSurface.framework */; };
- 4985388E16ECFF53008D0727 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4945071616E546F700B9FF78 /* OpenGL.framework */; };
- 4985389216ED0204008D0727 /* tinyxml2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4985389116ED0204008D0727 /* tinyxml2.cpp */; };
- 4985389516ED0218008D0727 /* Render_LoadTextureDDS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4985389316ED0218008D0727 /* Render_LoadTextureDDS.cpp */; };
- 4985389716ED1AA7008D0727 /* Assets in Resources */ = {isa = PBXBuildFile; fileRef = 4985389616ED1AA7008D0727 /* Assets */; };
- 49ABA2E91718A38100E288A7 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 49ABA2E81718A38100E288A7 /* AudioToolbox.framework */; };
- 49DB65F11718B1E10097A8DD /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 49DB65F01718B1E10097A8DD /* ApplicationServices.framework */; };
- 49DB65F71726F0C30097A8DD /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4945072216E55A0300B9FF78 /* Cocoa.framework */; };
- 49DB660F1726F0EA0097A8DD /* OSX_Platform.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9BBB8902171E2BE200563901 /* OSX_Platform.mm */; };
- 49DB66101726F0EA0097A8DD /* Platform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A5334216E527820039CB59 /* Platform.cpp */; };
- 49DB66111726F0F80097A8DD /* Render_LoadTextureDDS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4985389316ED0218008D0727 /* Render_LoadTextureDDS.cpp */; };
- 49DB66121726F0F80097A8DD /* Render_Device.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A5335016E527820039CB59 /* Render_Device.cpp */; };
- 49DB66131726F0F80097A8DD /* Render_GL_Device.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A5335416E527820039CB59 /* Render_GL_Device.cpp */; };
- 49DB66141726F0F80097A8DD /* Render_LoadTextureTGA.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A5335816E527820039CB59 /* Render_LoadTextureTGA.cpp */; };
- 49DB66171726F1350097A8DD /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 49DB65F01718B1E10097A8DD /* ApplicationServices.framework */; };
- 49DB66181726F13B0097A8DD /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 499ED4C516E6A179008EA2ED /* IOKit.framework */; };
- 49DB66191726F1530097A8DD /* libovr.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 49A5336D16E544BE0039CB59 /* libovr.a */; };
- 49DB661A1726F1650097A8DD /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4945071616E546F700B9FF78 /* OpenGL.framework */; };
- 9B6DEF851728A6560071E76B /* SensorBoxTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B6DEF841728A6560071E76B /* SensorBoxTest.cpp */; };
- 9BA4DDB61721E12400CF7715 /* OSX_Platform.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9BBB8902171E2BE200563901 /* OSX_Platform.mm */; };
- 9BA4DDB81727061100CF7715 /* Oculus.icns in Resources */ = {isa = PBXBuildFile; fileRef = 9BA4DDB71727061100CF7715 /* Oculus.icns */; };
- 9BA4DDB91727083500CF7715 /* Oculus.icns in Resources */ = {isa = PBXBuildFile; fileRef = 9BA4DDB71727061100CF7715 /* Oculus.icns */; };
- 9BAB70F6170E69530006FE98 /* libovr.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 49A5336D16E544BE0039CB59 /* libovr.a */; };
- 9BB10AF1173C4918009ED618 /* OSX_Gamepad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BB10AEF173C4918009ED618 /* OSX_Gamepad.cpp */; };
- 9BCE53F916F0293A007A23FF /* OVR_HIDDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BCE53F416F0293A007A23FF /* OVR_HIDDevice.h */; };
- 9BCE53FA16F0293A007A23FF /* OVR_HIDDeviceBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BCE53F516F0293A007A23FF /* OVR_HIDDeviceBase.h */; };
- 9BCE53FB16F0293A007A23FF /* OVR_HIDDeviceImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BCE53F616F0293A007A23FF /* OVR_HIDDeviceImpl.h */; };
- 9BCE53FC16F0293A007A23FF /* OVR_LatencyTestImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BCE53F716F0293A007A23FF /* OVR_LatencyTestImpl.cpp */; };
- 9BCE53FD16F0293A007A23FF /* OVR_LatencyTestImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BCE53F816F0293A007A23FF /* OVR_LatencyTestImpl.h */; };
- 9BCE540016F02A56007A23FF /* OVR_SensorImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BCE53FE16F02A56007A23FF /* OVR_SensorImpl.cpp */; };
- 9BCE540116F02A56007A23FF /* OVR_SensorImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BCE53FF16F02A56007A23FF /* OVR_SensorImpl.h */; };
- 9BCE541616F02ABC007A23FF /* OVR_OSX_DeviceManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BCE53EB16F028A9007A23FF /* OVR_OSX_DeviceManager.cpp */; };
- 9BCE541716F02AD5007A23FF /* OVR_OSX_HIDDevice.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BCE53ED16F028AA007A23FF /* OVR_OSX_HIDDevice.cpp */; };
- 9BCE541816F02ADB007A23FF /* OVR_OSX_DeviceManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BCE53EC16F028AA007A23FF /* OVR_OSX_DeviceManager.h */; };
- 9BCE541916F02AE6007A23FF /* OVR_OSX_HIDDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BCE53EE16F028AA007A23FF /* OVR_OSX_HIDDevice.h */; };
- 9BCE541A16F02AEB007A23FF /* OVR_OSX_HMDDevice.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BCE53EF16F028AA007A23FF /* OVR_OSX_HMDDevice.cpp */; };
- 9BCE541B16F02AF1007A23FF /* OVR_OSX_HMDDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BCE53F016F028AA007A23FF /* OVR_OSX_HMDDevice.h */; };
- 9BCE541C16F02B04007A23FF /* OVR_Device.h in Headers */ = {isa = PBXBuildFile; fileRef = 499ED4B216E5703B008EA2ED /* OVR_Device.h */; };
- 9BCE541D16F02B13007A23FF /* OVR_DeviceConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = 49A5339A16E544E30039CB59 /* OVR_DeviceConstants.h */; };
- 9BCE541E16F02B1D007A23FF /* OVR_DeviceHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 49A5339C16E544E30039CB59 /* OVR_DeviceHandle.h */; };
- 9BCE541F16F02B26007A23FF /* OVR_DeviceImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 49A5339E16E544E30039CB59 /* OVR_DeviceImpl.h */; };
- 9BCE542016F02B2A007A23FF /* OVR_DeviceMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 49A5339F16E544E30039CB59 /* OVR_DeviceMessages.h */; };
- 9BCE542216F02B88007A23FF /* OVR_SensorFusion.h in Headers */ = {isa = PBXBuildFile; fileRef = 49A533A516E544E30039CB59 /* OVR_SensorFusion.h */; };
- 9BCE542316F02B91007A23FF /* OVR_ThreadCommandQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 49A533A716E544E30039CB59 /* OVR_ThreadCommandQueue.h */; };
- 9BCE542516F2694F007A23FF /* OVR_OSX_SensorDevice.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BCE542416F2694E007A23FF /* OVR_OSX_SensorDevice.cpp */; };
- 9BD2A642172069B300C3C389 /* Util_MagCalibration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BD2A640172069B300C3C389 /* Util_MagCalibration.cpp */; };
- 9BD2A643172069B300C3C389 /* Util_MagCalibration.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BD2A641172069B300C3C389 /* Util_MagCalibration.h */; };
- 9BD2A646172069BF00C3C389 /* OVR_SensorFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BD2A644172069BF00C3C389 /* OVR_SensorFilter.cpp */; };
- 9BD2A647172069BF00C3C389 /* OVR_SensorFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BD2A645172069BF00C3C389 /* OVR_SensorFilter.h */; };
- 9BEAD55F17187B8A00A8AA1D /* Util_LatencyTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BEAD55B17187B8A00A8AA1D /* Util_LatencyTest.cpp */; };
- 9BEAD56017187B8A00A8AA1D /* Util_LatencyTest.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BEAD55C17187B8A00A8AA1D /* Util_LatencyTest.h */; };
- 9BEAD56117187B8A00A8AA1D /* Util_Render_Stereo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BEAD55D17187B8A00A8AA1D /* Util_Render_Stereo.cpp */; };
- 9BEAD56217187B8A00A8AA1D /* Util_Render_Stereo.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BEAD55E17187B8A00A8AA1D /* Util_Render_Stereo.h */; };
- 9BEAD56517187CFF00A8AA1D /* OSX_WavPlayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BEAD56317187CFF00A8AA1D /* OSX_WavPlayer.cpp */; };
- 9BEAD56717187E7500A8AA1D /* Render_XmlSceneLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9BEAD56617187E7500A8AA1D /* Render_XmlSceneLoader.cpp */; };
- C50FA3D0177BB88E00730BB7 /* OVR_JSON.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C50FA3CC177BB88E00730BB7 /* OVR_JSON.cpp */; };
- C50FA3D1177BB88E00730BB7 /* OVR_JSON.h in Headers */ = {isa = PBXBuildFile; fileRef = C50FA3CD177BB88E00730BB7 /* OVR_JSON.h */; };
- C50FA3D2177BB88E00730BB7 /* OVR_Profile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C50FA3CE177BB88E00730BB7 /* OVR_Profile.cpp */; };
- C50FA3D3177BB88E00730BB7 /* OVR_Profile.h in Headers */ = {isa = PBXBuildFile; fileRef = C50FA3CF177BB88E00730BB7 /* OVR_Profile.h */; };
-/* End PBXBuildFile section */
-
-/* Begin PBXContainerItemProxy section */
- 37973B5A1739FA100093BBB8 /* PBXContainerItemProxy */ = {
- isa = PBXContainerItemProxy;
- containerPortal = 49A5332B16E527490039CB59 /* Project object */;
- proxyType = 1;
- remoteGlobalIDString = 49A5336C16E544BE0039CB59;
- remoteInfo = ovr;
- };
- 4985388F16ECFF5C008D0727 /* PBXContainerItemProxy */ = {
- isa = PBXContainerItemProxy;
- containerPortal = 49A5332B16E527490039CB59 /* Project object */;
- proxyType = 1;
- remoteGlobalIDString = 49A5336C16E544BE0039CB59;
- remoteInfo = ovr;
- };
- 49DB660D1726F0CD0097A8DD /* PBXContainerItemProxy */ = {
- isa = PBXContainerItemProxy;
- containerPortal = 49A5332B16E527490039CB59 /* Project object */;
- proxyType = 1;
- remoteGlobalIDString = 49A5336C16E544BE0039CB59;
- remoteInfo = ovr;
- };
-/* End PBXContainerItemProxy section */
-
-/* Begin PBXFileReference section */
- 37973B381739D78B0093BBB8 /* OculusRoomTiny.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OculusRoomTiny.app; sourceTree = BUILT_PRODUCTS_DIR; };
- 37973B4F1739E1B60093BBB8 /* OculusRoomModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OculusRoomModel.cpp; sourceTree = "<group>"; };
- 37973B511739E1D20093BBB8 /* RenderTiny_Device.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTiny_Device.cpp; sourceTree = "<group>"; };
- 37973B521739E1D20093BBB8 /* RenderTiny_Device.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderTiny_Device.h; sourceTree = "<group>"; };
- 37973B541739E9230093BBB8 /* RenderTiny_GL_Device.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTiny_GL_Device.cpp; sourceTree = "<group>"; };
- 37973B551739E9230093BBB8 /* RenderTiny_GL_Device.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderTiny_GL_Device.h; sourceTree = "<group>"; };
- 37973B571739E9E80093BBB8 /* OSX_OculusRoomTiny.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSX_OculusRoomTiny.h; sourceTree = "<group>"; };
- 37973B581739E9E80093BBB8 /* OSX_OculusRoomTiny.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OSX_OculusRoomTiny.mm; sourceTree = "<group>"; };
- 4945071616E546F700B9FF78 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; };
- 4945071816E5474000B9FF78 /* libGL.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libGL.dylib; path = ../../../../../../../opt/X11/lib/libGL.dylib; sourceTree = "<group>"; };
- 4945071A16E5474A00B9FF78 /* libX11.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libX11.dylib; path = ../../../../../../../opt/X11/lib/libX11.dylib; sourceTree = "<group>"; };
- 4945072216E55A0300B9FF78 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
- 4945072516E55A0300B9FF78 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
- 4945072616E55A0300B9FF78 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
- 4945072716E55A0300B9FF78 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
- 4985385D16ECFE92008D0727 /* OculusWorldDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OculusWorldDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
- 4985388116ECFF23008D0727 /* OculusWorldDemo.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = OculusWorldDemo.cpp; path = OculusWorldDemo/OculusWorldDemo.cpp; sourceTree = "<group>"; };
- 4985388216ECFF23008D0727 /* Player.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = Player.cpp; path = OculusWorldDemo/Player.cpp; sourceTree = "<group>"; };
- 4985388316ECFF23008D0727 /* Player.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Player.h; path = OculusWorldDemo/Player.h; sourceTree = "<group>"; };
- 4985389116ED0204008D0727 /* tinyxml2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = tinyxml2.cpp; path = ../3rdParty/TinyXml/tinyxml2.cpp; sourceTree = "<group>"; };
- 4985389316ED0218008D0727 /* Render_LoadTextureDDS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Render_LoadTextureDDS.cpp; sourceTree = "<group>"; };
- 4985389616ED1AA7008D0727 /* Assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Assets; path = OculusWorldDemo/Assets; sourceTree = "<group>"; };
- 499ED49B16E57027008EA2ED /* OVR_Alg.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OVR_Alg.h; sourceTree = "<group>"; };
- 499ED49C16E57027008EA2ED /* OVR_Allocator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OVR_Allocator.h; sourceTree = "<group>"; };
- 499ED49D16E57027008EA2ED /* OVR_Array.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OVR_Array.h; sourceTree = "<group>"; };
- 499ED49E16E57027008EA2ED /* OVR_Atomic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OVR_Atomic.h; sourceTree = "<group>"; };
- 499ED49F16E57027008EA2ED /* OVR_Color.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OVR_Color.h; sourceTree = "<group>"; };
- 499ED4A016E57027008EA2ED /* OVR_ContainerAllocator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OVR_ContainerAllocator.h; sourceTree = "<group>"; };
- 499ED4A116E57027008EA2ED /* OVR_File.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OVR_File.h; sourceTree = "<group>"; };
- 499ED4A216E57027008EA2ED /* OVR_Hash.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OVR_Hash.h; sourceTree = "<group>"; };
- 499ED4A316E57027008EA2ED /* OVR_KeyCodes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OVR_KeyCodes.h; sourceTree = "<group>"; };
- 499ED4A416E57027008EA2ED /* OVR_List.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OVR_List.h; sourceTree = "<group>"; };
- 499ED4A516E57027008EA2ED /* OVR_Log.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OVR_Log.h; sourceTree = "<group>"; };
- 499ED4A616E57027008EA2ED /* OVR_Math.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OVR_Math.h; sourceTree = "<group>"; };
- 499ED4A716E57027008EA2ED /* OVR_RefCount.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OVR_RefCount.h; sourceTree = "<group>"; };
- 499ED4A816E57027008EA2ED /* OVR_Std.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OVR_Std.h; sourceTree = "<group>"; };
- 499ED4A916E57027008EA2ED /* OVR_String.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OVR_String.h; sourceTree = "<group>"; };
- 499ED4AA16E57027008EA2ED /* OVR_StringHash.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OVR_StringHash.h; sourceTree = "<group>"; };
- 499ED4AB16E57027008EA2ED /* OVR_SysFile.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OVR_SysFile.h; sourceTree = "<group>"; };
- 499ED4AC16E57027008EA2ED /* OVR_System.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OVR_System.h; sourceTree = "<group>"; };
- 499ED4AD16E57027008EA2ED /* OVR_Threads.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OVR_Threads.h; sourceTree = "<group>"; };
- 499ED4AE16E57027008EA2ED /* OVR_ThreadsWinAPI.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_ThreadsWinAPI.cpp; sourceTree = "<group>"; };
- 499ED4AF16E57027008EA2ED /* OVR_Timer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OVR_Timer.h; sourceTree = "<group>"; };
- 499ED4B016E57027008EA2ED /* OVR_Types.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OVR_Types.h; sourceTree = "<group>"; };
- 499ED4B116E57027008EA2ED /* OVR_UTF8Util.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OVR_UTF8Util.h; sourceTree = "<group>"; };
- 499ED4B216E5703B008EA2ED /* OVR_Device.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OVR_Device.h; sourceTree = "<group>"; };
- 499ED4C516E6A179008EA2ED /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; };
- 499ED4C716E6A187008EA2ED /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };
- 499ED4C916E9880D008EA2ED /* IOSurface.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOSurface.framework; path = System/Library/Frameworks/IOSurface.framework; sourceTree = SDKROOT; };
- 49A5334216E527820039CB59 /* Platform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Platform.cpp; sourceTree = "<group>"; };
- 49A5334316E527820039CB59 /* Platform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Platform.h; sourceTree = "<group>"; };
- 49A5334416E527820039CB59 /* Platform_Default.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Platform_Default.h; sourceTree = "<group>"; };
- 49A5335016E527820039CB59 /* Render_Device.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Render_Device.cpp; sourceTree = "<group>"; };
- 49A5335116E527820039CB59 /* Render_Device.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Render_Device.h; sourceTree = "<group>"; };
- 49A5335216E527820039CB59 /* Render_Font.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Render_Font.h; sourceTree = "<group>"; };
- 49A5335316E527820039CB59 /* Render_FontEmbed_DejaVu48.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Render_FontEmbed_DejaVu48.h; sourceTree = "<group>"; };
- 49A5335416E527820039CB59 /* Render_GL_Device.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Render_GL_Device.cpp; sourceTree = "<group>"; };
- 49A5335516E527820039CB59 /* Render_GL_Device.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Render_GL_Device.h; sourceTree = "<group>"; };
- 49A5335816E527820039CB59 /* Render_LoadTextureTGA.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Render_LoadTextureTGA.cpp; sourceTree = "<group>"; };
- 49A5336D16E544BE0039CB59 /* libovr.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libovr.a; sourceTree = BUILT_PRODUCTS_DIR; };
- 49A5337116E544E30039CB59 /* OVR_Alg.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_Alg.cpp; sourceTree = "<group>"; };
- 49A5337316E544E30039CB59 /* OVR_Allocator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_Allocator.cpp; sourceTree = "<group>"; };
- 49A5337616E544E30039CB59 /* OVR_Atomic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_Atomic.cpp; sourceTree = "<group>"; };
- 49A5337A16E544E30039CB59 /* OVR_File.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_File.cpp; sourceTree = "<group>"; };
- 49A5337C16E544E30039CB59 /* OVR_FileFILE.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_FileFILE.cpp; sourceTree = "<group>"; };
- 49A5338016E544E30039CB59 /* OVR_Log.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_Log.cpp; sourceTree = "<group>"; };
- 49A5338216E544E30039CB59 /* OVR_Math.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_Math.cpp; sourceTree = "<group>"; };
- 49A5338416E544E30039CB59 /* OVR_RefCount.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_RefCount.cpp; sourceTree = "<group>"; };
- 49A5338616E544E30039CB59 /* OVR_Std.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_Std.cpp; sourceTree = "<group>"; };
- 49A5338816E544E30039CB59 /* OVR_String.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_String.cpp; sourceTree = "<group>"; };
- 49A5338A16E544E30039CB59 /* OVR_String_FormatUtil.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_String_FormatUtil.cpp; sourceTree = "<group>"; };
- 49A5338B16E544E30039CB59 /* OVR_String_PathUtil.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_String_PathUtil.cpp; sourceTree = "<group>"; };
- 49A5338D16E544E30039CB59 /* OVR_SysFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_SysFile.cpp; sourceTree = "<group>"; };
- 49A5338F16E544E30039CB59 /* OVR_System.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_System.cpp; sourceTree = "<group>"; };
- 49A5339216E544E30039CB59 /* OVR_ThreadsPthread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_ThreadsPthread.cpp; sourceTree = "<group>"; };
- 49A5339316E544E30039CB59 /* OVR_Timer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_Timer.cpp; sourceTree = "<group>"; };
- 49A5339616E544E30039CB59 /* OVR_UTF8Util.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_UTF8Util.cpp; sourceTree = "<group>"; };
- 49A5339A16E544E30039CB59 /* OVR_DeviceConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OVR_DeviceConstants.h; sourceTree = "<group>"; };
- 49A5339B16E544E30039CB59 /* OVR_DeviceHandle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_DeviceHandle.cpp; sourceTree = "<group>"; };
- 49A5339C16E544E30039CB59 /* OVR_DeviceHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OVR_DeviceHandle.h; sourceTree = "<group>"; };
- 49A5339D16E544E30039CB59 /* OVR_DeviceImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_DeviceImpl.cpp; sourceTree = "<group>"; };
- 49A5339E16E544E30039CB59 /* OVR_DeviceImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OVR_DeviceImpl.h; sourceTree = "<group>"; };
- 49A5339F16E544E30039CB59 /* OVR_DeviceMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OVR_DeviceMessages.h; sourceTree = "<group>"; };
- 49A533A416E544E30039CB59 /* OVR_SensorFusion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_SensorFusion.cpp; sourceTree = "<group>"; };
- 49A533A516E544E30039CB59 /* OVR_SensorFusion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OVR_SensorFusion.h; sourceTree = "<group>"; };
- 49A533A616E544E30039CB59 /* OVR_ThreadCommandQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_ThreadCommandQueue.cpp; sourceTree = "<group>"; };
- 49A533A716E544E30039CB59 /* OVR_ThreadCommandQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OVR_ThreadCommandQueue.h; sourceTree = "<group>"; };
- 49ABA2E81718A38100E288A7 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = ../../../../../../../System/Library/Frameworks/AudioToolbox.framework; sourceTree = "<group>"; };
- 49DB65F01718B1E10097A8DD /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = System/Library/Frameworks/ApplicationServices.framework; sourceTree = SDKROOT; };
- 49DB65F61726F0C30097A8DD /* SensorBoxTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SensorBoxTest.app; sourceTree = BUILT_PRODUCTS_DIR; };
- 9B22CBB517187F5C0046D43D /* tinyxml2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = tinyxml2.h; path = ../3rdParty/TinyXml/tinyxml2.h; sourceTree = "<group>"; };
- 9B6DEF841728A6560071E76B /* SensorBoxTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SensorBoxTest.cpp; path = SensorBox/SensorBoxTest.cpp; sourceTree = "<group>"; };
- 9BA4DDB71727061100CF7715 /* Oculus.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Oculus.icns; sourceTree = "<group>"; };
- 9BB10AEF173C4918009ED618 /* OSX_Gamepad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OSX_Gamepad.cpp; sourceTree = "<group>"; };
- 9BB10AF0173C4918009ED618 /* OSX_Gamepad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSX_Gamepad.h; sourceTree = "<group>"; };
- 9BB10AF2173C49AC009ED618 /* Gamepad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Gamepad.h; sourceTree = "<group>"; };
- 9BBB8901171E2BE200563901 /* OSX_Platform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSX_Platform.h; sourceTree = "<group>"; };
- 9BBB8902171E2BE200563901 /* OSX_Platform.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OSX_Platform.mm; sourceTree = "<group>"; };
- 9BBB8903171E2BE200563901 /* OSX_PlatformObjc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSX_PlatformObjc.h; sourceTree = "<group>"; };
- 9BCE53EB16F028A9007A23FF /* OVR_OSX_DeviceManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_OSX_DeviceManager.cpp; sourceTree = "<group>"; };
- 9BCE53EC16F028AA007A23FF /* OVR_OSX_DeviceManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OVR_OSX_DeviceManager.h; sourceTree = "<group>"; };
- 9BCE53ED16F028AA007A23FF /* OVR_OSX_HIDDevice.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_OSX_HIDDevice.cpp; sourceTree = "<group>"; };
- 9BCE53EE16F028AA007A23FF /* OVR_OSX_HIDDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OVR_OSX_HIDDevice.h; sourceTree = "<group>"; };
- 9BCE53EF16F028AA007A23FF /* OVR_OSX_HMDDevice.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_OSX_HMDDevice.cpp; sourceTree = "<group>"; };
- 9BCE53F016F028AA007A23FF /* OVR_OSX_HMDDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OVR_OSX_HMDDevice.h; sourceTree = "<group>"; };
- 9BCE53F416F0293A007A23FF /* OVR_HIDDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OVR_HIDDevice.h; sourceTree = "<group>"; };
- 9BCE53F516F0293A007A23FF /* OVR_HIDDeviceBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OVR_HIDDeviceBase.h; sourceTree = "<group>"; };
- 9BCE53F616F0293A007A23FF /* OVR_HIDDeviceImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OVR_HIDDeviceImpl.h; sourceTree = "<group>"; };
- 9BCE53F716F0293A007A23FF /* OVR_LatencyTestImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_LatencyTestImpl.cpp; sourceTree = "<group>"; };
- 9BCE53F816F0293A007A23FF /* OVR_LatencyTestImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OVR_LatencyTestImpl.h; sourceTree = "<group>"; };
- 9BCE53FE16F02A56007A23FF /* OVR_SensorImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_SensorImpl.cpp; sourceTree = "<group>"; };
- 9BCE53FF16F02A56007A23FF /* OVR_SensorImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OVR_SensorImpl.h; sourceTree = "<group>"; };
- 9BCE542416F2694E007A23FF /* OVR_OSX_SensorDevice.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_OSX_SensorDevice.cpp; sourceTree = "<group>"; };
- 9BD2A640172069B300C3C389 /* Util_MagCalibration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Util_MagCalibration.cpp; path = Util/Util_MagCalibration.cpp; sourceTree = "<group>"; };
- 9BD2A641172069B300C3C389 /* Util_MagCalibration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Util_MagCalibration.h; path = Util/Util_MagCalibration.h; sourceTree = "<group>"; };
- 9BD2A644172069BF00C3C389 /* OVR_SensorFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_SensorFilter.cpp; sourceTree = "<group>"; };
- 9BD2A645172069BF00C3C389 /* OVR_SensorFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OVR_SensorFilter.h; sourceTree = "<group>"; };
- 9BEAD55B17187B8A00A8AA1D /* Util_LatencyTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Util_LatencyTest.cpp; path = Util/Util_LatencyTest.cpp; sourceTree = "<group>"; };
- 9BEAD55C17187B8A00A8AA1D /* Util_LatencyTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Util_LatencyTest.h; path = Util/Util_LatencyTest.h; sourceTree = "<group>"; };
- 9BEAD55D17187B8A00A8AA1D /* Util_Render_Stereo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Util_Render_Stereo.cpp; path = Util/Util_Render_Stereo.cpp; sourceTree = "<group>"; };
- 9BEAD55E17187B8A00A8AA1D /* Util_Render_Stereo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Util_Render_Stereo.h; path = Util/Util_Render_Stereo.h; sourceTree = "<group>"; };
- 9BEAD56317187CFF00A8AA1D /* OSX_WavPlayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OSX_WavPlayer.cpp; sourceTree = "<group>"; };
- 9BEAD56417187CFF00A8AA1D /* OSX_WavPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSX_WavPlayer.h; sourceTree = "<group>"; };
- 9BEAD56617187E7500A8AA1D /* Render_XmlSceneLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Render_XmlSceneLoader.cpp; sourceTree = "<group>"; };
- 9BEAD56817187E8300A8AA1D /* Render_XmlSceneLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Render_XmlSceneLoader.h; sourceTree = "<group>"; };
- C50FA3CC177BB88E00730BB7 /* OVR_JSON.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_JSON.cpp; sourceTree = "<group>"; };
- C50FA3CD177BB88E00730BB7 /* OVR_JSON.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OVR_JSON.h; sourceTree = "<group>"; };
- C50FA3CE177BB88E00730BB7 /* OVR_Profile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OVR_Profile.cpp; sourceTree = "<group>"; };
- C50FA3CF177BB88E00730BB7 /* OVR_Profile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OVR_Profile.h; sourceTree = "<group>"; };
-/* End PBXFileReference section */
-
-/* Begin PBXFrameworksBuildPhase section */
- 37973B351739D78B0093BBB8 /* Frameworks */ = {
- isa = PBXFrameworksBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 37973B601739FAD50093BBB8 /* CoreFoundation.framework in Frameworks */,
- 37973B5F1739FAC80093BBB8 /* ApplicationServices.framework in Frameworks */,
- 37973B5E1739FAB60093BBB8 /* OpenGL.framework in Frameworks */,
- 37973B5D1739FA920093BBB8 /* IOKit.framework in Frameworks */,
- 37973B391739D78B0093BBB8 /* Cocoa.framework in Frameworks */,
- 37973B5C1739FA620093BBB8 /* libovr.a in Frameworks */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
- 4985385A16ECFE92008D0727 /* Frameworks */ = {
- isa = PBXFrameworksBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 49DB65F11718B1E10097A8DD /* ApplicationServices.framework in Frameworks */,
- 49ABA2E91718A38100E288A7 /* AudioToolbox.framework in Frameworks */,
- 4985388A16ECFF53008D0727 /* CoreFoundation.framework in Frameworks */,
- 4985388C16ECFF53008D0727 /* IOKit.framework in Frameworks */,
- 4985388D16ECFF53008D0727 /* IOSurface.framework in Frameworks */,
- 4985388E16ECFF53008D0727 /* OpenGL.framework in Frameworks */,
- 4985385E16ECFE92008D0727 /* Cocoa.framework in Frameworks */,
- 9BAB70F6170E69530006FE98 /* libovr.a in Frameworks */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
- 49A5336A16E544BE0039CB59 /* Frameworks */ = {
- isa = PBXFrameworksBuildPhase;
- buildActionMask = 2147483647;
- files = (
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
- 49DB65F31726F0C30097A8DD /* Frameworks */ = {
- isa = PBXFrameworksBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 49DB661A1726F1650097A8DD /* OpenGL.framework in Frameworks */,
- 49DB66191726F1530097A8DD /* libovr.a in Frameworks */,
- 49DB66181726F13B0097A8DD /* IOKit.framework in Frameworks */,
- 49DB66171726F1350097A8DD /* ApplicationServices.framework in Frameworks */,
- 49DB65F71726F0C30097A8DD /* Cocoa.framework in Frameworks */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXFrameworksBuildPhase section */
-
-/* Begin PBXGroup section */
- 37973B3A1739D78B0093BBB8 /* OculusRoomTiny */ = {
- isa = PBXGroup;
- children = (
- 37973B571739E9E80093BBB8 /* OSX_OculusRoomTiny.h */,
- 37973B581739E9E80093BBB8 /* OSX_OculusRoomTiny.mm */,
- 37973B541739E9230093BBB8 /* RenderTiny_GL_Device.cpp */,
- 37973B551739E9230093BBB8 /* RenderTiny_GL_Device.h */,
- 37973B511739E1D20093BBB8 /* RenderTiny_Device.cpp */,
- 37973B521739E1D20093BBB8 /* RenderTiny_Device.h */,
- 37973B4F1739E1B60093BBB8 /* OculusRoomModel.cpp */,
- );
- path = OculusRoomTiny;
- sourceTree = "<group>";
- };
- 4945072116E55A0300B9FF78 /* Frameworks */ = {
- isa = PBXGroup;
- children = (
- 4945072216E55A0300B9FF78 /* Cocoa.framework */,
- 4945072416E55A0300B9FF78 /* Other Frameworks */,
- );
- name = Frameworks;
- sourceTree = "<group>";
- };
- 4945072416E55A0300B9FF78 /* Other Frameworks */ = {
- isa = PBXGroup;
- children = (
- 4945072516E55A0300B9FF78 /* AppKit.framework */,
- 4945072616E55A0300B9FF78 /* CoreData.framework */,
- 4945072716E55A0300B9FF78 /* Foundation.framework */,
- );
- name = "Other Frameworks";
- sourceTree = "<group>";
- };
- 49A5332A16E527490039CB59 = {
- isa = PBXGroup;
- children = (
- 9BA4DDB71727061100CF7715 /* Oculus.icns */,
- 49DB65F01718B1E10097A8DD /* ApplicationServices.framework */,
- 49ABA2E81718A38100E288A7 /* AudioToolbox.framework */,
- 9B22CBB417187F380046D43D /* 3rdParty */,
- 9B6DEF831728A60A0071E76B /* SensorBox */,
- 9B22CBB317187EC70046D43D /* OculusWorldDemo */,
- 4985389616ED1AA7008D0727 /* Assets */,
- 37973B3A1739D78B0093BBB8 /* OculusRoomTiny */,
- 49A5333416E527490039CB59 /* Products */,
- 49A533A816E544E30039CB59 /* Src */,
- 49A5334116E527820039CB59 /* Platform */,
- 49A5334916E527820039CB59 /* Render */,
- 4945071816E5474000B9FF78 /* libGL.dylib */,
- 4945071A16E5474A00B9FF78 /* libX11.dylib */,
- 4945072116E55A0300B9FF78 /* Frameworks */,
- 499ED4C716E6A187008EA2ED /* CoreFoundation.framework */,
- 4945071616E546F700B9FF78 /* OpenGL.framework */,
- 499ED4C516E6A179008EA2ED /* IOKit.framework */,
- 499ED4C916E9880D008EA2ED /* IOSurface.framework */,
- );
- sourceTree = "<group>";
- };
- 49A5333416E527490039CB59 /* Products */ = {
- isa = PBXGroup;
- children = (
- 49A5336D16E544BE0039CB59 /* libovr.a */,
- 4985385D16ECFE92008D0727 /* OculusWorldDemo.app */,
- 49DB65F61726F0C30097A8DD /* SensorBoxTest.app */,
- 37973B381739D78B0093BBB8 /* OculusRoomTiny.app */,
- );
- name = Products;
- sourceTree = "<group>";
- };
- 49A5334116E527820039CB59 /* Platform */ = {
- isa = PBXGroup;
- children = (
- 9BB10AF2173C49AC009ED618 /* Gamepad.h */,
- 9BB10AEF173C4918009ED618 /* OSX_Gamepad.cpp */,
- 9BB10AF0173C4918009ED618 /* OSX_Gamepad.h */,
- 9BEAD56317187CFF00A8AA1D /* OSX_WavPlayer.cpp */,
- 9BEAD56417187CFF00A8AA1D /* OSX_WavPlayer.h */,
- 9BBB8901171E2BE200563901 /* OSX_Platform.h */,
- 9BBB8902171E2BE200563901 /* OSX_Platform.mm */,
- 9BBB8903171E2BE200563901 /* OSX_PlatformObjc.h */,
- 49A5334216E527820039CB59 /* Platform.cpp */,
- 49A5334316E527820039CB59 /* Platform.h */,
- 49A5334416E527820039CB59 /* Platform_Default.h */,
- );
- name = Platform;
- path = CommonSrc/Platform;
- sourceTree = "<group>";
- };
- 49A5334916E527820039CB59 /* Render */ = {
- isa = PBXGroup;
- children = (
- 9BEAD56817187E8300A8AA1D /* Render_XmlSceneLoader.h */,
- 9BEAD56617187E7500A8AA1D /* Render_XmlSceneLoader.cpp */,
- 4985389316ED0218008D0727 /* Render_LoadTextureDDS.cpp */,
- 49A5335016E527820039CB59 /* Render_Device.cpp */,
- 49A5335116E527820039CB59 /* Render_Device.h */,
- 49A5335216E527820039CB59 /* Render_Font.h */,
- 49A5335316E527820039CB59 /* Render_FontEmbed_DejaVu48.h */,
- 49A5335416E527820039CB59 /* Render_GL_Device.cpp */,
- 49A5335516E527820039CB59 /* Render_GL_Device.h */,
- 49A5335816E527820039CB59 /* Render_LoadTextureTGA.cpp */,
- );
- name = Render;
- path = CommonSrc/Render;
- sourceTree = "<group>";
- };
- 49A5339816E544E30039CB59 /* Kernel */ = {
- isa = PBXGroup;
- children = (
- 499ED49B16E57027008EA2ED /* OVR_Alg.h */,
- 499ED49C16E57027008EA2ED /* OVR_Allocator.h */,
- 499ED49D16E57027008EA2ED /* OVR_Array.h */,
- 499ED49E16E57027008EA2ED /* OVR_Atomic.h */,
- 499ED49F16E57027008EA2ED /* OVR_Color.h */,
- 499ED4A016E57027008EA2ED /* OVR_ContainerAllocator.h */,
- 499ED4A116E57027008EA2ED /* OVR_File.h */,
- 499ED4A216E57027008EA2ED /* OVR_Hash.h */,
- 499ED4A316E57027008EA2ED /* OVR_KeyCodes.h */,
- 499ED4A416E57027008EA2ED /* OVR_List.h */,
- 499ED4A516E57027008EA2ED /* OVR_Log.h */,
- 499ED4A616E57027008EA2ED /* OVR_Math.h */,
- 499ED4A716E57027008EA2ED /* OVR_RefCount.h */,
- 499ED4A816E57027008EA2ED /* OVR_Std.h */,
- 499ED4A916E57027008EA2ED /* OVR_String.h */,
- 499ED4AA16E57027008EA2ED /* OVR_StringHash.h */,
- 499ED4AB16E57027008EA2ED /* OVR_SysFile.h */,
- 499ED4AC16E57027008EA2ED /* OVR_System.h */,
- 499ED4AD16E57027008EA2ED /* OVR_Threads.h */,
- 499ED4AE16E57027008EA2ED /* OVR_ThreadsWinAPI.cpp */,
- 499ED4AF16E57027008EA2ED /* OVR_Timer.h */,
- 499ED4B016E57027008EA2ED /* OVR_Types.h */,
- 499ED4B116E57027008EA2ED /* OVR_UTF8Util.h */,
- 49A5337116E544E30039CB59 /* OVR_Alg.cpp */,
- 49A5337316E544E30039CB59 /* OVR_Allocator.cpp */,
- 49A5337616E544E30039CB59 /* OVR_Atomic.cpp */,
- 49A5337A16E544E30039CB59 /* OVR_File.cpp */,
- 49A5337C16E544E30039CB59 /* OVR_FileFILE.cpp */,
- 49A5338016E544E30039CB59 /* OVR_Log.cpp */,
- 49A5338216E544E30039CB59 /* OVR_Math.cpp */,
- 49A5338416E544E30039CB59 /* OVR_RefCount.cpp */,
- 49A5338616E544E30039CB59 /* OVR_Std.cpp */,
- 49A5338816E544E30039CB59 /* OVR_String.cpp */,
- 49A5338A16E544E30039CB59 /* OVR_String_FormatUtil.cpp */,
- 49A5338B16E544E30039CB59 /* OVR_String_PathUtil.cpp */,
- 49A5338D16E544E30039CB59 /* OVR_SysFile.cpp */,
- 49A5338F16E544E30039CB59 /* OVR_System.cpp */,
- 49A5339216E544E30039CB59 /* OVR_ThreadsPthread.cpp */,
- 49A5339316E544E30039CB59 /* OVR_Timer.cpp */,
- 49A5339616E544E30039CB59 /* OVR_UTF8Util.cpp */,
- );
- path = Kernel;
- sourceTree = "<group>";
- };
- 49A533A816E544E30039CB59 /* Src */ = {
- isa = PBXGroup;
- children = (
- C50FA3CC177BB88E00730BB7 /* OVR_JSON.cpp */,
- C50FA3CD177BB88E00730BB7 /* OVR_JSON.h */,
- C50FA3CE177BB88E00730BB7 /* OVR_Profile.cpp */,
- C50FA3CF177BB88E00730BB7 /* OVR_Profile.h */,
- 9BD2A644172069BF00C3C389 /* OVR_SensorFilter.cpp */,
- 9BD2A645172069BF00C3C389 /* OVR_SensorFilter.h */,
- 9BEAD55A17187B5500A8AA1D /* Util */,
- 49A5339816E544E30039CB59 /* Kernel */,
- 9BCE542416F2694E007A23FF /* OVR_OSX_SensorDevice.cpp */,
- 9BCE53EB16F028A9007A23FF /* OVR_OSX_DeviceManager.cpp */,
- 9BCE53EC16F028AA007A23FF /* OVR_OSX_DeviceManager.h */,
- 9BCE53ED16F028AA007A23FF /* OVR_OSX_HIDDevice.cpp */,
- 9BCE53EE16F028AA007A23FF /* OVR_OSX_HIDDevice.h */,
- 9BCE53EF16F028AA007A23FF /* OVR_OSX_HMDDevice.cpp */,
- 9BCE53F016F028AA007A23FF /* OVR_OSX_HMDDevice.h */,
- 499ED4B216E5703B008EA2ED /* OVR_Device.h */,
- 49A5339A16E544E30039CB59 /* OVR_DeviceConstants.h */,
- 49A5339B16E544E30039CB59 /* OVR_DeviceHandle.cpp */,
- 49A5339C16E544E30039CB59 /* OVR_DeviceHandle.h */,
- 49A5339D16E544E30039CB59 /* OVR_DeviceImpl.cpp */,
- 49A5339E16E544E30039CB59 /* OVR_DeviceImpl.h */,
- 49A5339F16E544E30039CB59 /* OVR_DeviceMessages.h */,
- 9BCE53FE16F02A56007A23FF /* OVR_SensorImpl.cpp */,
- 9BCE53FF16F02A56007A23FF /* OVR_SensorImpl.h */,
- 9BCE53F416F0293A007A23FF /* OVR_HIDDevice.h */,
- 9BCE53F516F0293A007A23FF /* OVR_HIDDeviceBase.h */,
- 9BCE53F616F0293A007A23FF /* OVR_HIDDeviceImpl.h */,
- 9BCE53F716F0293A007A23FF /* OVR_LatencyTestImpl.cpp */,
- 9BCE53F816F0293A007A23FF /* OVR_LatencyTestImpl.h */,
- 49A533A416E544E30039CB59 /* OVR_SensorFusion.cpp */,
- 49A533A516E544E30039CB59 /* OVR_SensorFusion.h */,
- 49A533A616E544E30039CB59 /* OVR_ThreadCommandQueue.cpp */,
- 49A533A716E544E30039CB59 /* OVR_ThreadCommandQueue.h */,
- );
- name = Src;
- path = ../LibOVR/Src;
- sourceTree = "<group>";
- };
- 9B22CBB317187EC70046D43D /* OculusWorldDemo */ = {
- isa = PBXGroup;
- children = (
- 4985388216ECFF23008D0727 /* Player.cpp */,
- 4985388316ECFF23008D0727 /* Player.h */,
- 4985388116ECFF23008D0727 /* OculusWorldDemo.cpp */,
- );
- name = OculusWorldDemo;
- sourceTree = "<group>";
- };
- 9B22CBB417187F380046D43D /* 3rdParty */ = {
- isa = PBXGroup;
- children = (
- 9B22CBB517187F5C0046D43D /* tinyxml2.h */,
- 4985389116ED0204008D0727 /* tinyxml2.cpp */,
- );
- name = 3rdParty;
- sourceTree = "<group>";
- };
- 9B6DEF831728A60A0071E76B /* SensorBox */ = {
- isa = PBXGroup;
- children = (
- 9B6DEF841728A6560071E76B /* SensorBoxTest.cpp */,
- );
- name = SensorBox;
- sourceTree = "<group>";
- };
- 9BEAD55A17187B5500A8AA1D /* Util */ = {
- isa = PBXGroup;
- children = (
- 9BD2A640172069B300C3C389 /* Util_MagCalibration.cpp */,
- 9BD2A641172069B300C3C389 /* Util_MagCalibration.h */,
- 9BEAD55B17187B8A00A8AA1D /* Util_LatencyTest.cpp */,
- 9BEAD55C17187B8A00A8AA1D /* Util_LatencyTest.h */,
- 9BEAD55D17187B8A00A8AA1D /* Util_Render_Stereo.cpp */,
- 9BEAD55E17187B8A00A8AA1D /* Util_Render_Stereo.h */,
- );
- name = Util;
- sourceTree = "<group>";
- };
-/* End PBXGroup section */
-
-/* Begin PBXHeadersBuildPhase section */
- 49A5336B16E544BE0039CB59 /* Headers */ = {
- isa = PBXHeadersBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 9BCE53F916F0293A007A23FF /* OVR_HIDDevice.h in Headers */,
- 9BCE53FA16F0293A007A23FF /* OVR_HIDDeviceBase.h in Headers */,
- 9BCE53FB16F0293A007A23FF /* OVR_HIDDeviceImpl.h in Headers */,
- 9BCE53FD16F0293A007A23FF /* OVR_LatencyTestImpl.h in Headers */,
- 9BCE540116F02A56007A23FF /* OVR_SensorImpl.h in Headers */,
- 9BCE541816F02ADB007A23FF /* OVR_OSX_DeviceManager.h in Headers */,
- 9BCE541916F02AE6007A23FF /* OVR_OSX_HIDDevice.h in Headers */,
- 9BCE541B16F02AF1007A23FF /* OVR_OSX_HMDDevice.h in Headers */,
- 9BCE541C16F02B04007A23FF /* OVR_Device.h in Headers */,
- 9BCE541D16F02B13007A23FF /* OVR_DeviceConstants.h in Headers */,
- 9BCE541E16F02B1D007A23FF /* OVR_DeviceHandle.h in Headers */,
- 9BCE541F16F02B26007A23FF /* OVR_DeviceImpl.h in Headers */,
- 9BCE542016F02B2A007A23FF /* OVR_DeviceMessages.h in Headers */,
- 9BCE542216F02B88007A23FF /* OVR_SensorFusion.h in Headers */,
- 9BCE542316F02B91007A23FF /* OVR_ThreadCommandQueue.h in Headers */,
- 9BEAD56017187B8A00A8AA1D /* Util_LatencyTest.h in Headers */,
- 9BEAD56217187B8A00A8AA1D /* Util_Render_Stereo.h in Headers */,
- 9BD2A643172069B300C3C389 /* Util_MagCalibration.h in Headers */,
- 9BD2A647172069BF00C3C389 /* OVR_SensorFilter.h in Headers */,
- C50FA3D1177BB88E00730BB7 /* OVR_JSON.h in Headers */,
- C50FA3D3177BB88E00730BB7 /* OVR_Profile.h in Headers */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXHeadersBuildPhase section */
-
-/* Begin PBXNativeTarget section */
- 37973B371739D78B0093BBB8 /* OculusRoomTiny */ = {
- isa = PBXNativeTarget;
- buildConfigurationList = 37973B4E1739D7930093BBB8 /* Build configuration list for PBXNativeTarget "OculusRoomTiny" */;
- buildPhases = (
- 37973B341739D78B0093BBB8 /* Sources */,
- 37973B351739D78B0093BBB8 /* Frameworks */,
- 37973B361739D78B0093BBB8 /* Resources */,
- );
- buildRules = (
- );
- dependencies = (
- 37973B5B1739FA100093BBB8 /* PBXTargetDependency */,
- );
- name = OculusRoomTiny;
- productName = OculusRoomTiny;
- productReference = 37973B381739D78B0093BBB8 /* OculusRoomTiny.app */;
- productType = "com.apple.product-type.application";
- };
- 4985385C16ECFE92008D0727 /* OculusWorldDemo */ = {
- isa = PBXNativeTarget;
- buildConfigurationList = 4985387116ECFE92008D0727 /* Build configuration list for PBXNativeTarget "OculusWorldDemo" */;
- buildPhases = (
- 4985385916ECFE92008D0727 /* Sources */,
- 4985385A16ECFE92008D0727 /* Frameworks */,
- 4985385B16ECFE92008D0727 /* Resources */,
- );
- buildRules = (
- );
- dependencies = (
- 4985389016ECFF5C008D0727 /* PBXTargetDependency */,
- );
- name = OculusWorldDemo;
- productName = OculusWorldDemo;
- productReference = 4985385D16ECFE92008D0727 /* OculusWorldDemo.app */;
- productType = "com.apple.product-type.application";
- };
- 49A5336C16E544BE0039CB59 /* ovr */ = {
- isa = PBXNativeTarget;
- buildConfigurationList = 49A5336E16E544BE0039CB59 /* Build configuration list for PBXNativeTarget "ovr" */;
- buildPhases = (
- 49A5336916E544BE0039CB59 /* Sources */,
- 49A5336A16E544BE0039CB59 /* Frameworks */,
- 49A5336B16E544BE0039CB59 /* Headers */,
- );
- buildRules = (
- );
- dependencies = (
- );
- name = ovr;
- productName = ovr;
- productReference = 49A5336D16E544BE0039CB59 /* libovr.a */;
- productType = "com.apple.product-type.library.static";
- };
- 49DB65F51726F0C30097A8DD /* SensorBoxTest */ = {
- isa = PBXNativeTarget;
- buildConfigurationList = 49DB660C1726F0C30097A8DD /* Build configuration list for PBXNativeTarget "SensorBoxTest" */;
- buildPhases = (
- 49DB65F21726F0C30097A8DD /* Sources */,
- 49DB65F31726F0C30097A8DD /* Frameworks */,
- 49DB65F41726F0C30097A8DD /* Resources */,
- );
- buildRules = (
- );
- dependencies = (
- 49DB660E1726F0CD0097A8DD /* PBXTargetDependency */,
- );
- name = SensorBoxTest;
- productName = SensorBoxTest;
- productReference = 49DB65F61726F0C30097A8DD /* SensorBoxTest.app */;
- productType = "com.apple.product-type.application";
- };
-/* End PBXNativeTarget section */
-
-/* Begin PBXProject section */
- 49A5332B16E527490039CB59 /* Project object */ = {
- isa = PBXProject;
- attributes = {
- LastUpgradeCheck = 0460;
- ORGANIZATIONNAME = "Oculus VR";
- };
- buildConfigurationList = 49A5332E16E527490039CB59 /* Build configuration list for PBXProject "LibOVR_With_Samples" */;
- compatibilityVersion = "Xcode 3.2";
- developmentRegion = English;
- hasScannedForEncodings = 0;
- knownRegions = (
- en,
- );
- mainGroup = 49A5332A16E527490039CB59;
- productRefGroup = 49A5333416E527490039CB59 /* Products */;
- projectDirPath = "";
- projectRoot = "";
- targets = (
- 49A5336C16E544BE0039CB59 /* ovr */,
- 4985385C16ECFE92008D0727 /* OculusWorldDemo */,
- 49DB65F51726F0C30097A8DD /* SensorBoxTest */,
- 37973B371739D78B0093BBB8 /* OculusRoomTiny */,
- );
- };
-/* End PBXProject section */
-
-/* Begin PBXResourcesBuildPhase section */
- 37973B361739D78B0093BBB8 /* Resources */ = {
- isa = PBXResourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
- 4985385B16ECFE92008D0727 /* Resources */ = {
- isa = PBXResourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 4985389716ED1AA7008D0727 /* Assets in Resources */,
- 9BA4DDB81727061100CF7715 /* Oculus.icns in Resources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
- 49DB65F41726F0C30097A8DD /* Resources */ = {
- isa = PBXResourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 9BA4DDB91727083500CF7715 /* Oculus.icns in Resources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXResourcesBuildPhase section */
-
-/* Begin PBXSourcesBuildPhase section */
- 37973B341739D78B0093BBB8 /* Sources */ = {
- isa = PBXSourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 37973B501739E1B60093BBB8 /* OculusRoomModel.cpp in Sources */,
- 37973B531739E1D20093BBB8 /* RenderTiny_Device.cpp in Sources */,
- 37973B561739E9230093BBB8 /* RenderTiny_GL_Device.cpp in Sources */,
- 37973B591739E9E80093BBB8 /* OSX_OculusRoomTiny.mm in Sources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
- 4985385916ECFE92008D0727 /* Sources */ = {
- isa = PBXSourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 4985388616ECFF2D008D0727 /* OculusWorldDemo.cpp in Sources */,
- 4985388716ECFF2D008D0727 /* Player.cpp in Sources */,
- 4985388016ECFEE5008D0727 /* Platform.cpp in Sources */,
- 4985387416ECFED8008D0727 /* Render_Device.cpp in Sources */,
- 4985387816ECFED8008D0727 /* Render_GL_Device.cpp in Sources */,
- 4985387A16ECFED8008D0727 /* Render_LoadTextureTGA.cpp in Sources */,
- 4985389216ED0204008D0727 /* tinyxml2.cpp in Sources */,
- 4985389516ED0218008D0727 /* Render_LoadTextureDDS.cpp in Sources */,
- 9BEAD56517187CFF00A8AA1D /* OSX_WavPlayer.cpp in Sources */,
- 9BEAD56717187E7500A8AA1D /* Render_XmlSceneLoader.cpp in Sources */,
- 9BA4DDB61721E12400CF7715 /* OSX_Platform.mm in Sources */,
- 9BB10AF1173C4918009ED618 /* OSX_Gamepad.cpp in Sources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
- 49A5336916E544BE0039CB59 /* Sources */ = {
- isa = PBXSourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 4945070616E5462A00B9FF78 /* OVR_DeviceHandle.cpp in Sources */,
- 4945070816E5462A00B9FF78 /* OVR_DeviceImpl.cpp in Sources */,
- 4945070F16E5462A00B9FF78 /* OVR_SensorFusion.cpp in Sources */,
- 4945071116E5462A00B9FF78 /* OVR_ThreadCommandQueue.cpp in Sources */,
- 494506DD16E5461F00B9FF78 /* OVR_Alg.cpp in Sources */,
- 494506DF16E5461F00B9FF78 /* OVR_Allocator.cpp in Sources */,
- 494506E216E5461F00B9FF78 /* OVR_Atomic.cpp in Sources */,
- 494506E616E5461F00B9FF78 /* OVR_File.cpp in Sources */,
- 494506E816E5461F00B9FF78 /* OVR_FileFILE.cpp in Sources */,
- 494506EC16E5461F00B9FF78 /* OVR_Log.cpp in Sources */,
- 494506EE16E5461F00B9FF78 /* OVR_Math.cpp in Sources */,
- 494506F016E5461F00B9FF78 /* OVR_RefCount.cpp in Sources */,
- 494506F216E5461F00B9FF78 /* OVR_Std.cpp in Sources */,
- 494506F416E5461F00B9FF78 /* OVR_String.cpp in Sources */,
- 494506F616E5461F00B9FF78 /* OVR_String_FormatUtil.cpp in Sources */,
- 494506F716E5461F00B9FF78 /* OVR_String_PathUtil.cpp in Sources */,
- 494506F916E5461F00B9FF78 /* OVR_SysFile.cpp in Sources */,
- 494506FB16E5461F00B9FF78 /* OVR_System.cpp in Sources */,
- 494506FE16E5461F00B9FF78 /* OVR_ThreadsPthread.cpp in Sources */,
- 494506FF16E5461F00B9FF78 /* OVR_Timer.cpp in Sources */,
- 4945070216E5461F00B9FF78 /* OVR_UTF8Util.cpp in Sources */,
- 9BCE53FC16F0293A007A23FF /* OVR_LatencyTestImpl.cpp in Sources */,
- 9BCE540016F02A56007A23FF /* OVR_SensorImpl.cpp in Sources */,
- 9BCE541616F02ABC007A23FF /* OVR_OSX_DeviceManager.cpp in Sources */,
- 9BCE541716F02AD5007A23FF /* OVR_OSX_HIDDevice.cpp in Sources */,
- 9BCE541A16F02AEB007A23FF /* OVR_OSX_HMDDevice.cpp in Sources */,
- 9BCE542516F2694F007A23FF /* OVR_OSX_SensorDevice.cpp in Sources */,
- 9BEAD55F17187B8A00A8AA1D /* Util_LatencyTest.cpp in Sources */,
- 9BEAD56117187B8A00A8AA1D /* Util_Render_Stereo.cpp in Sources */,
- 9BD2A642172069B300C3C389 /* Util_MagCalibration.cpp in Sources */,
- 9BD2A646172069BF00C3C389 /* OVR_SensorFilter.cpp in Sources */,
- C50FA3D0177BB88E00730BB7 /* OVR_JSON.cpp in Sources */,
- C50FA3D2177BB88E00730BB7 /* OVR_Profile.cpp in Sources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
- 49DB65F21726F0C30097A8DD /* Sources */ = {
- isa = PBXSourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 439FE6E217BE2E21007EFD34 /* OSX_Gamepad.cpp in Sources */,
- 49DB66111726F0F80097A8DD /* Render_LoadTextureDDS.cpp in Sources */,
- 49DB66121726F0F80097A8DD /* Render_Device.cpp in Sources */,
- 49DB66131726F0F80097A8DD /* Render_GL_Device.cpp in Sources */,
- 49DB66141726F0F80097A8DD /* Render_LoadTextureTGA.cpp in Sources */,
- 49DB660F1726F0EA0097A8DD /* OSX_Platform.mm in Sources */,
- 49DB66101726F0EA0097A8DD /* Platform.cpp in Sources */,
- 9B6DEF851728A6560071E76B /* SensorBoxTest.cpp in Sources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXSourcesBuildPhase section */
-
-/* Begin PBXTargetDependency section */
- 37973B5B1739FA100093BBB8 /* PBXTargetDependency */ = {
- isa = PBXTargetDependency;
- target = 49A5336C16E544BE0039CB59 /* ovr */;
- targetProxy = 37973B5A1739FA100093BBB8 /* PBXContainerItemProxy */;
- };
- 4985389016ECFF5C008D0727 /* PBXTargetDependency */ = {
- isa = PBXTargetDependency;
- target = 49A5336C16E544BE0039CB59 /* ovr */;
- targetProxy = 4985388F16ECFF5C008D0727 /* PBXContainerItemProxy */;
- };
- 49DB660E1726F0CD0097A8DD /* PBXTargetDependency */ = {
- isa = PBXTargetDependency;
- target = 49A5336C16E544BE0039CB59 /* ovr */;
- targetProxy = 49DB660D1726F0CD0097A8DD /* PBXContainerItemProxy */;
- };
-/* End PBXTargetDependency section */
-
-/* Begin XCBuildConfiguration section */
- 37973B4C1739D78C0093BBB8 /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- CLANG_CXX_LIBRARY = "libstdc++";
- COMBINE_HIDPI_IMAGES = YES;
- CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
- GCC_PRECOMPILE_PREFIX_HEADER = NO;
- GCC_PREPROCESSOR_DEFINITIONS = (
- "DEBUG=1",
- "$(inherited)",
- );
- HEADER_SEARCH_PATHS = (
- ../LibOVR/Src,
- ../LibOVR/Include,
- );
- INFOPLIST_FILE = "LibOVR_With_Samples.xcodeproj/OculusRoomTiny-Info.plist";
- MACOSX_DEPLOYMENT_TARGET = 10.6;
- ONLY_ACTIVE_ARCH = NO;
- PRODUCT_NAME = "$(TARGET_NAME)";
- SYMROOT = OculusRoomTiny/MacOS/Debug;
- WRAPPER_EXTENSION = app;
- };
- name = Debug;
- };
- 37973B4D1739D78C0093BBB8 /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- CLANG_CXX_LIBRARY = "libstdc++";
- COMBINE_HIDPI_IMAGES = YES;
- CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
- GCC_PRECOMPILE_PREFIX_HEADER = NO;
- HEADER_SEARCH_PATHS = (
- ../LibOVR/Src,
- ../LibOVR/Include,
- );
- INFOPLIST_FILE = "LibOVR_With_Samples.xcodeproj/OculusRoomTiny-Info.plist";
- MACOSX_DEPLOYMENT_TARGET = 10.6;
- ONLY_ACTIVE_ARCH = NO;
- PRODUCT_NAME = "$(TARGET_NAME)";
- SYMROOT = OculusRoomTiny/MacOS/Release;
- WRAPPER_EXTENSION = app;
- };
- name = Release;
- };
- 4985387216ECFE92008D0727 /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ARCHS = "$(ARCHS_STANDARD_64_BIT)";
- COMBINE_HIDPI_IMAGES = YES;
- CONFIGURATION_BUILD_DIR = OculusWorldDemo/MacOS/Debug;
- GCC_PRECOMPILE_PREFIX_HEADER = NO;
- GCC_PREFIX_HEADER = "";
- GCC_PREPROCESSOR_DEFINITIONS = (
- "DEBUG=1",
- "$(inherited)",
- );
- "GCC_PREPROCESSOR_DEFINITIONS[arch=*]" = (
- "DEBUG=1",
- "$(inherited)",
- );
- HEADER_SEARCH_PATHS = (
- ../LibOVR/Src,
- ../LibOVR/Include,
- CommonSrc,
- ../3rdParty/TinyXml,
- );
- INFOPLIST_FILE = "LibOVR_With_Samples.xcodeproj/OculusWorldDemo-Info.plist";
- PRODUCT_NAME = "$(TARGET_NAME)";
- SYMROOT = OculusWorldDemo/MacOS/Debug;
- WRAPPER_EXTENSION = app;
- };
- name = Debug;
- };
- 4985387316ECFE92008D0727 /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ARCHS = "$(ARCHS_STANDARD_64_BIT)";
- COMBINE_HIDPI_IMAGES = YES;
- CONFIGURATION_BUILD_DIR = OculusWorldDemo/MacOS/Release;
- GCC_PRECOMPILE_PREFIX_HEADER = NO;
- GCC_PREFIX_HEADER = "";
- HEADER_SEARCH_PATHS = (
- ../LibOVR/Src,
- ../LibOVR/Include,
- CommonSrc,
- ../3rdParty/TinyXml,
- );
- INFOPLIST_FILE = "LibOVR_With_Samples.xcodeproj/OculusWorldDemo-Info.plist";
- PRODUCT_NAME = "$(TARGET_NAME)";
- SYMROOT = OculusWorldDemo/MacOS/Release;
- WRAPPER_EXTENSION = app;
- };
- name = Release;
- };
- 49A5333A16E527490039CB59 /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(ARCHS_STANDARD_64_BIT)";
- CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
- CLANG_CXX_LIBRARY = "libstdc++";
- CLANG_WARN_CONSTANT_CONVERSION = YES;
- CLANG_WARN_EMPTY_BODY = YES;
- CLANG_WARN_ENUM_CONVERSION = YES;
- CLANG_WARN_INT_CONVERSION = YES;
- CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
- CONFIGURATION_BUILD_DIR = ../LibOVR/Lib/MacOS/Debug;
- COPY_PHASE_STRIP = NO;
- DEBUG_INFORMATION_FORMAT = dwarf;
- GCC_C_LANGUAGE_STANDARD = gnu99;
- GCC_DYNAMIC_NO_PIC = NO;
- GCC_ENABLE_CPP_EXCEPTIONS = NO;
- GCC_ENABLE_CPP_RTTI = NO;
- GCC_ENABLE_OBJC_EXCEPTIONS = YES;
- GCC_OPTIMIZATION_LEVEL = 0;
- GCC_PREPROCESSOR_DEFINITIONS = (
- "DEBUG=1",
- OVR_BUILD_DEBUG,
- "$(inherited)",
- );
- GCC_SYMBOLS_PRIVATE_EXTERN = NO;
- GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
- GCC_WARN_ABOUT_RETURN_TYPE = YES;
- GCC_WARN_UNINITIALIZED_AUTOS = YES;
- GCC_WARN_UNUSED_VARIABLE = YES;
- HEADER_SEARCH_PATHS = (
- ../LibOVR/Src,
- ../LibOVR/Include,
- CommonSrc,
- );
- LIBRARY_SEARCH_PATHS = "../LibOVR/Lib/MacOS/$(CONFIGURATION)";
- MACOSX_DEPLOYMENT_TARGET = 10.6;
- ONLY_ACTIVE_ARCH = NO;
- SDKROOT = macosx;
- SUPPORTED_PLATFORMS = macosx;
- };
- name = Debug;
- };
- 49A5333B16E527490039CB59 /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(ARCHS_STANDARD_64_BIT)";
- CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
- CLANG_CXX_LIBRARY = "libstdc++";
- CLANG_WARN_CONSTANT_CONVERSION = YES;
- CLANG_WARN_EMPTY_BODY = YES;
- CLANG_WARN_ENUM_CONVERSION = YES;
- CLANG_WARN_INT_CONVERSION = YES;
- CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
- CONFIGURATION_BUILD_DIR = ../LibOVR/Lib/MacOS/Release;
- COPY_PHASE_STRIP = YES;
- DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
- GCC_C_LANGUAGE_STANDARD = gnu99;
- GCC_ENABLE_CPP_EXCEPTIONS = NO;
- GCC_ENABLE_CPP_RTTI = NO;
- GCC_ENABLE_OBJC_EXCEPTIONS = YES;
- GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
- GCC_WARN_ABOUT_RETURN_TYPE = YES;
- GCC_WARN_UNINITIALIZED_AUTOS = YES;
- GCC_WARN_UNUSED_VARIABLE = YES;
- HEADER_SEARCH_PATHS = (
- ../LibOVR/Src,
- ../LibOVR/Include,
- CommonSrc,
- );
- LIBRARY_SEARCH_PATHS = "../LibOVR/Lib/MacOS/$(CONFIGURATION)";
- MACOSX_DEPLOYMENT_TARGET = 10.6;
- ONLY_ACTIVE_ARCH = NO;
- SDKROOT = macosx;
- SUPPORTED_PLATFORMS = macosx;
- };
- name = Release;
- };
- 49A5336F16E544BE0039CB59 /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
- COMBINE_HIDPI_IMAGES = YES;
- EXECUTABLE_PREFIX = lib;
- GCC_ENABLE_CPP_EXCEPTIONS = NO;
- GCC_ENABLE_CPP_RTTI = NO;
- GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)";
- LIBRARY_SEARCH_PATHS = (
- "../LIbOVR/MacOS/$(CONFIGURATION)",
- "\"$(SRCROOT)/../LibOVR/Lib/MacOS/Debug\"",
- "\"$(SRCROOT)/../LibOVR/Lib/MacOS/LibOVR_With_Samples.build/Debug/ovr.build/Objects-normal/i386\"",
- "\"$(SRCROOT)/../LibOVR/Lib/MacOS/LibOVR_With_Samples.build/Debug/ovr.build/Objects-normal/x86_64\"",
- "\"$(SRCROOT)/../LibOVR/Lib/MacOS/LibOVR_With_Samples.build/Release/ovr.build/Objects-normal/i386\"",
- "\"$(SRCROOT)/../LibOVR/Lib/MacOS/LibOVR_With_Samples.build/Release/ovr.build/Objects-normal/x86_64\"",
- "\"$(SRCROOT)/../LibOVR/Lib/MacOS/Release\"",
- "\"$(SRCROOT)/../LibOVR/Lib/Win32\"",
- "\"$(SRCROOT)/../LibOVR/Lib/x64\"",
- );
- PRODUCT_NAME = "$(TARGET_NAME)";
- SYMROOT = ../LibOVR/Lib/MacOS;
- };
- name = Debug;
- };
- 49A5337016E544BE0039CB59 /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
- COMBINE_HIDPI_IMAGES = YES;
- EXECUTABLE_PREFIX = lib;
- GCC_ENABLE_CPP_EXCEPTIONS = NO;
- GCC_ENABLE_CPP_RTTI = NO;
- LIBRARY_SEARCH_PATHS = (
- "../LIbOVR/MacOS/$(CONFIGURATION)",
- "\"$(SRCROOT)/../LibOVR/Lib/MacOS/Debug\"",
- "\"$(SRCROOT)/../LibOVR/Lib/MacOS/LibOVR_With_Samples.build/Debug/ovr.build/Objects-normal/i386\"",
- "\"$(SRCROOT)/../LibOVR/Lib/MacOS/LibOVR_With_Samples.build/Debug/ovr.build/Objects-normal/x86_64\"",
- "\"$(SRCROOT)/../LibOVR/Lib/MacOS/LibOVR_With_Samples.build/Release/ovr.build/Objects-normal/i386\"",
- "\"$(SRCROOT)/../LibOVR/Lib/MacOS/LibOVR_With_Samples.build/Release/ovr.build/Objects-normal/x86_64\"",
- "\"$(SRCROOT)/../LibOVR/Lib/MacOS/Release\"",
- "\"$(SRCROOT)/../LibOVR/Lib/Win32\"",
- "\"$(SRCROOT)/../LibOVR/Lib/x64\"",
- );
- PRODUCT_NAME = "$(TARGET_NAME)";
- SYMROOT = ../LibOVR/Lib/MacOS;
- };
- name = Release;
- };
- 49DB660A1726F0C30097A8DD /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- CLANG_CXX_LIBRARY = "libstdc++";
- COMBINE_HIDPI_IMAGES = YES;
- CONFIGURATION_BUILD_DIR = Samples/SensorBoxTest/MacOS/Debug;
- GCC_PRECOMPILE_PREFIX_HEADER = NO;
- GCC_PREFIX_HEADER = "";
- GCC_PREPROCESSOR_DEFINITIONS = (
- "DEBUG=1",
- "$(inherited)",
- );
- INFOPLIST_FILE = "LibOVR_With_Samples.xcodeproj/SensorBoxTest-Info.plist";
- MACOSX_DEPLOYMENT_TARGET = 10.6;
- ONLY_ACTIVE_ARCH = NO;
- PRODUCT_NAME = "$(TARGET_NAME)";
- WRAPPER_EXTENSION = app;
- };
- name = Debug;
- };
- 49DB660B1726F0C30097A8DD /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- CLANG_CXX_LIBRARY = "libstdc++";
- COMBINE_HIDPI_IMAGES = YES;
- CONFIGURATION_BUILD_DIR = Samples/SensorBoxTest/MacOS/Release;
- GCC_PRECOMPILE_PREFIX_HEADER = NO;
- GCC_PREFIX_HEADER = "";
- INFOPLIST_FILE = "LibOVR_With_Samples.xcodeproj/SensorBoxTest-Info.plist";
- MACOSX_DEPLOYMENT_TARGET = 10.6;
- ONLY_ACTIVE_ARCH = NO;
- PRODUCT_NAME = "$(TARGET_NAME)";
- WRAPPER_EXTENSION = app;
- };
- name = Release;
- };
-/* End XCBuildConfiguration section */
-
-/* Begin XCConfigurationList section */
- 37973B4E1739D7930093BBB8 /* Build configuration list for PBXNativeTarget "OculusRoomTiny" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- 37973B4C1739D78C0093BBB8 /* Debug */,
- 37973B4D1739D78C0093BBB8 /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
- 4985387116ECFE92008D0727 /* Build configuration list for PBXNativeTarget "OculusWorldDemo" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- 4985387216ECFE92008D0727 /* Debug */,
- 4985387316ECFE92008D0727 /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
- 49A5332E16E527490039CB59 /* Build configuration list for PBXProject "LibOVR_With_Samples" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- 49A5333A16E527490039CB59 /* Debug */,
- 49A5333B16E527490039CB59 /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
- 49A5336E16E544BE0039CB59 /* Build configuration list for PBXNativeTarget "ovr" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- 49A5336F16E544BE0039CB59 /* Debug */,
- 49A5337016E544BE0039CB59 /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
- 49DB660C1726F0C30097A8DD /* Build configuration list for PBXNativeTarget "SensorBoxTest" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- 49DB660A1726F0C30097A8DD /* Debug */,
- 49DB660B1726F0C30097A8DD /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
-/* End XCConfigurationList section */
- };
- rootObject = 49A5332B16E527490039CB59 /* Project object */;
-}
diff --git a/Samples/LibOVR_With_Samples.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Samples/LibOVR_With_Samples.xcodeproj/project.xcworkspace/contents.xcworkspacedata
deleted file mode 100644
index 1a80571..0000000
--- a/Samples/LibOVR_With_Samples.xcodeproj/project.xcworkspace/contents.xcworkspacedata
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Workspace
- version = "1.0">
- <FileRef
- location = "self:LibOVR_With_Samples.xcodeproj">
- </FileRef>
-</Workspace>
diff --git a/Samples/LibOVR_With_Samples.xcodeproj/project.xcworkspace/xcuserdata/Nate.xcuserdatad/UserInterfaceState.xcuserstate b/Samples/LibOVR_With_Samples.xcodeproj/project.xcworkspace/xcuserdata/Nate.xcuserdatad/UserInterfaceState.xcuserstate
deleted file mode 100644
index be3c4ab..0000000
--- a/Samples/LibOVR_With_Samples.xcodeproj/project.xcworkspace/xcuserdata/Nate.xcuserdatad/UserInterfaceState.xcuserstate
+++ /dev/null
Binary files differ
diff --git a/Samples/LibOVR_With_Samples.xcodeproj/project.xcworkspace/xcuserdata/Nate.xcuserdatad/WorkspaceSettings.xcsettings b/Samples/LibOVR_With_Samples.xcodeproj/project.xcworkspace/xcuserdata/Nate.xcuserdatad/WorkspaceSettings.xcsettings
deleted file mode 100644
index 5202989..0000000
--- a/Samples/LibOVR_With_Samples.xcodeproj/project.xcworkspace/xcuserdata/Nate.xcuserdatad/WorkspaceSettings.xcsettings
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>BuildLocationStyle</key>
- <string>UseTargetSettings</string>
- <key>CustomBuildLocationType</key>
- <string>RelativeToDerivedData</string>
- <key>DerivedDataLocationStyle</key>
- <string>Default</string>
- <key>IssueFilterStyle</key>
- <string>ShowActiveSchemeOnly</string>
- <key>LiveSourceIssuesEnabled</key>
- <true/>
- <key>SnapshotAutomaticallyBeforeSignificantChanges</key>
- <true/>
- <key>SnapshotLocationStyle</key>
- <string>Default</string>
-</dict>
-</plist>
diff --git a/Samples/LibOVR_With_Samples.xcodeproj/xcshareddata/xcschemes/OculusRoomTiny.xcscheme b/Samples/LibOVR_With_Samples.xcodeproj/xcshareddata/xcschemes/OculusRoomTiny.xcscheme
deleted file mode 100644
index ca15d67..0000000
--- a/Samples/LibOVR_With_Samples.xcodeproj/xcshareddata/xcschemes/OculusRoomTiny.xcscheme
+++ /dev/null
@@ -1,86 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Scheme
- LastUpgradeVersion = "0460"
- version = "1.3">
- <BuildAction
- parallelizeBuildables = "YES"
- buildImplicitDependencies = "YES">
- <BuildActionEntries>
- <BuildActionEntry
- buildForTesting = "YES"
- buildForRunning = "YES"
- buildForProfiling = "YES"
- buildForArchiving = "YES"
- buildForAnalyzing = "YES">
- <BuildableReference
- BuildableIdentifier = "primary"
- BlueprintIdentifier = "37973B371739D78B0093BBB8"
- BuildableName = "OculusRoomTiny.app"
- BlueprintName = "OculusRoomTiny"
- ReferencedContainer = "container:LibOVR_With_Samples.xcodeproj">
- </BuildableReference>
- </BuildActionEntry>
- </BuildActionEntries>
- </BuildAction>
- <TestAction
- selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
- selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
- shouldUseLaunchSchemeArgsEnv = "YES"
- buildConfiguration = "Debug">
- <Testables>
- </Testables>
- <MacroExpansion>
- <BuildableReference
- BuildableIdentifier = "primary"
- BlueprintIdentifier = "37973B371739D78B0093BBB8"
- BuildableName = "OculusRoomTiny.app"
- BlueprintName = "OculusRoomTiny"
- ReferencedContainer = "container:LibOVR_With_Samples.xcodeproj">
- </BuildableReference>
- </MacroExpansion>
- </TestAction>
- <LaunchAction
- selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
- selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
- launchStyle = "0"
- useCustomWorkingDirectory = "NO"
- buildConfiguration = "Debug"
- ignoresPersistentStateOnLaunch = "NO"
- debugDocumentVersioning = "YES"
- allowLocationSimulation = "YES">
- <BuildableProductRunnable>
- <BuildableReference
- BuildableIdentifier = "primary"
- BlueprintIdentifier = "37973B371739D78B0093BBB8"
- BuildableName = "OculusRoomTiny.app"
- BlueprintName = "OculusRoomTiny"
- ReferencedContainer = "container:LibOVR_With_Samples.xcodeproj">
- </BuildableReference>
- </BuildableProductRunnable>
- <AdditionalOptions>
- </AdditionalOptions>
- </LaunchAction>
- <ProfileAction
- shouldUseLaunchSchemeArgsEnv = "YES"
- savedToolIdentifier = ""
- useCustomWorkingDirectory = "NO"
- buildConfiguration = "Release"
- debugDocumentVersioning = "YES">
- <BuildableProductRunnable>
- <BuildableReference
- BuildableIdentifier = "primary"
- BlueprintIdentifier = "37973B371739D78B0093BBB8"
- BuildableName = "OculusRoomTiny.app"
- BlueprintName = "OculusRoomTiny"
- ReferencedContainer = "container:LibOVR_With_Samples.xcodeproj">
- </BuildableReference>
- </BuildableProductRunnable>
- </ProfileAction>
- <AnalyzeAction
- buildConfiguration = "Debug">
- </AnalyzeAction>
- <ArchiveAction
- buildConfiguration = "Release"
- revealArchiveInOrganizer = "YES">
- </ArchiveAction>
-</Scheme>
diff --git a/Samples/LibOVR_With_Samples.xcodeproj/xcshareddata/xcschemes/OculusWorldDemo.xcscheme b/Samples/LibOVR_With_Samples.xcodeproj/xcshareddata/xcschemes/OculusWorldDemo.xcscheme
deleted file mode 100644
index df712e0..0000000
--- a/Samples/LibOVR_With_Samples.xcodeproj/xcshareddata/xcschemes/OculusWorldDemo.xcscheme
+++ /dev/null
@@ -1,86 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Scheme
- LastUpgradeVersion = "0460"
- version = "1.3">
- <BuildAction
- parallelizeBuildables = "YES"
- buildImplicitDependencies = "YES">
- <BuildActionEntries>
- <BuildActionEntry
- buildForTesting = "YES"
- buildForRunning = "YES"
- buildForProfiling = "YES"
- buildForArchiving = "YES"
- buildForAnalyzing = "YES">
- <BuildableReference
- BuildableIdentifier = "primary"
- BlueprintIdentifier = "4985385C16ECFE92008D0727"
- BuildableName = "OculusWorldDemo.app"
- BlueprintName = "OculusWorldDemo"
- ReferencedContainer = "container:LibOVR_With_Samples.xcodeproj">
- </BuildableReference>
- </BuildActionEntry>
- </BuildActionEntries>
- </BuildAction>
- <TestAction
- selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
- selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
- shouldUseLaunchSchemeArgsEnv = "YES"
- buildConfiguration = "Debug">
- <Testables>
- </Testables>
- <MacroExpansion>
- <BuildableReference
- BuildableIdentifier = "primary"
- BlueprintIdentifier = "4985385C16ECFE92008D0727"
- BuildableName = "OculusWorldDemo.app"
- BlueprintName = "OculusWorldDemo"
- ReferencedContainer = "container:LibOVR_With_Samples.xcodeproj">
- </BuildableReference>
- </MacroExpansion>
- </TestAction>
- <LaunchAction
- selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
- selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
- launchStyle = "0"
- useCustomWorkingDirectory = "NO"
- buildConfiguration = "Debug"
- ignoresPersistentStateOnLaunch = "NO"
- debugDocumentVersioning = "YES"
- allowLocationSimulation = "YES">
- <BuildableProductRunnable>
- <BuildableReference
- BuildableIdentifier = "primary"
- BlueprintIdentifier = "4985385C16ECFE92008D0727"
- BuildableName = "OculusWorldDemo.app"
- BlueprintName = "OculusWorldDemo"
- ReferencedContainer = "container:LibOVR_With_Samples.xcodeproj">
- </BuildableReference>
- </BuildableProductRunnable>
- <AdditionalOptions>
- </AdditionalOptions>
- </LaunchAction>
- <ProfileAction
- shouldUseLaunchSchemeArgsEnv = "YES"
- savedToolIdentifier = ""
- useCustomWorkingDirectory = "NO"
- buildConfiguration = "Release"
- debugDocumentVersioning = "YES">
- <BuildableProductRunnable>
- <BuildableReference
- BuildableIdentifier = "primary"
- BlueprintIdentifier = "4985385C16ECFE92008D0727"
- BuildableName = "OculusWorldDemo.app"
- BlueprintName = "OculusWorldDemo"
- ReferencedContainer = "container:LibOVR_With_Samples.xcodeproj">
- </BuildableReference>
- </BuildableProductRunnable>
- </ProfileAction>
- <AnalyzeAction
- buildConfiguration = "Debug">
- </AnalyzeAction>
- <ArchiveAction
- buildConfiguration = "Release"
- revealArchiveInOrganizer = "YES">
- </ArchiveAction>
-</Scheme>
diff --git a/Samples/LibOVR_With_Samples.xcodeproj/xcshareddata/xcschemes/SensorBoxTest.xcscheme b/Samples/LibOVR_With_Samples.xcodeproj/xcshareddata/xcschemes/SensorBoxTest.xcscheme
deleted file mode 100644
index 355208d..0000000
--- a/Samples/LibOVR_With_Samples.xcodeproj/xcshareddata/xcschemes/SensorBoxTest.xcscheme
+++ /dev/null
@@ -1,86 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Scheme
- LastUpgradeVersion = "0460"
- version = "1.3">
- <BuildAction
- parallelizeBuildables = "YES"
- buildImplicitDependencies = "YES">
- <BuildActionEntries>
- <BuildActionEntry
- buildForTesting = "YES"
- buildForRunning = "YES"
- buildForProfiling = "YES"
- buildForArchiving = "YES"
- buildForAnalyzing = "YES">
- <BuildableReference
- BuildableIdentifier = "primary"
- BlueprintIdentifier = "49DB65F51726F0C30097A8DD"
- BuildableName = "SensorBoxTest.app"
- BlueprintName = "SensorBoxTest"
- ReferencedContainer = "container:LibOVR_With_Samples.xcodeproj">
- </BuildableReference>
- </BuildActionEntry>
- </BuildActionEntries>
- </BuildAction>
- <TestAction
- selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
- selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
- shouldUseLaunchSchemeArgsEnv = "YES"
- buildConfiguration = "Debug">
- <Testables>
- </Testables>
- <MacroExpansion>
- <BuildableReference
- BuildableIdentifier = "primary"
- BlueprintIdentifier = "49DB65F51726F0C30097A8DD"
- BuildableName = "SensorBoxTest.app"
- BlueprintName = "SensorBoxTest"
- ReferencedContainer = "container:LibOVR_With_Samples.xcodeproj">
- </BuildableReference>
- </MacroExpansion>
- </TestAction>
- <LaunchAction
- selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
- selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
- launchStyle = "0"
- useCustomWorkingDirectory = "NO"
- buildConfiguration = "Debug"
- ignoresPersistentStateOnLaunch = "NO"
- debugDocumentVersioning = "YES"
- allowLocationSimulation = "YES">
- <BuildableProductRunnable>
- <BuildableReference
- BuildableIdentifier = "primary"
- BlueprintIdentifier = "49DB65F51726F0C30097A8DD"
- BuildableName = "SensorBoxTest.app"
- BlueprintName = "SensorBoxTest"
- ReferencedContainer = "container:LibOVR_With_Samples.xcodeproj">
- </BuildableReference>
- </BuildableProductRunnable>
- <AdditionalOptions>
- </AdditionalOptions>
- </LaunchAction>
- <ProfileAction
- shouldUseLaunchSchemeArgsEnv = "YES"
- savedToolIdentifier = ""
- useCustomWorkingDirectory = "NO"
- buildConfiguration = "Release"
- debugDocumentVersioning = "YES">
- <BuildableProductRunnable>
- <BuildableReference
- BuildableIdentifier = "primary"
- BlueprintIdentifier = "49DB65F51726F0C30097A8DD"
- BuildableName = "SensorBoxTest.app"
- BlueprintName = "SensorBoxTest"
- ReferencedContainer = "container:LibOVR_With_Samples.xcodeproj">
- </BuildableReference>
- </BuildableProductRunnable>
- </ProfileAction>
- <AnalyzeAction
- buildConfiguration = "Debug">
- </AnalyzeAction>
- <ArchiveAction
- buildConfiguration = "Release"
- revealArchiveInOrganizer = "YES">
- </ArchiveAction>
-</Scheme>
diff --git a/Samples/LibOVR_With_Samples.xcodeproj/xcshareddata/xcschemes/ovr.xcscheme b/Samples/LibOVR_With_Samples.xcodeproj/xcshareddata/xcschemes/ovr.xcscheme
deleted file mode 100644
index d032bda..0000000
--- a/Samples/LibOVR_With_Samples.xcodeproj/xcshareddata/xcschemes/ovr.xcscheme
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Scheme
- LastUpgradeVersion = "0460"
- version = "1.3">
- <BuildAction
- parallelizeBuildables = "YES"
- buildImplicitDependencies = "YES">
- <BuildActionEntries>
- <BuildActionEntry
- buildForTesting = "YES"
- buildForRunning = "YES"
- buildForProfiling = "YES"
- buildForArchiving = "YES"
- buildForAnalyzing = "YES">
- <BuildableReference
- BuildableIdentifier = "primary"
- BlueprintIdentifier = "49A5336C16E544BE0039CB59"
- BuildableName = "libovr.a"
- BlueprintName = "ovr"
- ReferencedContainer = "container:LibOVR_With_Samples.xcodeproj">
- </BuildableReference>
- </BuildActionEntry>
- </BuildActionEntries>
- </BuildAction>
- <TestAction
- selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
- selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
- shouldUseLaunchSchemeArgsEnv = "YES"
- buildConfiguration = "Debug">
- <Testables>
- </Testables>
- </TestAction>
- <LaunchAction
- selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
- selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
- launchStyle = "0"
- useCustomWorkingDirectory = "NO"
- buildConfiguration = "Debug"
- ignoresPersistentStateOnLaunch = "NO"
- debugDocumentVersioning = "YES"
- allowLocationSimulation = "YES">
- <AdditionalOptions>
- </AdditionalOptions>
- </LaunchAction>
- <ProfileAction
- shouldUseLaunchSchemeArgsEnv = "YES"
- savedToolIdentifier = ""
- useCustomWorkingDirectory = "NO"
- buildConfiguration = "Release"
- debugDocumentVersioning = "YES">
- </ProfileAction>
- <AnalyzeAction
- buildConfiguration = "Debug">
- </AnalyzeAction>
- <ArchiveAction
- buildConfiguration = "Release"
- revealArchiveInOrganizer = "YES">
- </ArchiveAction>
-</Scheme>
diff --git a/Samples/LibOVR_With_Samples.xcodeproj/xcuserdata/Nate.xcuserdatad/xcschemes/xcschememanagement.plist b/Samples/LibOVR_With_Samples.xcodeproj/xcuserdata/Nate.xcuserdatad/xcschemes/xcschememanagement.plist
deleted file mode 100644
index 58dbb85..0000000
--- a/Samples/LibOVR_With_Samples.xcodeproj/xcuserdata/Nate.xcuserdatad/xcschemes/xcschememanagement.plist
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>SuppressBuildableAutocreation</key>
- <dict>
- <key>37973B371739D78B0093BBB8</key>
- <dict>
- <key>primary</key>
- <true/>
- </dict>
- <key>4985385C16ECFE92008D0727</key>
- <dict>
- <key>primary</key>
- <true/>
- </dict>
- <key>49A5336C16E544BE0039CB59</key>
- <dict>
- <key>primary</key>
- <true/>
- </dict>
- <key>49DB65F51726F0C30097A8DD</key>
- <dict>
- <key>primary</key>
- <true/>
- </dict>
- </dict>
-</dict>
-</plist>
diff --git a/Samples/LibOVR_With_Samples_Msvc2010.sln b/Samples/LibOVR_With_Samples_Msvc2010.sln
deleted file mode 100644
index a874b38..0000000
--- a/Samples/LibOVR_With_Samples_Msvc2010.sln
+++ /dev/null
@@ -1,67 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibOVR", "..\LibOVR\Projects\Win32\LibOVR_Msvc2010.vcxproj", "{934B40C7-F40A-4E4C-97A7-B9659BE0A441}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OculusWorldDemo", "OculusWorldDemo\OculusWorldDemo_Msvc2010.vcxproj", "{8051B877-2992-4F64-8C3B-FAF88B6D83AA}"
- ProjectSection(ProjectDependencies) = postProject
- {934B40C7-F40A-4E4C-97A7-B9659BE0A441} = {934B40C7-F40A-4E4C-97A7-B9659BE0A441}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SensorBoxTest", "SensorBox\SensorBoxTest_Msvc2010.vcxproj", "{8051B837-2982-4F64-8C3B-FAF88B6D83AB}"
- ProjectSection(ProjectDependencies) = postProject
- {934B40C7-F40A-4E4C-97A7-B9659BE0A441} = {934B40C7-F40A-4E4C-97A7-B9659BE0A441}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OculusRoomTiny", "OculusRoomTiny\OculusRoomTiny_Msvc2010.vcxproj", "{80523489-2881-4F64-8C3B-FAF88B60ABCD}"
- ProjectSection(ProjectDependencies) = postProject
- {934B40C7-F40A-4E4C-97A7-B9659BE0A441} = {934B40C7-F40A-4E4C-97A7-B9659BE0A441}
- EndProjectSection
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Debug|x64 = Debug|x64
- Release|Win32 = Release|Win32
- Release|x64 = Release|x64
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {934B40C7-F40A-4E4C-97A7-B9659BE0A441}.Debug|Win32.ActiveCfg = Debug|Win32
- {934B40C7-F40A-4E4C-97A7-B9659BE0A441}.Debug|Win32.Build.0 = Debug|Win32
- {934B40C7-F40A-4E4C-97A7-B9659BE0A441}.Debug|x64.ActiveCfg = Debug|x64
- {934B40C7-F40A-4E4C-97A7-B9659BE0A441}.Debug|x64.Build.0 = Debug|x64
- {934B40C7-F40A-4E4C-97A7-B9659BE0A441}.Release|Win32.ActiveCfg = Release|Win32
- {934B40C7-F40A-4E4C-97A7-B9659BE0A441}.Release|Win32.Build.0 = Release|Win32
- {934B40C7-F40A-4E4C-97A7-B9659BE0A441}.Release|x64.ActiveCfg = Release|x64
- {934B40C7-F40A-4E4C-97A7-B9659BE0A441}.Release|x64.Build.0 = Release|x64
- {8051B877-2992-4F64-8C3B-FAF88B6D83AA}.Debug|Win32.ActiveCfg = Debug|Win32
- {8051B877-2992-4F64-8C3B-FAF88B6D83AA}.Debug|Win32.Build.0 = Debug|Win32
- {8051B877-2992-4F64-8C3B-FAF88B6D83AA}.Debug|x64.ActiveCfg = Debug|x64
- {8051B877-2992-4F64-8C3B-FAF88B6D83AA}.Debug|x64.Build.0 = Debug|x64
- {8051B877-2992-4F64-8C3B-FAF88B6D83AA}.Release|Win32.ActiveCfg = Release|Win32
- {8051B877-2992-4F64-8C3B-FAF88B6D83AA}.Release|Win32.Build.0 = Release|Win32
- {8051B877-2992-4F64-8C3B-FAF88B6D83AA}.Release|x64.ActiveCfg = Release|x64
- {8051B837-2982-4F64-8C3B-FAF88B6D83AB}.Debug|Win32.ActiveCfg = Debug|Win32
- {8051B837-2982-4F64-8C3B-FAF88B6D83AB}.Debug|Win32.Build.0 = Debug|Win32
- {8051B837-2982-4F64-8C3B-FAF88B6D83AB}.Debug|x64.ActiveCfg = Debug|Win32
- {8051B837-2982-4F64-8C3B-FAF88B6D83AB}.Release|Win32.ActiveCfg = Release|Win32
- {8051B837-2982-4F64-8C3B-FAF88B6D83AB}.Release|Win32.Build.0 = Release|Win32
- {8051B837-2982-4F64-8C3B-FAF88B6D83AB}.Release|x64.ActiveCfg = Release|Win32
- {80523489-2881-4F64-8C3B-FAF88B60ABCD}.Debug|Win32.ActiveCfg = Debug|Win32
- {80523489-2881-4F64-8C3B-FAF88B60ABCD}.Debug|Win32.Build.0 = Debug|Win32
- {80523489-2881-4F64-8C3B-FAF88B60ABCD}.Debug|x64.ActiveCfg = Debug|x64
- {80523489-2881-4F64-8C3B-FAF88B60ABCD}.Debug|x64.Build.0 = Debug|x64
- {80523489-2881-4F64-8C3B-FAF88B60ABCD}.Release|Win32.ActiveCfg = Release|Win32
- {80523489-2881-4F64-8C3B-FAF88B60ABCD}.Release|Win32.Build.0 = Release|Win32
- {80523489-2881-4F64-8C3B-FAF88B60ABCD}.Release|x64.ActiveCfg = Release|x64
- {80523489-2881-4F64-8C3B-FAF88B60ABCD}.Release|x64.Build.0 = Release|x64
- {9ABD1D70-F80B-466F-B097-821EBAA00ED6}.Debug|Win32.ActiveCfg = Debug|Win32
- {9ABD1D70-F80B-466F-B097-821EBAA00ED6}.Debug|Win32.Build.0 = Debug|Win32
- {9ABD1D70-F80B-466F-B097-821EBAA00ED6}.Debug|x64.ActiveCfg = Debug|Win32
- {9ABD1D70-F80B-466F-B097-821EBAA00ED6}.Release|Win32.ActiveCfg = Release|Win32
- {9ABD1D70-F80B-466F-B097-821EBAA00ED6}.Release|Win32.Build.0 = Release|Win32
- {9ABD1D70-F80B-466F-B097-821EBAA00ED6}.Release|x64.ActiveCfg = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/Samples/LibOVR_With_Samples_VS2010.sln b/Samples/LibOVR_With_Samples_VS2010.sln
new file mode 100644
index 0000000..36888ff
--- /dev/null
+++ b/Samples/LibOVR_With_Samples_VS2010.sln
@@ -0,0 +1,51 @@
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibOVR", "..\LibOVR\Projects\Win32\VS2010\LibOVR.vcxproj", "{720F6C5E-6DCF-495A-B25E-10540EA081A2}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OculusRoomTiny", "OculusRoomTiny\Projects\Win\VS2010\OculusRoomTiny.vcxproj", "{6C6ECAC4-DB5C-4301-8371-9C7CC8C623C2}"
+ ProjectSection(ProjectDependencies) = postProject
+ {720F6C5E-6DCF-495A-B25E-10540EA081A2} = {720F6C5E-6DCF-495A-B25E-10540EA081A2}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OculusWorldDemo", "OculusWorldDemo\Projects\Win\VS2010\OculusWorldDemo.vcxproj", "{456DA1F5-7D65-4B77-8336-277F3921639B}"
+ ProjectSection(ProjectDependencies) = postProject
+ {720F6C5E-6DCF-495A-B25E-10540EA081A2} = {720F6C5E-6DCF-495A-B25E-10540EA081A2}
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
+ Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {720F6C5E-6DCF-495A-B25E-10540EA081A2}.Debug|Win32.ActiveCfg = Debug|Win32
+ {720F6C5E-6DCF-495A-B25E-10540EA081A2}.Debug|Win32.Build.0 = Debug|Win32
+ {720F6C5E-6DCF-495A-B25E-10540EA081A2}.Debug|x64.ActiveCfg = Debug|x64
+ {720F6C5E-6DCF-495A-B25E-10540EA081A2}.Debug|x64.Build.0 = Debug|x64
+ {720F6C5E-6DCF-495A-B25E-10540EA081A2}.Release|Win32.ActiveCfg = Release|Win32
+ {720F6C5E-6DCF-495A-B25E-10540EA081A2}.Release|Win32.Build.0 = Release|Win32
+ {720F6C5E-6DCF-495A-B25E-10540EA081A2}.Release|x64.ActiveCfg = Release|x64
+ {720F6C5E-6DCF-495A-B25E-10540EA081A2}.Release|x64.Build.0 = Release|x64
+ {6C6ECAC4-DB5C-4301-8371-9C7CC8C623C2}.Debug|Win32.ActiveCfg = Debug|Win32
+ {6C6ECAC4-DB5C-4301-8371-9C7CC8C623C2}.Debug|Win32.Build.0 = Debug|Win32
+ {6C6ECAC4-DB5C-4301-8371-9C7CC8C623C2}.Debug|x64.ActiveCfg = Debug|x64
+ {6C6ECAC4-DB5C-4301-8371-9C7CC8C623C2}.Debug|x64.Build.0 = Debug|x64
+ {6C6ECAC4-DB5C-4301-8371-9C7CC8C623C2}.Release|Win32.ActiveCfg = Release|Win32
+ {6C6ECAC4-DB5C-4301-8371-9C7CC8C623C2}.Release|Win32.Build.0 = Release|Win32
+ {6C6ECAC4-DB5C-4301-8371-9C7CC8C623C2}.Release|x64.ActiveCfg = Release|x64
+ {6C6ECAC4-DB5C-4301-8371-9C7CC8C623C2}.Release|x64.Build.0 = Release|x64
+ {456DA1F5-7D65-4B77-8336-277F3921639B}.Debug|Win32.ActiveCfg = Debug|Win32
+ {456DA1F5-7D65-4B77-8336-277F3921639B}.Debug|Win32.Build.0 = Debug|Win32
+ {456DA1F5-7D65-4B77-8336-277F3921639B}.Debug|x64.ActiveCfg = Debug|x64
+ {456DA1F5-7D65-4B77-8336-277F3921639B}.Debug|x64.Build.0 = Debug|x64
+ {456DA1F5-7D65-4B77-8336-277F3921639B}.Release|Win32.ActiveCfg = Release|Win32
+ {456DA1F5-7D65-4B77-8336-277F3921639B}.Release|Win32.Build.0 = Release|Win32
+ {456DA1F5-7D65-4B77-8336-277F3921639B}.Release|x64.ActiveCfg = Release|x64
+ {456DA1F5-7D65-4B77-8336-277F3921639B}.Release|x64.Build.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Samples/LibOVR_With_Samples_VS2012.sln b/Samples/LibOVR_With_Samples_VS2012.sln
new file mode 100644
index 0000000..cc3b3a7
--- /dev/null
+++ b/Samples/LibOVR_With_Samples_VS2012.sln
@@ -0,0 +1,63 @@
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibOVR", "..\LibOVR\Projects\Win32\VS2012\LibOVR.vcxproj", "{CCFFB3F0-DDC4-4F01-8116-A5BFC53B331C}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OculusWorldDemo", "OculusWorldDemo\Projects\Win\VS2012\OculusWorldDemo.vcxproj", "{4F8C2B89-7CF1-4763-8EEF-E969FB760E32}"
+ ProjectSection(ProjectDependencies) = postProject
+ {CCFFB3F0-DDC4-4F01-8116-A5BFC53B331C} = {CCFFB3F0-DDC4-4F01-8116-A5BFC53B331C}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OculusRoomTiny", "OculusRoomTiny\Projects\Win\VS2012\OculusRoomTiny.vcxproj", "{5736727A-FEB0-49C0-B63A-36BF0FEB4FF3}"
+ ProjectSection(ProjectDependencies) = postProject
+ {CCFFB3F0-DDC4-4F01-8116-A5BFC53B331C} = {CCFFB3F0-DDC4-4F01-8116-A5BFC53B331C}
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
+ Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {CCFFB3F0-DDC4-4F01-8116-A5BFC53B331C}.Debug|Win32.ActiveCfg = Debug|Win32
+ {CCFFB3F0-DDC4-4F01-8116-A5BFC53B331C}.Debug|Win32.Build.0 = Debug|Win32
+ {CCFFB3F0-DDC4-4F01-8116-A5BFC53B331C}.Debug|Win32.Deploy.0 = Debug|Win32
+ {CCFFB3F0-DDC4-4F01-8116-A5BFC53B331C}.Debug|x64.ActiveCfg = Debug|x64
+ {CCFFB3F0-DDC4-4F01-8116-A5BFC53B331C}.Debug|x64.Build.0 = Debug|x64
+ {CCFFB3F0-DDC4-4F01-8116-A5BFC53B331C}.Debug|x64.Deploy.0 = Debug|x64
+ {CCFFB3F0-DDC4-4F01-8116-A5BFC53B331C}.Release|Win32.ActiveCfg = Release|Win32
+ {CCFFB3F0-DDC4-4F01-8116-A5BFC53B331C}.Release|Win32.Build.0 = Release|Win32
+ {CCFFB3F0-DDC4-4F01-8116-A5BFC53B331C}.Release|Win32.Deploy.0 = Release|Win32
+ {CCFFB3F0-DDC4-4F01-8116-A5BFC53B331C}.Release|x64.ActiveCfg = Release|x64
+ {CCFFB3F0-DDC4-4F01-8116-A5BFC53B331C}.Release|x64.Build.0 = Release|x64
+ {CCFFB3F0-DDC4-4F01-8116-A5BFC53B331C}.Release|x64.Deploy.0 = Release|x64
+ {4F8C2B89-7CF1-4763-8EEF-E969FB760E32}.Debug|Win32.ActiveCfg = Debug|Win32
+ {4F8C2B89-7CF1-4763-8EEF-E969FB760E32}.Debug|Win32.Build.0 = Debug|Win32
+ {4F8C2B89-7CF1-4763-8EEF-E969FB760E32}.Debug|Win32.Deploy.0 = Debug|Win32
+ {4F8C2B89-7CF1-4763-8EEF-E969FB760E32}.Debug|x64.ActiveCfg = Debug|x64
+ {4F8C2B89-7CF1-4763-8EEF-E969FB760E32}.Debug|x64.Build.0 = Debug|x64
+ {4F8C2B89-7CF1-4763-8EEF-E969FB760E32}.Debug|x64.Deploy.0 = Debug|x64
+ {4F8C2B89-7CF1-4763-8EEF-E969FB760E32}.Release|Win32.ActiveCfg = Release|Win32
+ {4F8C2B89-7CF1-4763-8EEF-E969FB760E32}.Release|Win32.Build.0 = Release|Win32
+ {4F8C2B89-7CF1-4763-8EEF-E969FB760E32}.Release|Win32.Deploy.0 = Release|Win32
+ {4F8C2B89-7CF1-4763-8EEF-E969FB760E32}.Release|x64.ActiveCfg = Release|x64
+ {4F8C2B89-7CF1-4763-8EEF-E969FB760E32}.Release|x64.Build.0 = Release|x64
+ {4F8C2B89-7CF1-4763-8EEF-E969FB760E32}.Release|x64.Deploy.0 = Release|x64
+ {5736727A-FEB0-49C0-B63A-36BF0FEB4FF3}.Debug|Win32.ActiveCfg = Debug|Win32
+ {5736727A-FEB0-49C0-B63A-36BF0FEB4FF3}.Debug|Win32.Build.0 = Debug|Win32
+ {5736727A-FEB0-49C0-B63A-36BF0FEB4FF3}.Debug|Win32.Deploy.0 = Debug|Win32
+ {5736727A-FEB0-49C0-B63A-36BF0FEB4FF3}.Debug|x64.ActiveCfg = Debug|x64
+ {5736727A-FEB0-49C0-B63A-36BF0FEB4FF3}.Debug|x64.Build.0 = Debug|x64
+ {5736727A-FEB0-49C0-B63A-36BF0FEB4FF3}.Debug|x64.Deploy.0 = Debug|x64
+ {5736727A-FEB0-49C0-B63A-36BF0FEB4FF3}.Release|Win32.ActiveCfg = Release|Win32
+ {5736727A-FEB0-49C0-B63A-36BF0FEB4FF3}.Release|Win32.Build.0 = Release|Win32
+ {5736727A-FEB0-49C0-B63A-36BF0FEB4FF3}.Release|Win32.Deploy.0 = Release|Win32
+ {5736727A-FEB0-49C0-B63A-36BF0FEB4FF3}.Release|x64.ActiveCfg = Release|x64
+ {5736727A-FEB0-49C0-B63A-36BF0FEB4FF3}.Release|x64.Build.0 = Release|x64
+ {5736727A-FEB0-49C0-B63A-36BF0FEB4FF3}.Release|x64.Deploy.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Samples/LibOVR_With_Samples_VS2013.sln b/Samples/LibOVR_With_Samples_VS2013.sln
new file mode 100644
index 0000000..975fa48
--- /dev/null
+++ b/Samples/LibOVR_With_Samples_VS2013.sln
@@ -0,0 +1,53 @@
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.30110.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibOVR", "..\LibOVR\Projects\Win32\VS2013\LibOVR.vcxproj", "{EA50E705-5113-49E5-B105-2512EDC8DDC6}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OculusRoomTiny", "OculusRoomTiny\Projects\Win\VS2013\OculusRoomTiny.vcxproj", "{394FF596-A90B-4C95-888B-B743834ED15B}"
+ ProjectSection(ProjectDependencies) = postProject
+ {EA50E705-5113-49E5-B105-2512EDC8DDC6} = {EA50E705-5113-49E5-B105-2512EDC8DDC6}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OculusWorldDemo", "OculusWorldDemo\Projects\Win\VS2013\OculusWorldDemo.vcxproj", "{CA4E4127-1BAD-447C-BFF9-5AF940EEC376}"
+ ProjectSection(ProjectDependencies) = postProject
+ {EA50E705-5113-49E5-B105-2512EDC8DDC6} = {EA50E705-5113-49E5-B105-2512EDC8DDC6}
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
+ Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {EA50E705-5113-49E5-B105-2512EDC8DDC6}.Debug|Win32.ActiveCfg = Debug|Win32
+ {EA50E705-5113-49E5-B105-2512EDC8DDC6}.Debug|Win32.Build.0 = Debug|Win32
+ {EA50E705-5113-49E5-B105-2512EDC8DDC6}.Debug|x64.ActiveCfg = Debug|x64
+ {EA50E705-5113-49E5-B105-2512EDC8DDC6}.Debug|x64.Build.0 = Debug|x64
+ {EA50E705-5113-49E5-B105-2512EDC8DDC6}.Release|Win32.ActiveCfg = Release|Win32
+ {EA50E705-5113-49E5-B105-2512EDC8DDC6}.Release|Win32.Build.0 = Release|Win32
+ {EA50E705-5113-49E5-B105-2512EDC8DDC6}.Release|x64.ActiveCfg = Release|x64
+ {EA50E705-5113-49E5-B105-2512EDC8DDC6}.Release|x64.Build.0 = Release|x64
+ {394FF596-A90B-4C95-888B-B743834ED15B}.Debug|Win32.ActiveCfg = Debug|Win32
+ {394FF596-A90B-4C95-888B-B743834ED15B}.Debug|Win32.Build.0 = Debug|Win32
+ {394FF596-A90B-4C95-888B-B743834ED15B}.Debug|x64.ActiveCfg = Debug|x64
+ {394FF596-A90B-4C95-888B-B743834ED15B}.Debug|x64.Build.0 = Debug|x64
+ {394FF596-A90B-4C95-888B-B743834ED15B}.Release|Win32.ActiveCfg = Release|Win32
+ {394FF596-A90B-4C95-888B-B743834ED15B}.Release|Win32.Build.0 = Release|Win32
+ {394FF596-A90B-4C95-888B-B743834ED15B}.Release|x64.ActiveCfg = Release|x64
+ {394FF596-A90B-4C95-888B-B743834ED15B}.Release|x64.Build.0 = Release|x64
+ {CA4E4127-1BAD-447C-BFF9-5AF940EEC376}.Debug|Win32.ActiveCfg = Debug|Win32
+ {CA4E4127-1BAD-447C-BFF9-5AF940EEC376}.Debug|Win32.Build.0 = Debug|Win32
+ {CA4E4127-1BAD-447C-BFF9-5AF940EEC376}.Debug|x64.ActiveCfg = Debug|x64
+ {CA4E4127-1BAD-447C-BFF9-5AF940EEC376}.Debug|x64.Build.0 = Debug|x64
+ {CA4E4127-1BAD-447C-BFF9-5AF940EEC376}.Release|Win32.ActiveCfg = Release|Win32
+ {CA4E4127-1BAD-447C-BFF9-5AF940EEC376}.Release|Win32.Build.0 = Release|Win32
+ {CA4E4127-1BAD-447C-BFF9-5AF940EEC376}.Release|x64.ActiveCfg = Release|x64
+ {CA4E4127-1BAD-447C-BFF9-5AF940EEC376}.Release|x64.Build.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Samples/OculusRoomTiny/OSX_OculusRoomTiny.mm b/Samples/OculusRoomTiny/OSX_OculusRoomTiny.mm
deleted file mode 100644
index 7c5d81f..0000000
--- a/Samples/OculusRoomTiny/OSX_OculusRoomTiny.mm
+++ /dev/null
@@ -1,861 +0,0 @@
-/************************************************************************************
-
- Filename : OSX_OculusRoomTiny.mm
- Content : Simplest possible first-person view test application for Oculus Rift
- Created : May 7, 2013
- Authors : Michael Antonov, Andrew Reisse, Artem Bolgar
-
- Copyright : Copyright 2013 Oculus, Inc. All Rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- 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.
-
- *************************************************************************************/
-
-#import "OSX_OculusRoomTiny.h"
-#include "RenderTiny_GL_Device.h"
-
-#include "Kernel/OVR_KeyCodes.h"
-
-using namespace OVR;
-
-//-------------------------------------------------------------------------------------
-// ***** OculusRoomTiny Class
-
-// Static pApp simplifies routing the window function.
-OculusRoomTinyApp* OculusRoomTinyApp::pApp = 0;
-
-
-OculusRoomTinyApp::OculusRoomTinyApp(OVRApp* nsapp)
- : pRender(0),
- LastUpdate(0),
- NsApp(nsapp),
- Quit(0),
-
- // Initial location
- EyePos(0.0f, 1.6f, -5.0f),
- EyeYaw(YawInitial), EyePitch(0), EyeRoll(0),
- LastSensorYaw(0),
- SConfig(),
- PostProcess(PostProcess_Distortion),
- ShiftDown(false),
- ControlDown(false)
-{
- pApp = this;
-
- Width = 1280;
- Height = 800;
-
- StartupTicks = OVR::Timer::GetTicks();
-
- MoveForward = MoveBack = MoveLeft = MoveRight = 0;
-}
-
-OculusRoomTinyApp::~OculusRoomTinyApp()
-{
- RemoveHandlerFromDevices();
- pSensor.Clear();
- pHMD.Clear();
- destroyWindow();
- pApp = 0;
-}
-
-
-int OculusRoomTinyApp::OnStartup(const char* args)
-{
- OVR_UNUSED(args);
-
-
- // *** Oculus HMD & Sensor Initialization
-
- // Create DeviceManager and first available HMDDevice from it.
- // Sensor object is created from the HMD, to ensure that it is on the
- // correct device.
-
- pManager = *DeviceManager::Create();
-
- // We'll handle it's messages in this case.
- pManager->SetMessageHandler(this);
-
- CFOptionFlags detectionResult;
- const char* detectionMessage;
-
- do
- {
- // Release Sensor/HMD in case this is a retry.
- pSensor.Clear();
- pHMD.Clear();
- RenderParams.MonitorName.Clear();
-
- pHMD = *pManager->EnumerateDevices<HMDDevice>().CreateDevice();
- if (pHMD)
- {
- pSensor = *pHMD->GetSensor();
-
- // This will initialize HMDInfo with information about configured IPD,
- // screen size and other variables needed for correct projection.
- // We pass HMD DisplayDeviceName into the renderer to select the
- // correct monitor in full-screen mode.
- if (pHMD->GetDeviceInfo(&HMDInfo))
- {
- RenderParams.MonitorName = HMDInfo.DisplayDeviceName;
- RenderParams.DisplayId = HMDInfo.DisplayId;
- SConfig.SetHMDInfo(HMDInfo);
- }
- }
- else
- {
- // If we didn't detect an HMD, try to create the sensor directly.
- // This is useful for debugging sensor interaction; it is not needed in
- // a shipping app.
- pSensor = *pManager->EnumerateDevices<SensorDevice>().CreateDevice();
- }
-
-
- // If there was a problem detecting the Rift, display appropriate message.
- detectionResult = kCFUserNotificationAlternateResponse;
-
- if (!pHMD && !pSensor)
- detectionMessage = "Oculus Rift not detected.";
- else if (!pHMD)
- detectionMessage = "Oculus Sensor detected; HMD Display not detected.";
- else if (!pSensor)
- detectionMessage = "Oculus HMD Display detected; Sensor not detected.";
- else if (HMDInfo.DisplayDeviceName[0] == '\0')
- detectionMessage = "Oculus Sensor detected; HMD display EDID not detected.";
- else
- detectionMessage = 0;
-
- if (detectionMessage)
- {
- String messageText(detectionMessage);
- messageText += "\n\n"
- "Press 'Try Again' to run retry detection.\n"
- "Press 'Continue' to run full-screen anyway.";
-
- CFStringRef headerStrRef = CFStringCreateWithCString(NULL, "Oculus Rift Detection", kCFStringEncodingMacRoman);
- CFStringRef messageStrRef = CFStringCreateWithCString(NULL, messageText, kCFStringEncodingMacRoman);
-
- //launch the message box
- CFUserNotificationDisplayAlert(0,
- kCFUserNotificationNoteAlertLevel,
- NULL, NULL, NULL,
- headerStrRef, // header text
- messageStrRef, // message text
- CFSTR("Try again"),
- CFSTR("Continue"),
- CFSTR("Cancel"),
- &detectionResult);
-
- //Clean up the strings
- CFRelease(headerStrRef);
- CFRelease(messageStrRef);
-
- if (detectionResult == kCFUserNotificationCancelResponse ||
- detectionResult == kCFUserNotificationOtherResponse)
- return 1;
- }
-
- } while (detectionResult != kCFUserNotificationAlternateResponse);
-
-
- if (HMDInfo.HResolution > 0)
- {
- Width = HMDInfo.HResolution;
- Height = HMDInfo.VResolution;
- }
-
-
- if (!setupWindow())
- return 1;
-
- if (pSensor)
- {
- // We need to attach sensor to SensorFusion object for it to receive
- // body frame messages and update orientation. SFusion.GetOrientation()
- // is used in OnIdle() to orient the view.
- SFusion.AttachToSensor(pSensor);
- SFusion.SetDelegateMessageHandler(this);
- SFusion.SetPredictionEnabled(true);
- }
-
-
- // *** Initialize Rendering
-
- // Enable multi-sampling by default.
- RenderParams.Multisample = 4;
- RenderParams.Fullscreen = false;//true; //?
-
- // Setup Graphics.
- pRender = *OSX::RenderDevice::CreateDevice(RenderParams, (void*)View);
- if (!pRender)
- return 1;
-
-
- // *** Configure Stereo settings.
-
- SConfig.SetFullViewport(Viewport(0,0, Width, Height));
- SConfig.SetStereoMode(Stereo_LeftRight_Multipass);
-
- // Configure proper Distortion Fit.
- // For 7" screen, fit to touch left side of the view, leaving a bit of invisible
- // screen on the top (saves on rendering cost).
- // For smaller screens (5.5"), fit to the top.
- if (HMDInfo.HScreenSize > 0.0f)
- {
- if (HMDInfo.HScreenSize > 0.140f) // 7"
- SConfig.SetDistortionFitPointVP(-1.0f, 0.0f);
- else
- SConfig.SetDistortionFitPointVP(0.0f, 1.0f);
- }
-
- pRender->SetSceneRenderScale(SConfig.GetDistortionScale());
-
- SConfig.Set2DAreaFov(DegreeToRad(85.0f));
-
-
- // *** Populate Room Scene
-
- // This creates lights and models.
- PopulateRoomScene(&Scene, pRender);
-
-
- LastUpdate = GetAppTime();
- return 0;
-}
-
-void OculusRoomTinyApp::OnMessage(const Message& msg)
-{
- if (msg.Type == Message_DeviceAdded && msg.pDevice == pManager)
- {
- LogText("DeviceManager reported device added.\n");
- }
- else if (msg.Type == Message_DeviceRemoved && msg.pDevice == pManager)
- {
- LogText("DeviceManager reported device removed.\n");
- }
- else if (msg.Type == Message_DeviceAdded && msg.pDevice == pSensor)
- {
- LogText("Sensor reported device added.\n");
- }
- else if (msg.Type == Message_DeviceRemoved && msg.pDevice == pSensor)
- {
- LogText("Sensor reported device removed.\n");
- }
-}
-
-bool OculusRoomTinyApp::setupWindow()
-{
- NSRect winrect;
- winrect.origin.x = 0;
- winrect.origin.y = 1000;
- winrect.size.width = Width;
- winrect.size.height = Height;
- NSWindow* win = [[NSWindow alloc] initWithContentRect:winrect styleMask:NSTitledWindowMask|NSClosableWindowMask backing:NSBackingStoreBuffered defer:NO];
-
- OVRView* view = [[OVRView alloc] initWithFrame:winrect];
- [win setContentView:view];
- [win setAcceptsMouseMovedEvents:YES];
- [win setDelegate:view];
- [view setApp:pApp];
- Win = win;
- View = view;
-
- const char* title = "OculusRoomTiny";
- [((NSWindow*)Win) setTitle:[[NSString alloc] initWithBytes:title length:strlen(title) encoding:NSUTF8StringEncoding]];
-
- [NSCursor hide];
- [view warpMouseToCenter];
- CGAssociateMouseAndMouseCursorPosition(false);
-
- SetFullscreen(RenderParams, true);
- return true;
-}
-
-void OculusRoomTinyApp::destroyWindow()
-{
- SetFullscreen(RenderParams, false);
- [((NSWindow*)Win) close];
-}
-
-void OculusRoomTinyApp::OnMouseMove(int x, int y, int modifiers)
-{
- OVR_UNUSED(modifiers);
-
- // Mouse motion here is always relative.
- int dx = x, dy = y;
- const float maxPitch = ((3.1415f/2)*0.98f);
-
- // Apply to rotation. Subtract for right body frame rotation,
- // since yaw rotation is positive CCW when looking down on XZ plane.
- EyeYaw -= (Sensitivity * dx)/ 360.0f;
-
- if (!pSensor)
- {
- EyePitch -= (Sensitivity * dy)/ 360.0f;
-
- if (EyePitch > maxPitch)
- EyePitch = maxPitch;
- if (EyePitch < -maxPitch)
- EyePitch = -maxPitch;
- }
-}
-
-
-void OculusRoomTinyApp::OnKey(unsigned vk, bool down)
-{
- switch (vk)
- {
- case 'Q':
- if (down && ControlDown)
- Exit();;
- break;
- case Key_Escape:
- if (!down)
- Exit();
- break;
-
- // Handle player movement keys.
- // We just update movement state here, while the actual translation is done in OnIdle()
- // based on time.
- case 'W': MoveForward = down ? (MoveForward | 1) : (MoveForward & ~1); break;
- case 'S': MoveBack = down ? (MoveBack | 1) : (MoveBack & ~1); break;
- case 'A': MoveLeft = down ? (MoveLeft | 1) : (MoveLeft & ~1); break;
- case 'D': MoveRight = down ? (MoveRight | 1) : (MoveRight & ~1); break;
- case Key_Up: MoveForward = down ? (MoveForward | 2) : (MoveForward & ~2); break;
- case Key_Down: MoveBack = down ? (MoveBack | 2) : (MoveBack & ~2); break;
-
- case 'R':
- SFusion.Reset();
- break;
-
- case 'P':
- if (down)
- {
- // Toggle chromatic aberration correction on/off.
- RenderDevice::PostProcessShader shader = pRender->GetPostProcessShader();
-
- if (shader == RenderDevice::PostProcessShader_Distortion)
- {
- pRender->SetPostProcessShader(RenderDevice::PostProcessShader_DistortionAndChromAb);
- }
- else if (shader == RenderDevice::PostProcessShader_DistortionAndChromAb)
- {
- pRender->SetPostProcessShader(RenderDevice::PostProcessShader_Distortion);
- }
- else
- OVR_ASSERT(false);
- }
- break;
-
- // Switch rendering modes/distortion.
- case Key_F1:
- SConfig.SetStereoMode(Stereo_None);
- PostProcess = PostProcess_None;
- break;
- case Key_F2:
- SConfig.SetStereoMode(Stereo_LeftRight_Multipass);
- PostProcess = PostProcess_None;
- break;
- case Key_F3:
- SConfig.SetStereoMode(Stereo_LeftRight_Multipass);
- PostProcess = PostProcess_Distortion;
- break;
-
- // Stereo IPD adjustments, in meter (default IPD is 64mm).
- case '+':
- case '=':
- if (down)
- SConfig.SetIPD(SConfig.GetIPD() + 0.0005f * (ShiftDown ? 5.0f : 1.0f));
- break;
- case '-':
- case '_':
- if (down)
- SConfig.SetIPD(SConfig.GetIPD() - 0.0005f * (ShiftDown ? 5.0f : 1.0f));
- break;
-
- // Holding down Shift key accelerates adjustment velocity.
- case Key_Shift:
- ShiftDown = down;
- break;
- case Key_Meta:
- ControlDown = down;
- break;
- }
-}
-
-
-void OculusRoomTinyApp::OnIdle()
-{
- double curtime = GetAppTime();
- float dt = float(curtime - LastUpdate);
- LastUpdate = curtime;
-
-
- // Handle Sensor motion.
- // We extract Yaw, Pitch, Roll instead of directly using the orientation
- // to allow "additional" yaw manipulation with mouse/controller.
- if (pSensor)
- {
- Quatf hmdOrient = SFusion.GetOrientation();
- float yaw = 0.0f;
-
- hmdOrient.GetEulerAngles<Axis_Y, Axis_X, Axis_Z>(&yaw, &EyePitch, &EyeRoll);
-
- EyeYaw += (yaw - LastSensorYaw);
- LastSensorYaw = yaw;
- }
-
-
- if (!pSensor)
- {
- const float maxPitch = ((3.1415f/2)*0.98f);
- if (EyePitch > maxPitch)
- EyePitch = maxPitch;
- if (EyePitch < -maxPitch)
- EyePitch = -maxPitch;
- }
-
- // Handle keyboard movement.
- // This translates EyePos based on Yaw vector direction and keys pressed.
- // Note that Pitch and Roll do not affect movement (they only affect view).
- if (MoveForward || MoveBack || MoveLeft || MoveRight)
- {
- Vector3f localMoveVector(0,0,0);
- Matrix4f yawRotate = Matrix4f::RotationY(EyeYaw);
-
- if (MoveForward)
- localMoveVector = ForwardVector;
- else if (MoveBack)
- localMoveVector = -ForwardVector;
-
- if (MoveRight)
- localMoveVector += RightVector;
- else if (MoveLeft)
- localMoveVector -= RightVector;
-
- // Normalize vector so we don't move faster diagonally.
- localMoveVector.Normalize();
- Vector3f orientationVector = yawRotate.Transform(localMoveVector);
- orientationVector *= MoveSpeed * dt * (ShiftDown ? 3.0f : 1.0f);
-
- EyePos += orientationVector;
- }
-
- // Rotate and position View Camera, using YawPitchRoll in BodyFrame coordinates.
- //
- Matrix4f rollPitchYaw = Matrix4f::RotationY(EyeYaw) * Matrix4f::RotationX(EyePitch) *
- Matrix4f::RotationZ(EyeRoll);
- Vector3f up = rollPitchYaw.Transform(UpVector);
- Vector3f forward = rollPitchYaw.Transform(ForwardVector);
-
-
- // Minimal head modelling.
- float headBaseToEyeHeight = 0.15f; // Vertical height of eye from base of head
- float headBaseToEyeProtrusion = 0.09f; // Distance forward of eye from base of head
-
- Vector3f eyeCenterInHeadFrame(0.0f, headBaseToEyeHeight, -headBaseToEyeProtrusion);
- Vector3f shiftedEyePos = EyePos + rollPitchYaw.Transform(eyeCenterInHeadFrame);
- shiftedEyePos.y -= eyeCenterInHeadFrame.y; // Bring the head back down to original height
-
- ViewMat = Matrix4f::LookAtRH(shiftedEyePos, shiftedEyePos + forward, up);
-
- // This is what transformation would be without head modeling.
- // View = Matrix4f::LookAtRH(EyePos, EyePos + forward, up);
-
- switch(SConfig.GetStereoMode())
- {
- case Stereo_None:
- Render(SConfig.GetEyeRenderParams(StereoEye_Center));
- break;
-
- case Stereo_LeftRight_Multipass:
- Render(SConfig.GetEyeRenderParams(StereoEye_Left));
- Render(SConfig.GetEyeRenderParams(StereoEye_Right));
- break;
- }
-
- pRender->Present();
- // Force GPU to flush the scene, resulting in the lowest possible latency.
- pRender->ForceFlushGPU();
-}
-
-
-// Render the scene for one eye.
-void OculusRoomTinyApp::Render(const StereoEyeParams& stereo)
-{
- pRender->BeginScene(PostProcess);
-
- // Apply Viewport/Projection for the eye.
- pRender->ApplyStereoParams(stereo);
- pRender->Clear();
- pRender->SetDepthMode(true, true);
-
- Scene.Render(pRender, stereo.ViewAdjust * ViewMat);
-
- pRender->FinishScene();
-}
-
-void OculusRoomTinyApp::Exit()
-{
- [NsApp stop:nil];
- Quit = true;
-}
-
-bool OculusRoomTinyApp::SetFullscreen(const RenderTiny::RendererParams& rp, int fullscreen)
-{
- if (fullscreen == RenderTiny::Display_Window)
- [(OVRView*)View exitFullScreenModeWithOptions:nil];
- else
- {
- NSScreen* usescreen = [NSScreen mainScreen];
- NSArray* screens = [NSScreen screens];
- for (int i = 0; i < [screens count]; i++)
- {
- NSScreen* s = (NSScreen*)[screens objectAtIndex:i];
- CGDirectDisplayID disp = [OVRView displayFromScreen:s];
-
- if (disp == rp.DisplayId)
- usescreen = s;
- }
-
- [(OVRView*)View enterFullScreenMode:usescreen withOptions:nil];
- }
-
- if (pRender)
- pRender->SetFullscreen((RenderTiny::DisplayMode)fullscreen);
- return 1;
-}
-
-//-------------------------------------------------------------------------------------
-// ***** OS X-Specific Logic
-
-@implementation OVRApp
-
-- (void)dealloc
-{
- [super dealloc];
-}
-
-- (void)run
-{
- NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- _running = YES;
- OculusRoomTinyApp* app;
-
- // Initializes LibOVR. This LogMask_All enables maximum logging.
- // Custom allocator can also be specified here.
- OVR::System::Init(OVR::Log::ConfigureDefaultLog(OVR::LogMask_All));
-
- int exitCode = 0;
- do
- {
- {
- using namespace OVR;
-
- // CreateApplication must be the first call since it does OVR::System::Initialize.
- app = new OculusRoomTinyApp(self);
- // The platform attached to an app will be deleted by DestroyApplication.
-
- [self setApp:app];
-
- const char* argv[] = {"OVRApp"};
- exitCode = app->OnStartup(argv[0]);
- if (exitCode)
- break;
- }
- [self finishLaunching];
- [pool drain];
-
- while ([self isRunning])
- {
- pool = [[NSAutoreleasePool alloc] init];
- NSEvent* event = [self nextEventMatchingMask:NSAnyEventMask untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES];
- if (event)
- {
- [self sendEvent:event];
- }
- _App->OnIdle();
- [pool drain];
- }
- } while(0);
-
- delete app;
-
- // No OVR functions involving memory are allowed after this.
- OVR::System::Destroy();
-}
-
-@end
-
-static int KeyMap[][2] =
-{
- { NSDeleteFunctionKey, OVR::Key_Delete },
- { '\t', OVR::Key_Tab },
- { '\n', OVR::Key_Return },
- { NSPauseFunctionKey, OVR::Key_Pause },
- { 27, OVR::Key_Escape },
- { 127, OVR::Key_Backspace },
- { ' ', OVR::Key_Space },
- { NSPageUpFunctionKey, OVR::Key_PageUp },
- { NSPageDownFunctionKey, OVR::Key_PageDown },
- { NSNextFunctionKey, OVR::Key_PageDown },
- { NSEndFunctionKey, OVR::Key_End },
- { NSHomeFunctionKey, OVR::Key_Home },
- { NSLeftArrowFunctionKey, OVR::Key_Left },
- { NSUpArrowFunctionKey, OVR::Key_Up },
- { NSRightArrowFunctionKey, OVR::Key_Right },
- { NSDownArrowFunctionKey, OVR::Key_Down },
- { NSInsertFunctionKey, OVR::Key_Insert },
- { NSDeleteFunctionKey, OVR::Key_Delete },
- { NSHelpFunctionKey, OVR::Key_Insert },
-};
-
-
-static KeyCode MapToKeyCode(wchar_t vk)
-{
- unsigned key = Key_None;
-
- if ((vk >= 'a') && (vk <= 'z'))
- {
- key = vk - 'a' + Key_A;
- }
- else if ((vk >= ' ') && (vk <= '~'))
- {
- key = vk;
- }
- else if ((vk >= '0') && (vk <= '9'))
- {
- key = vk - '0' + Key_Num0;
- }
- else if ((vk >= NSF1FunctionKey) && (vk <= NSF15FunctionKey))
- {
- key = vk - NSF1FunctionKey + Key_F1;
- }
- else
- {
- for (unsigned i = 0; i< (sizeof(KeyMap) / sizeof(KeyMap[1])); i++)
- {
- if (vk == KeyMap[i][0])
- {
- key = KeyMap[i][1];
- break;
- }
- }
- }
-
- return (KeyCode)key;
-}
-
-@implementation OVRView
-
--(BOOL) acceptsFirstResponder
-{
- return YES;
-}
--(BOOL) acceptsFirstMouse:(NSEvent *)ev
-{
- return YES;
-}
-
-+(CGDirectDisplayID) displayFromScreen:(NSScreen *)s
-{
- NSNumber* didref = (NSNumber*)[[s deviceDescription] objectForKey:@"NSScreenNumber"];
- CGDirectDisplayID disp = (CGDirectDisplayID)[didref longValue];
- return disp;
-}
-
--(void) warpMouseToCenter
-{
- NSPoint w;
- w.x = _App->GetWidth()/2.0f;
- w.y = _App->GetHeight()/2.0f;
- w = [[self window] convertBaseToScreen:w];
- CGDirectDisplayID disp = [OVRView displayFromScreen:[[self window] screen]];
- CGPoint p = {w.x, CGDisplayPixelsHigh(disp)-w.y};
- CGDisplayMoveCursorToPoint(disp, p);
-}
-
--(void) keyDown:(NSEvent*)ev
-{
- NSString* chars = [ev charactersIgnoringModifiers];
- if ([chars length])
- {
- wchar_t ch = [chars characterAtIndex:0];
- OVR::KeyCode key = MapToKeyCode(ch);
- _App->OnKey(key, true);
- }
-}
--(void) keyUp:(NSEvent*)ev
-{
- NSString* chars = [ev charactersIgnoringModifiers];
- if ([chars length])
- {
- wchar_t ch = [chars characterAtIndex:0];
- OVR::KeyCode key = MapToKeyCode(ch);
- _App->OnKey(key, false);
-
- }
-}
-
-
--(void)flagsChanged:(NSEvent *)ev
-{
- static const OVR::KeyCode ModifierKeys[] = {OVR::Key_None, OVR::Key_Shift, OVR::Key_Control, OVR::Key_Alt, OVR::Key_Meta};
-
- unsigned long cmods = [ev modifierFlags];
- if ((cmods & 0xffff0000) != _Modifiers)
- {
- uint32_t mods = 0;
- if (cmods & NSShiftKeyMask)
- mods |= 0x01;
- if (cmods & NSControlKeyMask)
- mods |= 0x02;
- if (cmods & NSAlternateKeyMask)
- mods |= 0x04;
- if (cmods & NSCommandKeyMask)
- mods |= 0x08;
-
- for (int i = 1; i <= 4; i++)
- {
- unsigned long m = (1 << (16+i));
- if ((cmods & m) != (_Modifiers & m))
- {
- if (cmods & m)
- _App->OnKey(ModifierKeys[i], true);
- else
- _App->OnKey(ModifierKeys[i], false);
- }
- }
- _Modifiers = cmods & 0xffff0000;
- }
-}
-
--(void)ProcessMouse:(NSEvent*)ev
-{
- switch ([ev type])
- {
- case NSLeftMouseDragged:
- case NSRightMouseDragged:
- case NSOtherMouseDragged:
- case NSMouseMoved:
- {
- int dx = [ev deltaX];
- int dy = [ev deltaY];
-
- if (dx != 0 || dy != 0)
- {
- _App->OnMouseMove(dx, dy, 0);
- [self warpMouseToCenter];
- }
- }
- break;
- case NSLeftMouseDown:
- case NSRightMouseDown:
- case NSOtherMouseDown:
- break;
- }
-}
-
--(void) mouseMoved:(NSEvent*)ev
-{
- [self ProcessMouse:ev];
-}
--(void) mouseDragged:(NSEvent*)ev
-{
- [self ProcessMouse:ev];
-}
-
--(void) mouseDown:(NSEvent*)ev
-{
- [self warpMouseToCenter];
- CGAssociateMouseAndMouseCursorPosition(false);
- [NSCursor hide];
-}
-
-//-(void)
-
--(id) initWithFrame:(NSRect)frameRect
-{
- NSOpenGLPixelFormatAttribute attr[] =
- {NSOpenGLPFAWindow, NSOpenGLPFADoubleBuffer, NSOpenGLPFADepthSize, 24, nil};
-
- NSOpenGLPixelFormat *pf = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attr] autorelease];
-
- self = [super initWithFrame:frameRect pixelFormat:pf];
- GLint swap = 0;
- [[self openGLContext] setValues:&swap forParameter:NSOpenGLCPSwapInterval];
- //[self setWantsBestResolutionOpenGLSurface:YES];
- return self;
-}
-
--(BOOL)windowShouldClose:(id)sender
-{
- _App->Exit();
- return 1;
-}
-
-@end
-
-// GL OSX-specific logic
-namespace OSX {
-
- RenderDevice::RenderDevice(const RendererParams& p, void* osview, void* context)
- : GL::RenderDevice(p), Context(context)
- {
- OVRView* view = (OVRView*)osview;
- NSRect bounds = [view bounds];
- WindowWidth = bounds.size.width;
- WindowHeight= bounds.size.height;
-
- }
-
- RenderDevice* RenderDevice::CreateDevice(const RendererParams& rp, void* osview)
- {
- OVRView* view = (OVRView*)osview;
- NSOpenGLContext *context = [view openGLContext];
- if (!context)
- return NULL;
-
- [context makeCurrentContext];
- [[view window] makeKeyAndOrderFront:nil];
-
- return new OSX::RenderDevice(rp, osview, context);
- }
-
- void RenderDevice::Present()
- {
- NSOpenGLContext *context = (NSOpenGLContext*)Context;
- [context flushBuffer];
- }
-
- void RenderDevice::Shutdown()
- {
- Context = NULL;
- }
-
- bool RenderDevice::SetFullscreen(DisplayMode fullscreen)
- {
- Params.Fullscreen = fullscreen;
- return 1;
- }
-
-}
-
-
-int main(int argc, char *argv[])
-{
- NSApplication* nsapp = [OVRApp sharedApplication];
- [nsapp run];
- return 0;
-}
-
diff --git a/Samples/OculusRoomTiny/OSX_OculusRoomTiny.h b/Samples/OculusRoomTiny/OSX_OculusRoomTiny2.h
index 280fda5..ff5ad5e 100644
--- a/Samples/OculusRoomTiny/OSX_OculusRoomTiny.h
+++ b/Samples/OculusRoomTiny/OSX_OculusRoomTiny2.h
@@ -5,7 +5,7 @@
Created : May 7, 2013
Authors : Michael Antonov, Andrew Reisse, Artem Bolgar
- Copyright : Copyright 2013 Oculus, Inc. All Rights reserved.
+ Copyright : Copyright 2012 Oculus, Inc. All Rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/Samples/OculusRoomTiny/OculusRoomModel.cpp b/Samples/OculusRoomTiny/OculusRoomModel.cpp
index e12751a..f425be0 100644
--- a/Samples/OculusRoomTiny/OculusRoomModel.cpp
+++ b/Samples/OculusRoomTiny/OculusRoomModel.cpp
@@ -4,7 +4,7 @@ Filename : OculusRoomModel.cpp
Content : Creates a simple room scene from hard-coded geometry
Created : October 4, 2012
-Copyright : Copyright 2012-2013 Oculus, Inc. All Rights reserved.
+Copyright : Copyright 2012 Oculus, Inc. All Rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -20,11 +20,7 @@ limitations under the License.
*************************************************************************************/
-#include "RenderTiny_Device.h"
-
-using namespace OVR;
-using namespace OVR::RenderTiny;
-
+#include "RenderTiny_D3D11_Device.h"
//-------------------------------------------------------------------------------------
// ***** Room Model
diff --git a/Samples/OculusRoomTiny/OculusRoomTiny.rc b/Samples/OculusRoomTiny/OculusRoomTiny2.rc
index 49a6a5a..49a6a5a 100644
--- a/Samples/OculusRoomTiny/OculusRoomTiny.rc
+++ b/Samples/OculusRoomTiny/OculusRoomTiny2.rc
Binary files differ
diff --git a/Samples/OculusRoomTiny/OculusRoomTiny_Msvc2010.vcxproj.filters b/Samples/OculusRoomTiny/OculusRoomTiny_Msvc2010.vcxproj.filters
deleted file mode 100644
index 3c09bd5..0000000
--- a/Samples/OculusRoomTiny/OculusRoomTiny_Msvc2010.vcxproj.filters
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <ClCompile Include="OculusRoomModel.cpp" />
- <ClCompile Include="RenderTiny_D3D1X_Device.cpp" />
- <ClCompile Include="RenderTiny_Device.cpp" />
- <ClCompile Include="Win32_OculusRoomTiny.cpp" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="RenderTiny_Device.h" />
- <ClInclude Include="RenderTiny_D3D1X_Device.h" />
- <ClInclude Include="Win32_OculusRoomTiny.h" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="OculusRoomTiny.rc" />
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/Samples/OculusRoomTiny/OculusRoomTiny_Msvc2010.vcxproj b/Samples/OculusRoomTiny/Projects/Win/VS2010/OculusRoomTiny.vcxproj
index 4bc37a8..d6bb3e7 100644
--- a/Samples/OculusRoomTiny/OculusRoomTiny_Msvc2010.vcxproj
+++ b/Samples/OculusRoomTiny/Projects/Win/VS2010/OculusRoomTiny.vcxproj
@@ -19,7 +19,7 @@
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
- <ProjectGuid>{80523489-2881-4F64-8C3B-FAF88B60ABCD}</ProjectGuid>
+ <ProjectGuid>{6C6ECAC4-DB5C-4301-8371-9C7CC8C623C2}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>OculusRoomTiny</RootNamespace>
<ProjectName>OculusRoomTiny</ProjectName>
@@ -65,23 +65,27 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
- <IntDir>$(Configuration)\Obj\</IntDir>
- <OutDir>$(ProjectDir)$(Configuration)\</OutDir>
+ <IntDir>$(ProjectDir)../../../Obj/Win/VS2010/$(Configuration)/$(PlatformName)/</IntDir>
+ <OutDir>$(ProjectDir)../../../Bin/Win/VS2010/$(Configuration)/$(PlatformName)/</OutDir>
+ <TargetName>OculusRoomTiny</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
- <IntDir>$(Configuration)\Obj\</IntDir>
- <OutDir>$(ProjectDir)$(Configuration)\</OutDir>
+ <IntDir>$(ProjectDir)../../../Obj/Win/VS2010/$(Configuration)/$(PlatformName)/</IntDir>
+ <OutDir>$(ProjectDir)../../../Bin/Win/VS2010/$(Configuration)/$(PlatformName)/</OutDir>
+ <TargetName>OculusRoomTiny</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
- <IntDir>$(Configuration)\Obj\</IntDir>
- <OutDir>$(ProjectDir)$(Configuration)\</OutDir>
+ <IntDir>$(ProjectDir)../../../Obj/Win/VS2010/$(Configuration)/$(PlatformName)/</IntDir>
+ <OutDir>$(ProjectDir)../../../Bin/Win/VS2010/$(Configuration)/$(PlatformName)/</OutDir>
+ <TargetName>OculusRoomTiny</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
- <IntDir>$(Configuration)\Obj\</IntDir>
- <OutDir>$(ProjectDir)$(Configuration)\</OutDir>
+ <IntDir>$(ProjectDir)../../../Obj/Win/VS2010/$(Configuration)/$(PlatformName)/</IntDir>
+ <OutDir>$(ProjectDir)../../../Bin/Win/VS2010/$(Configuration)/$(PlatformName)/</OutDir>
+ <TargetName>OculusRoomTiny</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@@ -90,16 +94,17 @@
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>OVR_BUILD_DEBUG;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>../../LibOVR/Include;../../LibOVR/Src;../../3rdParty/glext;$(DXSDK_DIR)/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>../../../../../LibOVR/Include;../../../../../LibOVR/Src;$(DXSDK_DIR)/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalDependencies>libovrd.lib;dxgi.lib;d3d10.lib;d3d11.lib;d3dcompiler.lib;opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>../../LibOVR/Lib/Win32;$(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>opengl32.lib;libovrd.lib;d3dx11.lib;dxgi.lib;dxguid.lib;d3d10.lib;d3d11.lib;d3dcompiler.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>../../../../../LibOVR/Lib/$(Platform)/VS2010/;$(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@@ -109,16 +114,17 @@
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>OVR_BUILD_DEBUG;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>../../LibOVR/Include;../../LibOVR/Src;../../3rdParty/glext;$(DXSDK_DIR)/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>../../../../../LibOVR/Include;../../../../../LibOVR/Src;$(DXSDK_DIR)/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalDependencies>libovr64d.lib;dxgi.lib;d3d10.lib;d3d11.lib;d3dcompiler.lib;opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>../../LibOVR/Lib/x64;$(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>opengl32.lib;libovr64d.lib;dxgi.lib;dxguid.lib;d3d10.lib;d3d11.lib;d3dcompiler.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>../../../../../LibOVR/Lib/$(Platform)/VS2010/;$(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -130,7 +136,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>../../LibOVR/Include;../../LibOVR/Src;../../3rdParty/glext;$(DXSDK_DIR)/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>../../../../../LibOVR/Include;../../../../../LibOVR/Src;$(DXSDK_DIR)/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
@@ -140,8 +146,8 @@
<GenerateDebugInformation>false</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
- <AdditionalLibraryDirectories>../../LibOVR/Lib/Win32;$(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <AdditionalDependencies>libovr.lib;dxgi.lib;d3d10.lib;d3d11.lib;d3dcompiler.lib;opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>../../../../../LibOVR/Lib/$(Platform)/VS2010/;$(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>opengl32.lib;libovr.lib;dxguid.lib;dxgi.lib;d3dx11.lib;d3d10.lib;d3d11.lib;d3dcompiler.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -153,7 +159,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>../../LibOVR/Include;../../LibOVR/Src;../../3rdParty/glext;$(DXSDK_DIR)/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>../../../../../LibOVR/Include;../../../../../LibOVR/Src;$(DXSDK_DIR)/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
@@ -163,23 +169,19 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
- <AdditionalLibraryDirectories>../../LibOVR/Lib/x64;$(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <AdditionalDependencies>libovr64.lib;dxgi.lib;d3d10.lib;d3d11.lib;d3dcompiler.lib;opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>../../../../../LibOVR/Lib/$(Platform)/VS2010/;$(DXSDK_DIR)/Lib/x64;../../../../../3rdParty/Point Grey Research/FlyCapture2/lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>opengl32.lib;libovr64.lib;dxgi.lib;dxguid.lib;d3d10.lib;d3d11.lib;d3dcompiler.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="OculusRoomModel.cpp" />
- <ClCompile Include="RenderTiny_D3D1X_Device.cpp" />
- <ClCompile Include="RenderTiny_Device.cpp" />
- <ClCompile Include="Win32_OculusRoomTiny.cpp" />
+ <ClCompile Include="../../../Win32_DistortionMesh.cpp" />
+ <ClCompile Include="../../../OculusRoomModel.cpp" />
+ <ClCompile Include="../../../RenderTiny_D3D11_Device.cpp" />
+ <ClCompile Include="../../../Win32_OculusRoomTiny.cpp" />
+ <ClCompile Include="../../../Win32_OculusRoomTiny_Util.cpp" />
</ItemGroup>
<ItemGroup>
- <ClInclude Include="RenderTiny_D3D1X_Device.h" />
- <ClInclude Include="RenderTiny_Device.h" />
- <ClInclude Include="Win32_OculusRoomTiny.h" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="OculusRoomTiny.rc" />
+ <ClInclude Include="../../../RenderTiny_D3D11_Device.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/Samples/OculusRoomTiny/Projects/Win/VS2010/OculusRoomTiny.vcxproj.filters b/Samples/OculusRoomTiny/Projects/Win/VS2010/OculusRoomTiny.vcxproj.filters
new file mode 100644
index 0000000..8c02afc
--- /dev/null
+++ b/Samples/OculusRoomTiny/Projects/Win/VS2010/OculusRoomTiny.vcxproj.filters
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <ClCompile Include="../../../OculusRoomModel.cpp">
+ <Filter>Util</Filter>
+ </ClCompile>
+ <ClCompile Include="../../../Win32_OculusRoomTiny_Util.cpp">
+ <Filter>Util</Filter>
+ </ClCompile>
+ <ClCompile Include="../../../RenderTiny_D3D11_Device.cpp">
+ <Filter>Util</Filter>
+ </ClCompile>
+ <ClCompile Include="../../../Win32_DistortionMesh.cpp" />
+ <ClCompile Include="../../../Win32_OculusRoomTiny.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="../../../RenderTiny_D3D11_Device.h">
+ <Filter>Util</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <Filter Include="Util">
+ <UniqueIdentifier>{0750679b-ec1e-44c8-a78b-05d9e58a3588}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/Samples/OculusWorldDemo/OculusWorldDemo_Msvc2010.vcxproj b/Samples/OculusRoomTiny/Projects/Win/VS2012/OculusRoomTiny.vcxproj
index a881ab8..b547f70 100644
--- a/Samples/OculusWorldDemo/OculusWorldDemo_Msvc2010.vcxproj
+++ b/Samples/OculusRoomTiny/Projects/Win/VS2012/OculusRoomTiny.vcxproj
@@ -19,33 +19,37 @@
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
- <ProjectGuid>{8051B877-2992-4F64-8C3B-FAF88B6D83AA}</ProjectGuid>
+ <ProjectGuid>{5736727A-FEB0-49C0-B63A-36BF0FEB4FF3}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
- <RootNamespace>OculusWorldDemo</RootNamespace>
- <ProjectName>OculusWorldDemo</ProjectName>
+ <RootNamespace>OculusRoomTiny</RootNamespace>
+ <ProjectName>OculusRoomTiny</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
@@ -65,23 +69,27 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
- <IntDir>$(Configuration)\Obj\</IntDir>
- <OutDir>$(ProjectDir)$(Configuration)\</OutDir>
+ <IntDir>$(ProjectDir)../../../Obj/Win/VS2012/$(Configuration)/$(PlatformName)/</IntDir>
+ <OutDir>$(ProjectDir)../../../Bin/Win/VS2012/$(Configuration)/$(PlatformName)/</OutDir>
+ <TargetName>OculusRookTiny</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
- <IntDir>$(Configuration)\Obj\</IntDir>
- <OutDir>$(ProjectDir)$(Configuration)\</OutDir>
+ <IntDir>$(ProjectDir)../../../Obj/Win/VS2012/$(Configuration)/$(PlatformName)/</IntDir>
+ <OutDir>$(ProjectDir)../../../Bin/Win/VS2012/$(Configuration)/$(PlatformName)/</OutDir>
+ <TargetName>OculusRookTiny</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
- <IntDir>$(Configuration)\Obj\</IntDir>
- <OutDir>$(ProjectDir)$(Configuration)\</OutDir>
+ <IntDir>$(ProjectDir)../../../Obj/Win/VS2012/$(Configuration)/$(PlatformName)/</IntDir>
+ <OutDir>$(ProjectDir)../../../Bin/Win/VS2012/$(Configuration)/$(PlatformName)/</OutDir>
+ <TargetName>OculusRookTiny</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
- <IntDir>$(Configuration)\Obj\</IntDir>
- <OutDir>$(ProjectDir)$(Configuration)\</OutDir>
+ <IntDir>$(ProjectDir)../../../Obj/Win/VS2012/$(Configuration)/$(PlatformName)/</IntDir>
+ <OutDir>$(ProjectDir)../../../Bin/Win/VS2012/$(Configuration)/$(PlatformName)/</OutDir>
+ <TargetName>OculusRookTiny</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@@ -90,16 +98,17 @@
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>OVR_BUILD_DEBUG;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>../../LibOVR/Include;../../3rdParty/TinyXml;../../LibOVR/Src;../../3rdParty/glext;$(DXSDK_DIR)/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>../../../../../LibOVR/Include;../../../../../3rdParty/glext;../../../../../LibOVR/Src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalDependencies>libovrd.lib;dxgi.lib;d3d10.lib;d3d11.lib;d3dcompiler.lib;opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>../../LibOVR/Lib/Win32;$(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>opengl32.lib;libovrd.lib;dxgi.lib;dxguid.lib;d3d10.lib;d3d11.lib;d3dcompiler.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>../../../../../LibOVR/Lib/$(PlatformName)/VS2012/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@@ -109,16 +118,17 @@
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>OVR_BUILD_DEBUG;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>../../LibOVR/Include;../../LibOVR/Src;../../3rdParty/glext;$(DXSDK_DIR)/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>../../../../../LibOVR/Include;../../../../../3rdParty/glext;../../../../../LibOVR/Src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalDependencies>libovr64d.lib;dxgi.lib;d3d10.lib;d3d11.lib;d3dcompiler.lib;opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>../../LibOVR/Lib/x64;$(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>opengl32.lib;libovr64d.lib;dxgi.lib;dxguid.lib;d3d10.lib;d3d11.lib;d3dcompiler.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>../../../../../LibOVR/Lib/$(PlatformName)/VS2012/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -130,18 +140,20 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>../../LibOVR/Include;../../3rdParty/TinyXml;../../LibOVR/Src;../../3rdParty/glext;$(DXSDK_DIR)/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>../../../../../LibOVR/Include;../../../../../3rdParty/glext;../../../../../LibOVR/Src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
+ <AdditionalOptions>/d2Zi+ %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>false</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
- <AdditionalLibraryDirectories>../../LibOVR/Lib/Win32;$(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <AdditionalDependencies>libovr.lib;dxgi.lib;d3d10.lib;d3d11.lib;d3dcompiler.lib;opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>../../../../../LibOVR/Lib/$(PlatformName)/VS2012/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>opengl32.lib;libovr.lib;dxguid.lib;dxgi.lib;d3d10.lib;d3d11.lib;d3dcompiler.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -153,57 +165,31 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>../../LibOVR/Include;../../LibOVR/Src;../../3rdParty/glext;$(DXSDK_DIR)/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>../../../../../LibOVR/Include;../../../../../3rdParty/glext;../../../../../LibOVR/Src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
+ <AdditionalOptions>/d2Zi+ %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
- <AdditionalLibraryDirectories>../../LibOVR/Lib/x64;$(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <AdditionalDependencies>libovr64.lib;dxgi.lib;d3d10.lib;d3d11.lib;d3dcompiler.lib;opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>../../../../../LibOVR/Lib/$(PlatformName)/VS2012/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>opengl32.lib;libovr64.lib;dxgi.lib;dxguid.lib;d3d10.lib;d3d11.lib;d3dcompiler.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="..\CommonSrc\Platform\Platform.cpp" />
- <ClCompile Include="..\CommonSrc\Platform\Win32_Gamepad.cpp" />
- <ClCompile Include="..\CommonSrc\Platform\Win32_Platform.cpp" />
- <ClCompile Include="..\CommonSrc\Render\Render_LoadTextureDDS.cpp" />
- <ClCompile Include="..\CommonSrc\Render\Render_LoadTextureTGA.cpp" />
- <ClCompile Include="..\CommonSrc\Render\Render_Device.cpp" />
- <ClCompile Include="..\CommonSrc\Render\Render_D3D10_Device.cpp" />
- <ClCompile Include="..\CommonSrc\Render\Render_D3D11_Device.cpp" />
- <ClCompile Include="..\CommonSrc\Render\Render_D3D1X_Device.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\3rdParty\TinyXml\tinyxml2.cpp" />
- <ClCompile Include="..\CommonSrc\Render\Render_XmlSceneLoader.cpp" />
- <ClCompile Include="OculusWorldDemo.cpp" />
- <ClCompile Include="Player.cpp" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="..\CommonSrc\Platform\Gamepad.h" />
- <ClInclude Include="..\CommonSrc\Platform\Platform.h" />
- <ClInclude Include="..\CommonSrc\Platform\Platform_Default.h" />
- <ClInclude Include="..\CommonSrc\Platform\Win32_Gamepad.h" />
- <ClInclude Include="..\CommonSrc\Platform\Win32_Platform.h" />
- <ClInclude Include="..\CommonSrc\Render\Render_Font.h" />
- <ClInclude Include="..\CommonSrc\Render\Render_Device.h" />
- <ClInclude Include="..\CommonSrc\Render\Render_D3D10_Device.h" />
- <ClInclude Include="..\CommonSrc\Render\Render_D3D11_Device.h" />
- <ClInclude Include="..\CommonSrc\Render\Render_D3D1X_Device.h" />
- <ClInclude Include="..\..\3rdParty\TinyXml\tinyxml2.h" />
- <ClInclude Include="..\CommonSrc\Render\Render_XmlSceneLoader.h" />
- <ClInclude Include="Player.h" />
+ <ClCompile Include="../../../Win32_DistortionMesh.cpp" />
+ <ClCompile Include="../../../OculusRoomModel.cpp" />
+ <ClCompile Include="../../../RenderTiny_D3D11_Device.cpp" />
+ <ClCompile Include="../../../Win32_OculusRoomTiny.cpp" />
+ <ClCompile Include="../../../Win32_OculusRoomTiny_Util.cpp" />
</ItemGroup>
<ItemGroup>
- <ResourceCompile Include="OculusWorldDemo.rc" />
+ <ClInclude Include="../../../RenderTiny_D3D11_Device.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/Samples/OculusRoomTiny/Projects/Win/VS2012/OculusRoomTiny.vcxproj.filters b/Samples/OculusRoomTiny/Projects/Win/VS2012/OculusRoomTiny.vcxproj.filters
new file mode 100644
index 0000000..0847db0
--- /dev/null
+++ b/Samples/OculusRoomTiny/Projects/Win/VS2012/OculusRoomTiny.vcxproj.filters
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <ClCompile Include="../../../Win32_DistortionMesh.cpp" />
+ <ClCompile Include="../../../Win32_OculusRoomTiny.cpp" />
+ <ClCompile Include="../../../OculusRoomModel.cpp">
+ <Filter>Util</Filter>
+ </ClCompile>
+ <ClCompile Include="../../../RenderTiny_D3D11_Device.cpp">
+ <Filter>Util</Filter>
+ </ClCompile>
+ <ClCompile Include="../../../Win32_OculusRoomTiny_Util.cpp">
+ <Filter>Util</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <Filter Include="Util">
+ <UniqueIdentifier>{0750679b-ec1e-44c8-a78b-05d9e58a3588}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="../../../RenderTiny_D3D11_Device.h">
+ <Filter>Util</Filter>
+ </ClInclude>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/Samples/OculusRoomTiny/Projects/Win/VS2013/OculusRoomTiny.vcxproj b/Samples/OculusRoomTiny/Projects/Win/VS2013/OculusRoomTiny.vcxproj
new file mode 100644
index 0000000..e09a883
--- /dev/null
+++ b/Samples/OculusRoomTiny/Projects/Win/VS2013/OculusRoomTiny.vcxproj
@@ -0,0 +1,208 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{394FF596-A90B-4C95-888B-B743834ED15B}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>OculusRoomTiny</RootNamespace>
+ <ProjectName>OculusRoomTiny</ProjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(ProjectDir)../../../Obj/Win/VS2013/$(Configuration)/$(PlatformName)/</IntDir>
+ <OutDir>$(ProjectDir)../../../Bin/Win/VS2013/$(Configuration)/$(PlatformName)/</OutDir>
+ <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
+ <LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);</LibraryPath>
+ <TargetName>OculusRoomTiny</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(ProjectDir)../../../Obj/Win/VS2013/$(Configuration)/$(PlatformName)/</IntDir>
+ <OutDir>$(ProjectDir)../../../Bin/Win/VS2013/$(Configuration)/$(PlatformName)/</OutDir>
+ <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
+ <LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);</LibraryPath>
+ <TargetName>OculusRoomTiny</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(ProjectDir)../../../Obj/Win/VS2013/$(Configuration)/$(PlatformName)/</IntDir>
+ <OutDir>$(ProjectDir)../../../Bin/Win/VS2013/$(Configuration)/$(PlatformName)/</OutDir>
+ <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
+ <LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);</LibraryPath>
+ <TargetName>OculusRoomTiny</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(ProjectDir)../../../Obj/Win/VS2013/$(Configuration)/$(PlatformName)/</IntDir>
+ <OutDir>$(ProjectDir)../../../Bin/Win/VS2013/$(Configuration)/$(PlatformName)/</OutDir>
+ <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
+ <LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);</LibraryPath>
+ <TargetName>OculusRoomTiny</TargetName>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level4</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>OVR_BUILD_DEBUG;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>../../../../../LibOVR/Include;../../../../../LibOVR/Src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <DebugInformationFormat>OldStyle</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ <MinimalRebuild>false</MinimalRebuild>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalDependencies>opengl32.lib;libovrd.lib;dxgi.lib;dxguid.lib;d3d10.lib;d3d11.lib;d3dcompiler.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>../../../../../LibOVR/Lib/Win32/VS2013/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level4</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>OVR_BUILD_DEBUG;_WIN64;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>../../../../../LibOVR/Include;../../../../../LibOVR/Src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <DebugInformationFormat>OldStyle</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ <MinimalRebuild>false</MinimalRebuild>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalDependencies>opengl32.lib;libovr64d.lib;dxgi.lib;dxguid.lib;d3d10.lib;d3d11.lib;d3dcompiler.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>../../../../../LibOVR/Lib/x64/VS2013/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level4</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>../../../../../LibOVR/Include;../../../../../LibOVR/Src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ <DebugInformationFormat>OldStyle</DebugInformationFormat>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
+ <AdditionalOptions>/d2Zi+ %(AdditionalOptions)</AdditionalOptions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalLibraryDirectories>../../../../../LibOVR/Lib/Win32/VS2013/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>opengl32.lib;libovr.lib;dxguid.lib;dxgi.lib;d3d10.lib;d3d11.lib;d3dcompiler.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level4</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>_WIN64;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>../../../../../LibOVR/Include;../../../../../LibOVR/Src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ <DebugInformationFormat>OldStyle</DebugInformationFormat>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
+ <AdditionalOptions>/d2Zi+ %(AdditionalOptions)</AdditionalOptions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalLibraryDirectories>../../../../../LibOVR/Lib/x64/VS2013/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>opengl32.lib;libovr64.lib;dxguid.lib;dxgi.lib;d3d10.lib;d3d11.lib;d3dcompiler.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="../../../OculusRoomModel.cpp" />
+ <ClCompile Include="..\..\..\RenderTiny_D3D11_Device.cpp" />
+ <ClCompile Include="..\..\..\Win32_DistortionMesh.cpp" />
+ <ClCompile Include="..\..\..\Win32_OculusRoomTiny.cpp" />
+ <ClCompile Include="..\..\..\Win32_OculusRoomTiny_Util.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="../../../OculusRoomTiny2.rc" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\..\RenderTiny_D3D11_Device.h" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Samples/OculusRoomTiny/Projects/Win/VS2013/OculusRoomTiny.vcxproj.filters b/Samples/OculusRoomTiny/Projects/Win/VS2013/OculusRoomTiny.vcxproj.filters
new file mode 100644
index 0000000..6df3291
--- /dev/null
+++ b/Samples/OculusRoomTiny/Projects/Win/VS2013/OculusRoomTiny.vcxproj.filters
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <ClCompile Include="..\..\..\Win32_DistortionMesh.cpp" />
+ <ClCompile Include="..\..\..\Win32_OculusRoomTiny.cpp" />
+ <ClCompile Include="../../../OculusRoomModel.cpp">
+ <Filter>Util</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\RenderTiny_D3D11_Device.cpp">
+ <Filter>Util</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\Win32_OculusRoomTiny_Util.cpp">
+ <Filter>Util</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="../../../OculusRoomTiny2.rc" />
+ </ItemGroup>
+ <ItemGroup>
+ <Filter Include="Util">
+ <UniqueIdentifier>{aa2ef577-a403-4088-a39c-0a87a96151a9}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\..\RenderTiny_D3D11_Device.h">
+ <Filter>Util</Filter>
+ </ClInclude>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/Samples/OculusRoomTiny/RenderTiny_D3D1X_Device.cpp b/Samples/OculusRoomTiny/RenderTiny_D3D11_Device.cpp
index a1a567a..964c81c 100644
--- a/Samples/OculusRoomTiny/RenderTiny_D3D1X_Device.cpp
+++ b/Samples/OculusRoomTiny/RenderTiny_D3D11_Device.cpp
@@ -1,6 +1,6 @@
/************************************************************************************
-Filename : RenderTiny_D3D1x.cpp
+Filename : RenderTiny_D3D11.cpp
Content : RenderDevice implementation for D3DX10/11.
Created : September 10, 2012
Authors : Andrew Reisse
@@ -21,24 +21,24 @@ limitations under the License.
************************************************************************************/
+#include "RenderTiny_D3D11_Device.h"
#include "Kernel/OVR_Log.h"
-#include "Kernel/OVR_Std.h"
+#include <d3dcompiler.h>
+
-#include "RenderTiny_D3D1X_Device.h"
-#include <d3dcompiler.h>
-namespace OVR { namespace RenderTiny { namespace D3D10 {
+namespace OVR { namespace RenderTiny {
//-------------------------------------------------------------------------------------
// Vertex format
-static D3D1x_(INPUT_ELEMENT_DESC) ModelVertexDesc[] =
+static D3D11_INPUT_ELEMENT_DESC ModelVertexDesc[] =
{
- {"Position", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, offsetof(Vertex, Pos), D3D1x_(INPUT_PER_VERTEX_DATA), 0},
- {"Color", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, offsetof(Vertex, C), D3D1x_(INPUT_PER_VERTEX_DATA), 0},
- {"TexCoord", 0, DXGI_FORMAT_R32G32_FLOAT, 0, offsetof(Vertex, U), D3D1x_(INPUT_PER_VERTEX_DATA), 0},
- {"Normal", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, offsetof(Vertex, Norm), D3D1x_(INPUT_PER_VERTEX_DATA), 0},
+ {"Position", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, offsetof(Vertex, Pos), D3D11_INPUT_PER_VERTEX_DATA, 0},
+ {"Color", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, offsetof(Vertex, C), D3D11_INPUT_PER_VERTEX_DATA, 0},
+ {"TexCoord", 0, DXGI_FORMAT_R32G32_FLOAT, 0, offsetof(Vertex, U), D3D11_INPUT_PER_VERTEX_DATA, 0},
+ {"Normal", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, offsetof(Vertex, Norm), D3D11_INPUT_PER_VERTEX_DATA, 0},
};
// These shaders are used to render the world, including lit vertex-colored and textured geometry.
@@ -124,6 +124,7 @@ static const char* TexturePixelShaderSrc =
"}\n";
+
#define LIGHTING_COMMON \
"cbuffer Lighting : register(b1)\n" \
"{\n" \
@@ -171,122 +172,25 @@ static const char* LitTexturePixelShaderSrc =
"}\n";
-//-------------------------------------------------------------------------------------
-// ***** Distortion Post-process Shaders
-
-static const char* PostProcessVertexShaderSrc =
- "float4x4 View : register(c4);\n"
- "float4x4 Texm : register(c8);\n"
- "void main(in float4 Position : POSITION, in float4 Color : COLOR0, in float2 TexCoord : TEXCOORD0,\n"
- " out float4 oPosition : SV_Position, out float4 oColor : COLOR, out float2 oTexCoord : TEXCOORD0)\n"
- "{\n"
- " oPosition = mul(View, Position);\n"
- " oTexCoord = mul(Texm, float4(TexCoord,0,1));\n"
- " oColor = Color;\n"
- "}\n";
-
-// Shader with just lens distortion correction.
-static const char* PostProcessPixelShaderSrc =
- "Texture2D Texture : register(t0);\n"
- "SamplerState Linear : register(s0);\n"
- "float2 LensCenter;\n"
- "float2 ScreenCenter;\n"
- "float2 Scale;\n"
- "float2 ScaleIn;\n"
- "float4 HmdWarpParam;\n"
- "\n"
-
- // Scales input texture coordinates for distortion.
- // ScaleIn maps texture coordinates to Scales to ([-1, 1]), although top/bottom will be
- // larger due to aspect ratio.
- "float2 HmdWarp(float2 in01)\n"
- "{\n"
- " float2 theta = (in01 - LensCenter) * ScaleIn;\n" // Scales to [-1, 1]
- " float rSq = theta.x * theta.x + theta.y * theta.y;\n"
- " float2 theta1 = theta * (HmdWarpParam.x + HmdWarpParam.y * rSq + "
- " HmdWarpParam.z * rSq * rSq + HmdWarpParam.w * rSq * rSq * rSq);\n"
- " return LensCenter + Scale * theta1;\n"
- "}\n"
-
- "float4 main(in float4 oPosition : SV_Position, in float4 oColor : COLOR,\n"
- " in float2 oTexCoord : TEXCOORD0) : SV_Target\n"
- "{\n"
- " float2 tc = HmdWarp(oTexCoord);\n"
- " if (any(clamp(tc, ScreenCenter-float2(0.25,0.5), ScreenCenter+float2(0.25, 0.5)) - tc))\n"
- " return 0;\n"
- " return Texture.Sample(Linear, tc);\n"
- "}\n";
-
-// Shader with lens distortion and chromatic aberration correction.
-static const char* PostProcessPixelShaderWithChromAbSrc =
- "Texture2D Texture : register(t0);\n"
- "SamplerState Linear : register(s0);\n"
- "float2 LensCenter;\n"
- "float2 ScreenCenter;\n"
- "float2 Scale;\n"
- "float2 ScaleIn;\n"
- "float4 HmdWarpParam;\n"
- "float4 ChromAbParam;\n"
- "\n"
-
- // Scales input texture coordinates for distortion.
- // ScaleIn maps texture coordinates to Scales to ([-1, 1]), although top/bottom will be
- // larger due to aspect ratio.
- "float4 main(in float4 oPosition : SV_Position, in float4 oColor : COLOR,\n"
- " in float2 oTexCoord : TEXCOORD0) : SV_Target\n"
- "{\n"
- " float2 theta = (oTexCoord - LensCenter) * ScaleIn;\n" // Scales to [-1, 1]
- " float rSq= theta.x * theta.x + theta.y * theta.y;\n"
- " float2 theta1 = theta * (HmdWarpParam.x + HmdWarpParam.y * rSq + "
- " HmdWarpParam.z * rSq * rSq + HmdWarpParam.w * rSq * rSq * rSq);\n"
- " \n"
- " // Detect whether blue texture coordinates are out of range since these will scaled out the furthest.\n"
- " float2 thetaBlue = theta1 * (ChromAbParam.z + ChromAbParam.w * rSq);\n"
- " float2 tcBlue = LensCenter + Scale * thetaBlue;\n"
- " if (any(clamp(tcBlue, ScreenCenter-float2(0.25,0.5), ScreenCenter+float2(0.25, 0.5)) - tcBlue))\n"
- " return 0;\n"
- " \n"
- " // Now do blue texture lookup.\n"
- " float blue = Texture.Sample(Linear, tcBlue).b;\n"
- " \n"
- " // Do green lookup (no scaling).\n"
- " float2 tcGreen = LensCenter + Scale * theta1;\n"
- " float green = Texture.Sample(Linear, tcGreen).g;\n"
- " \n"
- " // Do red scale and lookup.\n"
- " float2 thetaRed = theta1 * (ChromAbParam.x + ChromAbParam.y * rSq);\n"
- " float2 tcRed = LensCenter + Scale * thetaRed;\n"
- " float red = Texture.Sample(Linear, tcRed).r;\n"
- " \n"
- " return float4(red, green, blue, 1);\n"
- "}\n";
-
-
static const char* VShaderSrcs[VShader_Count] =
{
DirectVertexShaderSrc,
- StdVertexShaderSrc,
- PostProcessVertexShaderSrc
+ StdVertexShaderSrc
+
};
static const char* FShaderSrcs[FShader_Count] =
{
SolidPixelShaderSrc,
GouraudPixelShaderSrc,
TexturePixelShaderSrc,
- PostProcessPixelShaderSrc,
- PostProcessPixelShaderWithChromAbSrc,
LitSolidPixelShaderSrc,
- LitTexturePixelShaderSrc
+ LitTexturePixelShaderSrc
};
//-------------------------------------------------------------------------------------
// ***** Buffer
-Buffer::~Buffer()
-{
-}
-
bool Buffer::Data(int use, const void *buffer, size_t size)
{
if (D3DBuffer && Size >= size)
@@ -318,33 +222,33 @@ bool Buffer::Data(int use, const void *buffer, size_t size)
Dynamic = 0;
}
- D3D1x_(BUFFER_DESC) desc;
+ D3D11_BUFFER_DESC desc;
memset(&desc, 0, sizeof(desc));
if (use & Buffer_ReadOnly)
{
- desc.Usage = D3D1x_(USAGE_IMMUTABLE);
+ desc.Usage = D3D11_USAGE_IMMUTABLE;
desc.CPUAccessFlags = 0;
}
else
{
- desc.Usage = D3D1x_(USAGE_DYNAMIC);
- desc.CPUAccessFlags = D3D1x_(CPU_ACCESS_WRITE);
+ desc.Usage = D3D11_USAGE_DYNAMIC;
+ desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
Dynamic = 1;
}
switch(use & Buffer_TypeMask)
{
- case Buffer_Vertex: desc.BindFlags = D3D1x_(BIND_VERTEX_BUFFER); break;
- case Buffer_Index: desc.BindFlags = D3D1x_(BIND_INDEX_BUFFER); break;
+ case Buffer_Vertex: desc.BindFlags = D3D11_BIND_VERTEX_BUFFER; break;
+ case Buffer_Index: desc.BindFlags = D3D11_BIND_INDEX_BUFFER; break;
case Buffer_Uniform:
- desc.BindFlags = D3D1x_(BIND_CONSTANT_BUFFER);
+ desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
size += ((size + 15) & ~15) - size;
break;
}
desc.ByteWidth = (unsigned)size;
- D3D1x_(SUBRESOURCE_DATA) sr;
+ D3D11_SUBRESOURCE_DATA sr;
sr.pSysMem = buffer;
sr.SysMemPitch = 0;
sr.SysMemSlicePitch = 0;
@@ -361,55 +265,56 @@ bool Buffer::Data(int use, const void *buffer, size_t size)
void* Buffer::Map(size_t start, size_t size, int flags)
{
- OVR_UNUSED(size);
-
- D3D1x_(MAP) mapFlags = D3D1x_(MAP_WRITE);
- if (flags & Map_Discard)
- mapFlags = D3D1x_(MAP_WRITE_DISCARD);
- if (flags & Map_Unsynchronized)
- mapFlags = D3D1x_(MAP_WRITE_NO_OVERWRITE);
-
- void* map = 0;
- if (SUCCEEDED(D3DBuffer->Map(mapFlags, 0, &map)))
- return ((char*)map) + start;
- return NULL;
+ OVR_UNUSED(size);
+
+ D3D11_MAP mapFlags = D3D11_MAP_WRITE;
+ if (flags & Map_Discard)
+ mapFlags = D3D11_MAP_WRITE_DISCARD;
+ if (flags & Map_Unsynchronized)
+ mapFlags = D3D11_MAP_WRITE_NO_OVERWRITE;
+
+ D3D11_MAPPED_SUBRESOURCE map;
+ if (SUCCEEDED(Ren->Context->Map(D3DBuffer, 0, mapFlags, 0, &map)))
+ return ((char*)map.pData) + start;
+ else
+ return NULL;
}
bool Buffer::Unmap(void *m)
{
- OVR_UNUSED(m);
+ OVR_UNUSED(m);
- D3DBuffer->Unmap();
- return true;
+ Ren->Context->Unmap(D3DBuffer, 0);
+ return true;
}
//-------------------------------------------------------------------------------------
// Shaders
-template<> bool Shader<RenderTiny::Shader_Vertex, ID3D10VertexShader>::Load(void* shader, size_t size)
+template<> bool Shader<Shader_Vertex, ID3D11VertexShader>::Load(void* shader, size_t size)
{
- return SUCCEEDED(Ren->Device->CreateVertexShader(shader, size, &D3DShader));
+ return SUCCEEDED(Ren->Device->CreateVertexShader(shader, size, NULL, &D3DShader));
}
-template<> bool Shader<RenderTiny::Shader_Pixel, ID3D10PixelShader>::Load(void* shader, size_t size)
+template<> bool Shader<Shader_Pixel, ID3D11PixelShader>::Load(void* shader, size_t size)
{
- return SUCCEEDED(Ren->Device->CreatePixelShader(shader, size, &D3DShader));
+ return SUCCEEDED(Ren->Device->CreatePixelShader(shader, size, NULL, &D3DShader));
}
-template<> void Shader<RenderTiny::Shader_Vertex, ID3D10VertexShader>::Set(PrimitiveType) const
+template<> void Shader<Shader_Vertex, ID3D11VertexShader>::Set(PrimitiveType) const
{
- Ren->Context->VSSetShader(D3DShader);
+ Ren->Context->VSSetShader(D3DShader, NULL, 0);
}
-template<> void Shader<RenderTiny::Shader_Pixel, ID3D10PixelShader>::Set(PrimitiveType) const
+template<> void Shader<Shader_Pixel, ID3D11PixelShader>::Set(PrimitiveType) const
{
- Ren->Context->PSSetShader(D3DShader);
+ Ren->Context->PSSetShader(D3DShader, NULL, 0);
}
-template<> void Shader<RenderTiny::Shader_Vertex, ID3D1xVertexShader>::SetUniformBuffer(RenderTiny::Buffer* buffer, int i)
+template<> void Shader<Shader_Vertex, ID3D11VertexShader>::SetUniformBuffer(Buffer* buffer, int i)
{
Ren->Context->VSSetConstantBuffers(i, 1, &((Buffer*)buffer)->D3DBuffer.GetRawRef());
}
-template<> void Shader<RenderTiny::Shader_Pixel, ID3D1xPixelShader>::SetUniformBuffer(RenderTiny::Buffer* buffer, int i)
+template<> void Shader<Shader_Pixel, ID3D11PixelShader>::SetUniformBuffer(Buffer* buffer, int i)
{
Ren->Context->PSSetConstantBuffers(i, 1, &((Buffer*)buffer)->D3DBuffer.GetRawRef());
}
@@ -419,9 +324,10 @@ template<> void Shader<RenderTiny::Shader_Pixel, ID3D1xPixelShader>::SetUniformB
// ***** Shader Base
ShaderBase::ShaderBase(RenderDevice* r, ShaderStage stage)
- : RenderTiny::Shader(stage), Ren(r), UniformData(0)
+ : Stage(stage), Ren(r), UniformData(0)
{
}
+
ShaderBase::~ShaderBase()
{
if (UniformData)
@@ -441,12 +347,32 @@ bool ShaderBase::SetUniform(const char* name, int n, const float* v)
return 0;
}
+bool ShaderBase::SetUniformBool(const char* name, int n, const bool* v)
+{
+ OVR_UNUSED(n);
+
+ for(unsigned i = 0; i < UniformInfo.GetSize(); i++)
+ {
+ if (!strcmp(UniformInfo[i].Name.ToCStr(), name))
+ {
+ memcpy(UniformData + UniformInfo[i].Offset, v, UniformInfo[i].Size);
+ return 1;
+ }
+ }
+ return 0;
+}
+
void ShaderBase::InitUniforms(ID3D10Blob* s)
{
- ID3D10ShaderReflection* ref = NULL;
- D3D10ReflectShader(s->GetBufferPointer(), s->GetBufferSize(), &ref);
- ID3D10ShaderReflectionConstantBuffer* buf = ref->GetConstantBufferByIndex(0);
- D3D10_SHADER_BUFFER_DESC bufd;
+ InitUniforms(s->GetBufferPointer(), s->GetBufferSize());
+}
+
+void ShaderBase::InitUniforms(void* s, size_t size)
+{
+ ID3D11ShaderReflection* ref = NULL;
+ D3DReflect(s, size, IID_ID3D11ShaderReflection, (void**) &ref);
+ ID3D11ShaderReflectionConstantBuffer* buf = ref->GetConstantBufferByIndex(0);
+ D3D11_SHADER_BUFFER_DESC bufd;
if (FAILED(buf->GetDesc(&bufd)))
{
UniformsSize = 0;
@@ -460,10 +386,10 @@ void ShaderBase::InitUniforms(ID3D10Blob* s)
for(unsigned i = 0; i < bufd.Variables; i++)
{
- ID3D10ShaderReflectionVariable* var = buf->GetVariableByIndex(i);
+ ID3D11ShaderReflectionVariable* var = buf->GetVariableByIndex(i);
if (var)
{
- D3D10_SHADER_VARIABLE_DESC vd;
+ D3D11_SHADER_VARIABLE_DESC vd;
if (SUCCEEDED(var->GetDesc(&vd)))
{
Uniform u;
@@ -488,6 +414,12 @@ void ShaderBase::UpdateBuffer(Buffer* buf)
}
+
+
+
+
+
+
//-------------------------------------------------------------------------------------
// ***** Texture
//
@@ -502,7 +434,7 @@ Texture::~Texture()
{
}
-void Texture::Set(int slot, RenderTiny::ShaderStage stage) const
+void Texture::Set(int slot, ShaderStage stage) const
{
Ren->SetTexture(stage, slot, this);
}
@@ -513,6 +445,155 @@ void Texture::SetSampleMode(int sm)
}
+void Model::Render(const Matrix4f& ltw, RenderDevice* ren)
+{
+ if (Visible)
+ {
+ Matrix4f m = ltw * GetMatrix();
+ ren->Render(m, this);
+ }
+}
+
+void Container::Render(const Matrix4f& ltw, RenderDevice* ren)
+{
+ Matrix4f m = ltw * GetMatrix();
+ for(unsigned i = 0; i < Nodes.GetSize(); i++)
+ {
+ Nodes[i]->Render(m, ren);
+ }
+}
+
+void Scene::Render(RenderDevice* ren, const Matrix4f& view)
+{
+ Lighting.Update(view, LightPos);
+
+ ren->SetLighting(&Lighting);
+
+ World.Render(view, ren);
+}
+
+
+
+UInt16 CubeIndices[] =
+{
+ 0, 1, 3,
+ 3, 1, 2,
+
+ 5, 4, 6,
+ 6, 4, 7,
+
+ 8, 9, 11,
+ 11, 9, 10,
+
+ 13, 12, 14,
+ 14, 12, 15,
+
+ 16, 17, 19,
+ 19, 17, 18,
+
+ 21, 20, 22,
+ 22, 20, 23
+};
+
+
+void Model::AddSolidColorBox(float x1, float y1, float z1,
+ float x2, float y2, float z2,
+ Color c)
+{
+ float t;
+
+ if(x1 > x2)
+ {
+ t = x1;
+ x1 = x2;
+ x2 = t;
+ }
+ if(y1 > y2)
+ {
+ t = y1;
+ y1 = y2;
+ y2 = t;
+ }
+ if(z1 > z2)
+ {
+ t = z1;
+ z1 = z2;
+ z2 = t;
+ }
+
+ // Cube vertices and their normals.
+ Vector3f CubeVertices[][3] =
+ {
+ Vector3f(x1, y2, z1), Vector3f(z1, x1), Vector3f(0.0f, 1.0f, 0.0f),
+ Vector3f(x2, y2, z1), Vector3f(z1, x2), Vector3f(0.0f, 1.0f, 0.0f),
+ Vector3f(x2, y2, z2), Vector3f(z2, x2), Vector3f(0.0f, 1.0f, 0.0f),
+ Vector3f(x1, y2, z2), Vector3f(z2, x1), Vector3f(0.0f, 1.0f, 0.0f),
+
+ Vector3f(x1, y1, z1), Vector3f(z1, x1), Vector3f(0.0f, -1.0f, 0.0f),
+ Vector3f(x2, y1, z1), Vector3f(z1, x2), Vector3f(0.0f, -1.0f, 0.0f),
+ Vector3f(x2, y1, z2), Vector3f(z2, x2), Vector3f(0.0f, -1.0f, 0.0f),
+ Vector3f(x1, y1, z2), Vector3f(z2, x1), Vector3f(0.0f, -1.0f, 0.0f),
+
+ Vector3f(x1, y1, z2), Vector3f(z2, y1), Vector3f(-1.0f, 0.0f, 0.0f),
+ Vector3f(x1, y1, z1), Vector3f(z1, y1), Vector3f(-1.0f, 0.0f, 0.0f),
+ Vector3f(x1, y2, z1), Vector3f(z1, y2), Vector3f(-1.0f, 0.0f, 0.0f),
+ Vector3f(x1, y2, z2), Vector3f(z2, y2), Vector3f(-1.0f, 0.0f, 0.0f),
+
+ Vector3f(x2, y1, z2), Vector3f(z2, y1), Vector3f(1.0f, 0.0f, 0.0f),
+ Vector3f(x2, y1, z1), Vector3f(z1, y1), Vector3f(1.0f, 0.0f, 0.0f),
+ Vector3f(x2, y2, z1), Vector3f(z1, y2), Vector3f(1.0f, 0.0f, 0.0f),
+ Vector3f(x2, y2, z2), Vector3f(z2, y2), Vector3f(1.0f, 0.0f, 0.0f),
+
+ Vector3f(x1, y1, z1), Vector3f(x1, y1), Vector3f(0.0f, 0.0f, -1.0f),
+ Vector3f(x2, y1, z1), Vector3f(x2, y1), Vector3f(0.0f, 0.0f, -1.0f),
+ Vector3f(x2, y2, z1), Vector3f(x2, y2), Vector3f(0.0f, 0.0f, -1.0f),
+ Vector3f(x1, y2, z1), Vector3f(x1, y2), Vector3f(0.0f, 0.0f, -1.0f),
+
+ Vector3f(x1, y1, z2), Vector3f(x1, y1), Vector3f(0.0f, 0.0f, 1.0f),
+ Vector3f(x2, y1, z2), Vector3f(x2, y1), Vector3f(0.0f, 0.0f, 1.0f),
+ Vector3f(x2, y2, z2), Vector3f(x2, y2), Vector3f(0.0f, 0.0f, 1.0f),
+ Vector3f(x1, y2, z2), Vector3f(x1, y2), Vector3f(0.0f, 0.0f, 1.0f)
+ };
+
+
+ UInt16 startIndex = GetNextVertexIndex();
+
+ enum
+ {
+ CubeVertexCount = sizeof(CubeVertices) / sizeof(CubeVertices[0]),
+ CubeIndexCount = sizeof(CubeIndices) / sizeof(CubeIndices[0])
+ };
+
+ for(int v = 0; v < CubeVertexCount; v++)
+ {
+ AddVertex(Vertex(CubeVertices[v][0], c, CubeVertices[v][1].x, CubeVertices[v][1].y, CubeVertices[v][2]));
+ }
+
+ // Renumber indices
+ for(int i = 0; i < CubeIndexCount / 3; i++)
+ {
+ AddTriangle(CubeIndices[i * 3] + startIndex,
+ CubeIndices[i * 3 + 1] + startIndex,
+ CubeIndices[i * 3 + 2] + startIndex);
+ }
+}
+
+
+//-------------------------------------------------------------------------------------
+
+
+void ShaderFill::Set(PrimitiveType prim) const
+{
+ Shaders->Set(prim);
+ for(int i = 0; i < 8; i++)
+ {
+ if(Textures[i])
+ {
+ Textures[i]->Set(i);
+ }
+ }
+}
+
//-------------------------------------------------------------------------------------
// ***** Render Device
@@ -560,11 +641,11 @@ RenderDevice::RenderDevice(const RendererParams& p, HWND window)
}
int flags = 0;
+ //int flags = D3D11_CREATE_DEVICE_DEBUG;
- hr = D3D10CreateDevice(Adapter, D3D10_DRIVER_TYPE_HARDWARE, NULL, flags, D3D1x_(SDK_VERSION),
- &Device.GetRawRef());
- Context = Device;
- Context->AddRef();
+ hr = D3D11CreateDevice(Adapter, Adapter ? D3D_DRIVER_TYPE_UNKNOWN : D3D_DRIVER_TYPE_HARDWARE,
+ NULL, flags, NULL, 0, D3D11_SDK_VERSION,
+ &Device.GetRawRef(), NULL, &Context.GetRawRef());
if (FAILED(hr))
return;
@@ -575,6 +656,28 @@ RenderDevice::RenderDevice(const RendererParams& p, HWND window)
if (Params.Fullscreen)
SwapChain->SetFullscreenState(1, FullscreenOutput);
+ initShadersAndStates();
+}
+
+
+RenderDevice::RenderDevice(const SlaveRendererParams& p)
+{
+ WindowWidth = p.RTSize.w;
+ WindowHeight = p.RTSize.h;
+ Params.Multisample = p.Multisample;
+ Window = 0;
+
+ Context = p.pDeviceContext;
+ Device = p.pDevice; // IN D3D11 this is different
+
+ BackBufferRT = p.pBackBufferRT;
+
+ initShadersAndStates();
+}
+
+// Constructor helper
+void RenderDevice::initShadersAndStates()
+{
CurRenderTarget = NULL;
for(int i = 0; i < Shader_Count; i++)
{
@@ -596,10 +699,10 @@ RenderDevice::RenderDevice(const RendererParams& p, HWND window)
SPInt bufferSize = vsData->GetBufferSize();
const void* buffer = vsData->GetBufferPointer();
- ID3D1xInputLayout** objRef = &ModelVertexIL.GetRawRef();
+ ID3D11InputLayout** objRef = &ModelVertexIL.GetRawRef();
- HRESULT validate = Device->CreateInputLayout(ModelVertexDesc, sizeof(ModelVertexDesc)/sizeof(D3D1x_(INPUT_ELEMENT_DESC)),
- buffer, bufferSize, objRef);
+ HRESULT validate = Device->CreateInputLayout(ModelVertexDesc, sizeof(ModelVertexDesc)/sizeof(D3D11_INPUT_ELEMENT_DESC),
+ buffer, bufferSize, objRef);
OVR_UNUSED(validate);
Ptr<ShaderSet> gouraudShaders = *new ShaderSet();
@@ -607,32 +710,57 @@ RenderDevice::RenderDevice(const RendererParams& p, HWND window)
gouraudShaders->SetShader(PixelShaders[FShader_Gouraud]);
DefaultFill = *new ShaderFill(gouraudShaders);
- D3D1x_(BLEND_DESC) bm;
+ D3D11_BLEND_DESC bm;
memset(&bm, 0, sizeof(bm));
- bm.BlendEnable[0] = true;
- bm.BlendOp = bm.BlendOpAlpha = D3D1x_(BLEND_OP_ADD);
- bm.SrcBlend = bm.SrcBlendAlpha = D3D1x_(BLEND_SRC_ALPHA);
- bm.DestBlend = bm.DestBlendAlpha = D3D1x_(BLEND_INV_SRC_ALPHA);
- bm.RenderTargetWriteMask[0] = D3D1x_(COLOR_WRITE_ENABLE_ALL);
+ bm.RenderTarget[0].BlendEnable = true;
+ bm.RenderTarget[0].BlendOp = bm.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
+ bm.RenderTarget[0].SrcBlend = bm.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_SRC_ALPHA;
+ bm.RenderTarget[0].DestBlend = bm.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA;
+ bm.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
Device->CreateBlendState(&bm, &BlendState.GetRawRef());
- D3D1x_(RASTERIZER_DESC) rs;
+ D3D11_RASTERIZER_DESC rs;
memset(&rs, 0, sizeof(rs));
rs.AntialiasedLineEnable = true;
- rs.CullMode = D3D1x_(CULL_BACK);
+ rs.CullMode = D3D11_CULL_BACK;
rs.DepthClipEnable = true;
- rs.FillMode = D3D1x_(FILL_SOLID);
+ rs.FillMode = D3D11_FILL_SOLID;
Device->CreateRasterizerState(&rs, &Rasterizer.GetRawRef());
QuadVertexBuffer = *CreateBuffer();
- const RenderTiny::Vertex QuadVertices[] =
+ const Vertex QuadVertices[] =
{ Vertex(Vector3f(0, 1, 0)), Vertex(Vector3f(1, 1, 0)),
- Vertex(Vector3f(0, 0, 0)), Vertex(Vector3f(1, 0, 0)) };
+ Vertex(Vector3f(0, 0, 0)), Vertex(Vector3f(1, 0, 0)) };
QuadVertexBuffer->Data(Buffer_Vertex, QuadVertices, sizeof(QuadVertices));
SetDepthMode(0, 0);
}
+void RenderDevice::InitShaders( const char * vertex_shader, const char * pixel_shader, ShaderSet ** pShaders, ID3D11InputLayout ** pVertexIL,
+ D3D11_INPUT_ELEMENT_DESC * DistortionMeshVertexDesc, int num_elements)
+{
+ ID3D10Blob* vsData = CompileShader("vs_4_0", vertex_shader);
+
+ Ptr<VertexShader> vtxShader = *new VertexShader(this, vsData);
+
+ ID3D11InputLayout** objRef = pVertexIL;
+
+ HRESULT validate = Device->CreateInputLayout(
+ DistortionMeshVertexDesc, num_elements,
+ vsData->GetBufferPointer(), vsData->GetBufferSize(), objRef);
+ if(FAILED(validate)) OVR_ASSERT(false);
+
+ (*pShaders) = CreateShaderSet();
+ (*pShaders)->SetShader(vtxShader);
+
+ ID3D10Blob *pShader = CompileShader("ps_4_0", pixel_shader);
+ Ptr<PixelShader> ps = *new PixelShader(this, pShader);
+
+ (*pShaders)->SetShader(ps);
+}
+
+
+
RenderDevice::~RenderDevice()
{
if (SwapChain && Params.Fullscreen)
@@ -642,17 +770,32 @@ RenderDevice::~RenderDevice()
}
+
// Implement static initializer function to create this class.
-RenderTiny::RenderDevice* RenderDevice::CreateDevice(const RendererParams& rp, void* oswnd)
+RenderDevice* RenderDevice::CreateDevice(const RendererParams& rp, void* oswnd)
{
- return new RenderDevice(rp, (HWND)oswnd);
+ RenderDevice* p = new RenderDevice(rp, (HWND)oswnd);
+ if (p)
+ {
+ if (!p->Device)
+ {
+ p->Release();
+ p = 0;
+ }
+ }
+ return p;
+}
+
+RenderDevice* RenderDevice::CreateSlaveDevice(const SlaveRendererParams& srp)
+{
+ return new RenderDevice(srp);
}
// Fallback monitor enumeration in case newly plugged in monitor wasn't detected.
// Added originally for the FactoryTest app.
// New Outputs don't seem to be detected unless adapter is re-created, but that would also
-// require us to re-initialize D3D10 (recreating objects, etc). This bypasses that for "fake"
+// require us to re-initialize D3D11 (recreating objects, etc). This bypasses that for "fake"
// fullscreen modes.
BOOL CALLBACK MonitorEnumFunc(HMONITOR hMonitor, HDC, LPRECT, LPARAM dwData)
{
@@ -736,7 +879,7 @@ bool RenderDevice::RecreateSwapChain()
scDesc.BufferDesc.Width = WindowWidth;
scDesc.BufferDesc.Height = WindowHeight;
scDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
- scDesc.BufferDesc.RefreshRate.Numerator = 60;
+ scDesc.BufferDesc.RefreshRate.Numerator = 0;
scDesc.BufferDesc.RefreshRate.Denominator = 1;
scDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
scDesc.OutputWindow = Window;
@@ -759,7 +902,7 @@ bool RenderDevice::RecreateSwapChain()
BackBuffer = NULL;
BackBufferRT = NULL;
- HRESULT hr = SwapChain->GetBuffer(0, __uuidof(ID3D1xTexture2D), (void**)&BackBuffer.GetRawRef());
+ HRESULT hr = SwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)&BackBuffer.GetRawRef());
if (FAILED(hr))
return false;
@@ -786,8 +929,6 @@ bool RenderDevice::SetParams(const RendererParams& newParams)
UpdateMonitorOutputs();
}
- // Cause this to be recreated with the new multisample mode.
- pSceneColorTex = NULL;
return RecreateSwapChain();
}
@@ -807,14 +948,25 @@ bool RenderDevice::SetFullscreen(DisplayMode fullscreen)
return true;
}
-void RenderDevice::SetRealViewport(const Viewport& vp)
+void RenderDevice::SetViewport(const Recti& vp)
+{
+ D3DViewport.Width = (float)vp.w;
+ D3DViewport.Height = (float)vp.h;
+ D3DViewport.MinDepth = 0;
+ D3DViewport.MaxDepth = 1;
+ D3DViewport.TopLeftX = (float)vp.x;
+ D3DViewport.TopLeftY = (float)vp.y;
+ Context->RSSetViewports(1, &D3DViewport);
+}
+
+void RenderDevice::SetFullViewport()
{
- D3DViewport.Width = vp.w;
- D3DViewport.Height = vp.h;
+ D3DViewport.Width = (float)WindowWidth;
+ D3DViewport.Height = (float)WindowHeight;
D3DViewport.MinDepth = 0;
D3DViewport.MaxDepth = 1;
- D3DViewport.TopLeftX = vp.x;
- D3DViewport.TopLeftY = vp.y;
+ D3DViewport.TopLeftX = 0;
+ D3DViewport.TopLeftY = 0;
Context->RSSetViewports(1, &D3DViewport);
}
@@ -835,18 +987,18 @@ void RenderDevice::SetDepthMode(bool enable, bool write, CompareFunc func)
return;
}
- D3D1x_(DEPTH_STENCIL_DESC) dss;
+ D3D11_DEPTH_STENCIL_DESC dss;
memset(&dss, 0, sizeof(dss));
dss.DepthEnable = enable;
switch(func)
{
- case Compare_Always: dss.DepthFunc = D3D1x_(COMPARISON_ALWAYS); break;
- case Compare_Less: dss.DepthFunc = D3D1x_(COMPARISON_LESS); break;
- case Compare_Greater: dss.DepthFunc = D3D1x_(COMPARISON_GREATER); break;
+ case Compare_Always: dss.DepthFunc = D3D11_COMPARISON_ALWAYS; break;
+ case Compare_Less: dss.DepthFunc = D3D11_COMPARISON_LESS; break;
+ case Compare_Greater: dss.DepthFunc = D3D11_COMPARISON_GREATER; break;
default:
- assert(0);
+ OVR_ASSERT(0);
}
- dss.DepthWriteMask = write ? D3D1x_(DEPTH_WRITE_MASK_ALL) : D3D1x_(DEPTH_WRITE_MASK_ZERO);
+ dss.DepthWriteMask = write ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO;
Device->CreateDepthStencilState(&dss, &DepthStates[index].GetRawRef());
Context->OMSetDepthStencilState(DepthStates[index], 0);
CurDepthState = DepthStates[index];
@@ -879,21 +1031,21 @@ void RenderDevice::Clear(float r, float g, float b, float a, float depth)
// Needed for each eye to do its own clear, since ClearRenderTargetView doesn't honor viewport.
// Save state that is affected by clearing this way
- ID3D1xDepthStencilState* oldDepthState = CurDepthState;
+ ID3D11DepthStencilState* oldDepthState = CurDepthState;
StandardUniformData clearUniforms;
SetDepthMode(true, true, Compare_Always);
Context->IASetInputLayout(ModelVertexIL);
- Context->GSSetShader(NULL);
+ Context->GSSetShader(NULL, NULL, 0);
- ID3D1xShaderResourceView* sv[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+ ID3D11ShaderResourceView* sv[8] = {0, 0, 0, 0, 0, 0, 0, 0};
if (MaxTextureSet[Shader_Fragment])
{
Context->PSSetShaderResources(0, MaxTextureSet[Shader_Fragment], sv);
}
- ID3D1xBuffer* vertexBuffer = QuadVertexBuffer->GetBuffer();
+ ID3D11Buffer* vertexBuffer = QuadVertexBuffer->GetBuffer();
UINT vertexStride = sizeof(Vertex);
UINT vertexOffset = 0;
Context->IASetVertexBuffers(0, 1, &vertexBuffer, &vertexStride, &vertexOffset);
@@ -904,9 +1056,9 @@ void RenderDevice::Clear(float r, float g, float b, float a, float depth)
-1, -1, depth, 1);
UniformBuffers[Shader_Vertex]->Data(Buffer_Uniform, &clearUniforms, sizeof(clearUniforms));
- ID3D1xBuffer* vertexConstants = UniformBuffers[Shader_Vertex]->GetBuffer();
+ ID3D11Buffer* vertexConstants = UniformBuffers[Shader_Vertex]->GetBuffer();
Context->VSSetConstantBuffers(0, 1, &vertexConstants);
- Context->IASetPrimitiveTopology(D3D1x_(PRIMITIVE_TOPOLOGY_TRIANGLESTRIP));
+ Context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
VertexShaders[VShader_MV]->Set(Prim_TriangleStrip);
PixelShaders[FShader_Solid]->Set(Prim_TriangleStrip);
@@ -950,7 +1102,8 @@ ID3D10Blob* RenderDevice::CompileShader(const char* profile, const char* src, co
return shader;
}
-void RenderDevice::SetCommonUniformBuffer(int i, RenderTiny::Buffer* buffer)
+
+void RenderDevice::SetCommonUniformBuffer(int i, Buffer* buffer)
{
CommonUniforms[i] = (Buffer*)buffer;
@@ -958,7 +1111,7 @@ void RenderDevice::SetCommonUniformBuffer(int i, RenderTiny::Buffer* buffer)
Context->VSSetConstantBuffers(1, 1, &CommonUniforms[1]->D3DBuffer.GetRawRef());
}
-RenderTiny::Shader *RenderDevice::LoadBuiltinShader(ShaderStage stage, int shader)
+ShaderBase *RenderDevice::LoadBuiltinShader(ShaderStage stage, int shader)
{
switch(stage)
{
@@ -972,32 +1125,32 @@ RenderTiny::Shader *RenderDevice::LoadBuiltinShader(ShaderStage stage, int shade
}
-ID3D1xSamplerState* RenderDevice::GetSamplerState(int sm)
+ID3D11SamplerState* RenderDevice::GetSamplerState(int sm)
{
if (SamplerStates[sm])
return SamplerStates[sm];
- D3D1x_(SAMPLER_DESC) ss;
+ D3D11_SAMPLER_DESC ss;
memset(&ss, 0, sizeof(ss));
if (sm & Sample_Clamp)
- ss.AddressU = ss.AddressV = ss.AddressW = D3D1x_(TEXTURE_ADDRESS_CLAMP);
+ ss.AddressU = ss.AddressV = ss.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
else if (sm & Sample_ClampBorder)
- ss.AddressU = ss.AddressV = ss.AddressW = D3D1x_(TEXTURE_ADDRESS_BORDER);
+ ss.AddressU = ss.AddressV = ss.AddressW = D3D11_TEXTURE_ADDRESS_BORDER;
else
- ss.AddressU = ss.AddressV = ss.AddressW = D3D1x_(TEXTURE_ADDRESS_WRAP);
+ ss.AddressU = ss.AddressV = ss.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
if (sm & Sample_Nearest)
{
- ss.Filter = D3D1x_(FILTER_MIN_MAG_MIP_POINT);
+ ss.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
}
else if (sm & Sample_Anisotropic)
{
- ss.Filter = D3D1x_(FILTER_ANISOTROPIC);
+ ss.Filter = D3D11_FILTER_ANISOTROPIC;
ss.MaxAnisotropy = 8;
}
else
{
- ss.Filter = D3D1x_(FILTER_MIN_MAG_MIP_LINEAR);
+ ss.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
}
ss.MaxLOD = 15;
Device->CreateSamplerState(&ss, &SamplerStates[sm].GetRawRef());
@@ -1005,12 +1158,12 @@ ID3D1xSamplerState* RenderDevice::GetSamplerState(int sm)
}
-void RenderDevice::SetTexture(RenderTiny::ShaderStage stage, int slot, const Texture* t)
+void RenderDevice::SetTexture(ShaderStage stage, int slot, const Texture* t)
{
if (MaxTextureSet[stage] <= slot)
MaxTextureSet[stage] = slot + 1;
- ID3D1xShaderResourceView* sv = t ? t->TexSv : NULL;
+ ID3D11ShaderResourceView* sv = t ? t->TexSv : NULL;
switch(stage)
{
case Shader_Fragment:
@@ -1027,6 +1180,16 @@ void RenderDevice::SetTexture(RenderTiny::ShaderStage stage, int slot, const Tex
}
}
+// Placeholder texture to come in externally in slave rendering mode
+Texture* RenderDevice::CreatePlaceholderTexture(int format)
+{
+ Texture* newTex = new Texture(this, format, 0, 0);
+ newTex->Samples = 1;
+
+ return newTex;
+}
+
+
Texture* RenderDevice::CreateTexture(int format, int width, int height, const void* data, int mipcount)
{
OVR_UNUSED(mipcount);
@@ -1056,7 +1219,7 @@ Texture* RenderDevice::CreateTexture(int format, int width, int height, const vo
Texture* NewTex = new Texture(this, format, width, height);
NewTex->Samples = samples;
- D3D1x_(TEXTURE2D_DESC) dsDesc;
+ D3D11_TEXTURE2D_DESC dsDesc;
dsDesc.Width = width;
dsDesc.Height = height;
dsDesc.MipLevels = (format == (Texture_RGBA | Texture_GenMipmaps) && data) ? GetNumMipLevels(width, height) : 1;
@@ -1064,8 +1227,8 @@ Texture* RenderDevice::CreateTexture(int format, int width, int height, const vo
dsDesc.Format = d3dformat;
dsDesc.SampleDesc.Count = samples;
dsDesc.SampleDesc.Quality = 0;
- dsDesc.Usage = D3D1x_(USAGE_DEFAULT);
- dsDesc.BindFlags = D3D1x_(BIND_SHADER_RESOURCE);
+ dsDesc.Usage = D3D11_USAGE_DEFAULT;
+ dsDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
dsDesc.CPUAccessFlags = 0;
dsDesc.MiscFlags = 0;
@@ -1073,11 +1236,11 @@ Texture* RenderDevice::CreateTexture(int format, int width, int height, const vo
{
if ((format & Texture_TypeMask) == Texture_Depth)
{ // We don't use depth textures, and creating them in d3d10 requires different options.
- dsDesc.BindFlags = D3D1x_(BIND_DEPTH_STENCIL);
+ dsDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
}
else
{
- dsDesc.BindFlags |= D3D1x_(BIND_RENDER_TARGET);
+ dsDesc.BindFlags |= D3D11_BIND_RENDER_TARGET;
}
}
@@ -1088,7 +1251,7 @@ Texture* RenderDevice::CreateTexture(int format, int width, int height, const vo
NewTex->Release();
return NULL;
}
- if (dsDesc.BindFlags & D3D1x_(BIND_SHADER_RESOURCE))
+ if (dsDesc.BindFlags & D3D11_BIND_SHADER_RESOURCE)
{
Device->CreateShaderResourceView(NewTex->Tex, NULL, &NewTex->TexSv.GetRawRef());
}
@@ -1147,6 +1310,15 @@ Texture* RenderDevice::CreateTexture(int format, int width, int height, const vo
return NewTex;
}
+ShaderFill* RenderDevice::CreateTextureFill(Texture* t)
+{
+ ShaderSet* shaders = CreateShaderSet();
+ shaders->SetShader(LoadBuiltinShader(Shader_Vertex, VShader_MVP));
+ shaders->SetShader(LoadBuiltinShader(Shader_Fragment, FShader_Texture));
+ ShaderFill* f = new ShaderFill(*shaders);
+ f->SetTexture(0, t);
+ return f;
+}
// Rendering
@@ -1155,8 +1327,36 @@ void RenderDevice::BeginRendering()
Context->RSSetState(Rasterizer);
}
-void RenderDevice::SetRenderTarget(RenderTiny::Texture* colorTex,
- RenderTiny::Texture* depth, RenderTiny::Texture* stencil)
+void RenderDevice::SetLighting(const LightingParams* lt)
+{
+ if (!LightingBuffer)
+ LightingBuffer = *CreateBuffer();
+
+ LightingBuffer->Data(Buffer_Uniform, lt, sizeof(LightingParams));
+ SetCommonUniformBuffer(1, LightingBuffer);
+}
+
+void RenderDevice::SetProjection(const Matrix4f& proj)
+{
+ Proj = proj;
+ SetWorldUniforms(proj);
+}
+
+void RenderDevice::BeginScene()
+{
+ BeginRendering();
+ SetViewport(VP);
+ SetWorldUniforms(Proj);
+}
+
+void RenderDevice::FinishScene()
+{
+ SetRenderTarget(0);
+}
+
+void RenderDevice::SetRenderTarget(Texture* colorTex,
+ Texture* depth,
+ Texture* stencil)
{
OVR_UNUSED(stencil);
@@ -1180,7 +1380,7 @@ void RenderDevice::SetRenderTarget(RenderTiny::Texture* colorTex,
depth = GetDepthBuffer(colorTex->GetWidth(), colorTex->GetHeight(), CurRenderTarget->Samples);
}
- ID3D1xShaderResourceView* sv[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+ ID3D11ShaderResourceView* sv[8] = {0, 0, 0, 0, 0, 0, 0, 0};
if (MaxTextureSet[Shader_Fragment])
{
Context->PSSetShaderResources(0, MaxTextureSet[Shader_Fragment], sv);
@@ -1199,7 +1399,7 @@ void RenderDevice::SetWorldUniforms(const Matrix4f& proj)
}
-void RenderDevice::Render(const Matrix4f& matrix, Model* model)
+void RenderDevice::Render(const Matrix4f& view, Model* model)
{
// Store data in buffers if not already
if (!model->VertexBuffer)
@@ -1217,19 +1417,32 @@ void RenderDevice::Render(const Matrix4f& matrix, Model* model)
Render(model->Fill ? model->Fill : DefaultFill,
model->VertexBuffer, model->IndexBuffer,
- matrix, 0, (unsigned)model->Indices.GetSize(), model->GetPrimType());
+ view, 0, (unsigned)model->Indices.GetSize(), model->GetPrimType());
}
-void RenderDevice::Render(const ShaderFill* fill, RenderTiny::Buffer* vertices, RenderTiny::Buffer* indices,
- const Matrix4f& matrix, int offset, int count, PrimitiveType rprim)
+
+//Cut down one for ORT for simplicity
+void RenderDevice::Render(const ShaderFill* fill, Buffer* vertices, Buffer* indices)
{
- Context->IASetInputLayout(ModelVertexIL);
+ Render(fill, vertices, indices, Matrix4f(), 0, (int)vertices->GetSize(), Prim_Triangles, false);
+}
+
+
+void RenderDevice::Render(const ShaderFill* fill, Buffer* vertices, Buffer* indices,
+ const Matrix4f& matrix, int offset, int count, PrimitiveType rprim, bool updateUniformData)
+{
+
+ if(((ShaderFill*)fill)->GetInputLayout() != NULL)
+ Context->IASetInputLayout((ID3D11InputLayout*)((ShaderFill*)fill)->GetInputLayout());
+ else
+ Context->IASetInputLayout(ModelVertexIL);
+
if (indices)
{
Context->IASetIndexBuffer(((Buffer*)indices)->GetBuffer(), DXGI_FORMAT_R16_UINT, 0);
}
- ID3D1xBuffer* vertexBuffer = ((Buffer*)vertices)->GetBuffer();
+ ID3D11Buffer* vertexBuffer = ((Buffer*)vertices)->GetBuffer();
UINT vertexStride = sizeof(Vertex);
UINT vertexOffset = offset;
Context->IASetVertexBuffers(0, 1, &vertexBuffer, &vertexStride, &vertexOffset);
@@ -1240,11 +1453,15 @@ void RenderDevice::Render(const ShaderFill* fill, RenderTiny::Buffer* vertices,
unsigned char* vertexData = vshader->UniformData;
if (vertexData)
{
- StandardUniformData* stdUniforms = (StandardUniformData*) vertexData;
- stdUniforms->View = matrix.Transposed();
- stdUniforms->Proj = StdUniforms.Proj;
- UniformBuffers[Shader_Vertex]->Data(Buffer_Uniform, vertexData, vshader->UniformsSize);
- vshader->SetUniformBuffer(UniformBuffers[Shader_Vertex]);
+ // TODO: some VSes don't start with StandardUniformData!
+ if ( updateUniformData )
+ {
+ StandardUniformData* stdUniforms = (StandardUniformData*) vertexData;
+ stdUniforms->View = matrix.Transposed();
+ stdUniforms->Proj = StdUniforms.Proj;
+ }
+ UniformBuffers[Shader_Vertex]->Data(Buffer_Uniform, vertexData, vshader->UniformsSize);
+ vshader->SetUniformBuffer(UniformBuffers[Shader_Vertex]);
}
for(int i = Shader_Vertex + 1; i < Shader_Count; i++)
@@ -1254,20 +1471,20 @@ void RenderDevice::Render(const ShaderFill* fill, RenderTiny::Buffer* vertices,
((ShaderBase*)shaders->GetShader(i))->SetUniformBuffer(UniformBuffers[i]);
}
- D3D1x_(PRIMITIVE_TOPOLOGY) prim;
+ D3D11_PRIMITIVE_TOPOLOGY prim;
switch(rprim)
{
case Prim_Triangles:
- prim = D3D1x_(PRIMITIVE_TOPOLOGY_TRIANGLELIST);
+ prim = D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
break;
case Prim_Lines:
- prim = D3D1x_(PRIMITIVE_TOPOLOGY_LINELIST);
+ prim = D3D11_PRIMITIVE_TOPOLOGY_LINELIST;
break;
case Prim_TriangleStrip:
- prim = D3D1x_(PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
+ prim = D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP;
break;
default:
- assert(0);
+ OVR_ASSERT(0);
return;
}
Context->IASetPrimitiveTopology(prim);
@@ -1285,27 +1502,55 @@ void RenderDevice::Render(const ShaderFill* fill, RenderTiny::Buffer* vertices,
}
-void RenderDevice::Present()
+void RenderDevice::Present(bool vsyncEnabled)
{
- SwapChain->Present(0, 0);
+ SwapChain->Present(vsyncEnabled ? 1 : 0, 0);
}
-void RenderDevice::ForceFlushGPU()
+void RenderDevice::WaitUntilGpuIdle()
{
- D3D1x_QUERY_DESC queryDesc = { D3D1x_(QUERY_EVENT), 0 };
- Ptr<ID3D1xQuery> query;
+ // Flush and Stall CPU while waiting for GPU to complete rendering all of the queued draw calls
+ D3D11_QUERY_DESC queryDesc = { D3D11_QUERY_EVENT, 0 };
+ Ptr<ID3D11Query> query;
BOOL done = FALSE;
if (Device->CreateQuery(&queryDesc, &query.GetRawRef()) == S_OK)
{
- // Begin() not used for EVENT query.
- query->End();
- // GetData will returns S_OK for both done == TRUE or FALSE.
- // Exit on failure to avoid infinite loop.
+ Context->End(query);
do { }
- while(!done && !FAILED(query->GetData(&done, sizeof(BOOL), 0)));
+ while(!done && !FAILED(Context->GetData(query, &done, sizeof(BOOL), 0)));
+ }
+}
+
+
+int GetNumMipLevels(int w, int h)
+{
+ int n = 1;
+ while(w > 1 || h > 1)
+ {
+ w >>= 1;
+ h >>= 1;
+ n++;
+ }
+ return n;
+}
+
+void FilterRgba2x2(const UByte* src, int w, int h, UByte* dest)
+{
+ for(int j = 0; j < (h & ~1); j += 2)
+ {
+ const UByte* psrc = src + (w * j * 4);
+ UByte* pdest = dest + ((w >> 1) * (j >> 1) * 4);
+
+ for(int i = 0; i < w >> 1; i++, psrc += 8, pdest += 4)
+ {
+ pdest[0] = (((int)psrc[0]) + psrc[4] + psrc[w * 4 + 0] + psrc[w * 4 + 4]) >> 2;
+ pdest[1] = (((int)psrc[1]) + psrc[5] + psrc[w * 4 + 1] + psrc[w * 4 + 5]) >> 2;
+ pdest[2] = (((int)psrc[2]) + psrc[6] + psrc[w * 4 + 2] + psrc[w * 4 + 6]) >> 2;
+ pdest[3] = (((int)psrc[3]) + psrc[7] + psrc[w * 4 + 3] + psrc[w * 4 + 7]) >> 2;
+ }
}
}
-}}}
+}}
diff --git a/Samples/OculusRoomTiny/RenderTiny_Device.h b/Samples/OculusRoomTiny/RenderTiny_D3D11_Device.h
index 878450d..f4ec71a 100644
--- a/Samples/OculusRoomTiny/RenderTiny_Device.h
+++ b/Samples/OculusRoomTiny/RenderTiny_D3D11_Device.h
@@ -1,9 +1,9 @@
/************************************************************************************
-Filename : RenderTiny_Device.h
-Content : Minimal possible renderer for RoomTiny sample
-Created : September 6, 2012
-Authors : Andrew Reisse, Michael Antonov
+Filename : RenderTiny_D3D11_Device.h
+Content : RenderDevice implementation header for D3DX10.
+Created : September 10, 2012
+Authors : Andrew Reisse
Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
@@ -21,23 +21,20 @@ limitations under the License.
************************************************************************************/
-#ifndef OVR_RenderTiny_Device_h
-#define OVR_RenderTiny_Device_h
+#ifndef INC_RenderTiny_D3D11_Device_h
+#define INC_RenderTiny_D3D11_Device_h
#include "Kernel/OVR_Math.h"
#include "Kernel/OVR_Array.h"
-#include "Kernel/OVR_RefCount.h"
#include "Kernel/OVR_String.h"
-#include "Kernel/OVR_File.h"
#include "Kernel/OVR_Color.h"
-
-#include "Util/Util_Render_Stereo.h"
+#include <d3d11.h>
namespace OVR { namespace RenderTiny {
-using namespace OVR::Util::Render;
class RenderDevice;
+class Buffer;
//-----------------------------------------------------------------------------------
@@ -66,16 +63,13 @@ enum BuiltinShaders
{
VShader_MV = 0,
VShader_MVP = 1,
- VShader_PostProcess = 2,
- VShader_Count = 3,
+ VShader_Count = 2,
FShader_Solid = 0,
FShader_Gouraud = 1,
FShader_Texture = 2,
- FShader_PostProcess = 3,
- FShader_PostProcessWithChromAb = 4,
- FShader_LitGouraud = 5,
- FShader_LitTexture = 6,
+ FShader_LitGouraud = 3,
+ FShader_LitTexture = 4,
FShader_Count
};
@@ -124,20 +118,9 @@ enum SampleMode
Sample_Count =13,
};
-// A vector with a dummy w component for alignment in uniform buffers (and for float colors).
-// The w component is not used in any calculations.
-struct Vector4f : public Vector3f
-{
- float w;
-
- Vector4f() : w(1) {}
- Vector4f(const Vector3f& v) : Vector3f(v), w(1) {}
- Vector4f(float r, float g, float b, float a) : Vector3f(r,g,b), w(a) {}
-};
-
// Base class for vertex and pixel shaders. Stored in ShaderSet.
-class Shader : public RefCountBase<Shader>
+class ShaderBase : public RefCountBase<ShaderBase>
{
friend class ShaderSet;
@@ -145,31 +128,92 @@ protected:
ShaderStage Stage;
public:
- Shader(ShaderStage s) : Stage(s) {}
- virtual ~Shader() {}
+ RenderDevice* Ren;
+ unsigned char* UniformData;
+ int UniformsSize;
+
+ enum VarType
+ {
+ VARTYPE_FLOAT,
+ VARTYPE_INT,
+ VARTYPE_BOOL,
+ };
+
+ struct Uniform
+ {
+ String Name;
+ VarType Type;
+ int Offset, Size;
+ };
+ Array<Uniform> UniformInfo;
+
+ ShaderBase(RenderDevice* r, ShaderStage stage);
+ ShaderBase(ShaderStage s) : Stage(s) {}
+
+ ~ShaderBase();
ShaderStage GetStage() const { return Stage; }
virtual void Set(PrimitiveType) const { }
virtual void SetUniformBuffer(class Buffer* buffers, int i = 0) { OVR_UNUSED2(buffers, i); }
+
+ void InitUniforms(ID3D10Blob* s);
+ void InitUniforms(void* s, size_t sizeS);
+ virtual bool SetUniform(const char* name, int n, const float* v);
+ virtual bool SetUniformBool(const char* name, int n, const bool* v);
-protected:
- virtual bool SetUniform(const char* name, int n, const float* v) { OVR_UNUSED3(name, n, v); return false; }
+ void UpdateBuffer(Buffer* b);
};
+template<ShaderStage SStage, class D3DShaderType>
+class Shader : public ShaderBase
+{
+public:
+ D3DShaderType* D3DShader;
+
+ Shader(RenderDevice* r, D3DShaderType* s) : ShaderBase(r, SStage), D3DShader(s) {}
+ Shader(RenderDevice* r, ID3D10Blob* s) : ShaderBase(r, SStage)
+ {
+ Load(s);
+ InitUniforms(s);
+ }
+ Shader(RenderDevice* r, void* s, size_t size) : ShaderBase(r, SStage)
+ {
+ Load(s, size);
+ InitUniforms(s, size);
+ }
+ ~Shader()
+ {
+ if (D3DShader)
+ D3DShader->Release();
+ }
+ bool Load(ID3D10Blob* shader)
+ {
+ return Load(shader->GetBufferPointer(), shader->GetBufferSize());
+ }
+
+ // These functions have specializations.
+ bool Load(void* shader, size_t size);
+ void Set(PrimitiveType prim) const;
+ void SetUniformBuffer(Buffer* buffers, int i = 0);
+};
+
+typedef Shader<Shader_Vertex, ID3D11VertexShader> VertexShader;
+typedef Shader<Shader_Fragment, ID3D11PixelShader> PixelShader;
+
// A group of shaders, one per stage.
// A ShaderSet is applied to a RenderDevice for rendering with a given fill.
class ShaderSet : public RefCountBase<ShaderSet>
{
- protected:
- Ptr<Shader> Shaders[Shader_Count];
+protected:
+ Ptr<ShaderBase> Shaders[Shader_Count];
public:
ShaderSet() { }
~ShaderSet() { }
- virtual void SetShader(Shader *s)
+ virtual void SetShader(ShaderBase *s)
{
Shaders[s->GetStage()] = s;
}
@@ -177,7 +221,7 @@ public:
{
Shaders[stage] = NULL;
}
- Shader* GetShader(int stage) { return Shaders[stage]; }
+ ShaderBase* GetShader(int stage) { return Shaders[stage]; }
virtual void Set(PrimitiveType prim) const
{
@@ -208,6 +252,11 @@ public:
const float v[] = {x,y};
return SetUniform(name, 2, v);
}
+ bool SetUniform3f(const char* name, float x, float y, float z)
+ {
+ const float v[] = {x,y,z};
+ return SetUniform(name, 3, v);
+ }
bool SetUniform4f(const char* name, float x, float y, float z, float w = 1)
{
const float v[] = {x,y,z,w};
@@ -236,18 +285,22 @@ class ShaderFill : public RefCountBase<ShaderFill>
{
Ptr<ShaderSet> Shaders;
Ptr<class Texture> Textures[8];
+ void* InputLayout; // HACK this should be abstracted
public:
- ShaderFill(ShaderSet* sh) : Shaders(sh) { }
- ShaderFill(ShaderSet& sh) : Shaders(sh) { }
+ ShaderFill(ShaderSet* sh) : Shaders(sh) { InputLayout = NULL; }
+ ShaderFill(ShaderSet& sh) : Shaders(sh) { InputLayout = NULL; }
ShaderSet* GetShaders() { return Shaders; }
+
+ void* GetInputLayout() { return InputLayout; }
+
virtual void Set(PrimitiveType prim = Prim_Unknown) const;
virtual void SetTexture(int i, class Texture* tex) { if (i < 8) Textures[i] = tex; }
+ void SetInputLayout(void* newIL) { InputLayout = (void*)newIL; }
};
-
// Buffer for vertex or index data. Some renderers require separate buffers, so that
// is recommended. Some renderers cannot have high-performance buffers which are readable,
// so reading in Map should not be relied on.
@@ -263,31 +316,72 @@ public:
class Buffer : public RefCountBase<Buffer>
{
public:
+ RenderDevice* Ren;
+ Ptr<ID3D11Buffer> D3DBuffer;
+ size_t Size;
+ int Use;
+ bool Dynamic;
+
+public:
+ Buffer(RenderDevice* r) : Ren(r), Size(0), Use(0) {}
virtual ~Buffer() {}
- virtual size_t GetSize() = 0;
- virtual void* Map(size_t start, size_t size, int flags = 0) = 0;
- virtual bool Unmap(void *m) = 0;
+ ID3D11Buffer* GetBuffer()
+ {
+ return D3DBuffer;
+ }
+ virtual size_t GetSize()
+ {
+ return Size;
+ }
+ virtual void* Map(size_t start, size_t size, int flags = 0);
+ virtual bool Unmap(void *m);
// Allocates a buffer, optionally filling it with data.
- virtual bool Data(int use, const void* buffer, size_t size) = 0;
+ virtual bool Data(int use, const void* buffer, size_t size);
};
class Texture : public RefCountBase<Texture>
{
public:
- virtual ~Texture() {}
+ RenderDevice* Ren;
+ Ptr<ID3D11Texture2D> Tex;
+ Ptr<ID3D11ShaderResourceView> TexSv;
+ Ptr<ID3D11RenderTargetView> TexRtv;
+ Ptr<ID3D11DepthStencilView> TexDsv;
+ mutable Ptr<ID3D11SamplerState> Sampler;
+ int Width, Height;
+ int Samples;
+
+ Texture(RenderDevice* r, int fmt, int w, int h);
+ virtual ~Texture();
+
+ virtual int GetWidth() const { return Width; }
+ virtual int GetHeight() const { return Height; }
+ virtual int GetSamples() const { return Samples; }
+
+ virtual void SetSampleMode(int sm);
+
+ // Updates texture to point to specified resources
+ // - used for slave rendering.
+ void UpdatePlaceholderTexture(ID3D11Texture2D* texture, ID3D11ShaderResourceView* psrv)
+ {
+ Tex = texture;
+ TexSv = psrv;
+ TexRtv.Clear();
+ TexDsv.Clear();
+
+ D3D11_TEXTURE2D_DESC desc;
+ texture->GetDesc(&desc);
+ Width = desc.Width;
+ Height= desc.Height;
+ }
- virtual int GetWidth() const = 0;
- virtual int GetHeight() const = 0;
- virtual int GetSamples() const { return 1; }
- virtual void SetSampleMode(int sm) = 0;
- virtual void Set(int slot, ShaderStage stage = Shader_Fragment) const = 0;
+ virtual void Set(int slot, ShaderStage stage = Shader_Fragment) const;
};
-
//-----------------------------------------------------------------------------------
// Node is a base class for geometry in a Scene, it contains base position
@@ -300,7 +394,7 @@ class Node : public RefCountBase<Node>
Quatf Rot;
mutable Matrix4f Mat;
- mutable bool MatCurrent;
+ mutable bool MatCurrent;
public:
Node() : Pos(Vector3f(0)), MatCurrent(1) { }
@@ -334,14 +428,14 @@ public:
{
if (!MatCurrent)
{
- Mat = Rot;
+ Mat = Matrix4f(Rot);
Mat = Matrix4f::Translation(Pos) * Mat;
MatCurrent = 1;
}
return Mat;
}
- virtual void Render(const Matrix4f& ltw, RenderDevice* ren) { OVR_UNUSED2(ltw, ren); }
+ virtual void Render(const Matrix4f& ltw, RenderDevice* ren) { OVR_UNUSED2(ltw, ren); }
};
@@ -355,19 +449,20 @@ struct Vertex
Vector3f Norm;
Vertex (const Vector3f& p, const Color& c = Color(64,0,0,255),
- float u = 0, float v = 0, Vector3f n = Vector3f(1,0,0))
- : Pos(p), C(c), U(u), V(v), Norm(n)
+ float u = 0, float v = 0, Vector3f n = Vector3f(1,0,0))
+ : Pos(p), C(c), U(u), V(v), Norm(n)
{}
Vertex(float x, float y, float z, const Color& c = Color(64,0,0,255),
- float u = 0, float v = 0) : Pos(x,y,z), C(c), U(u), V(v)
+ float u = 0, float v = 0) : Pos(x,y,z), C(c), U(u), V(v)
{ }
-
+
bool operator==(const Vertex& b) const
{
return Pos == b.Pos && C == b.C && U == b.U && V == b.V;
}
};
+
// LightingParams are stored in a uniform buffer, don't change it without fixing all renderers
// Scene contains a set of LightingParams that is uses for rendering.
struct LightingParams
@@ -397,9 +492,9 @@ struct LightingParams
s->SetUniform4fv("LightPos", (int)LightCount, LightPos);
s->SetUniform4fv("LightColor", (int)LightCount, LightColor);
}
-
};
+
//-----------------------------------------------------------------------------------
// Model is a triangular mesh with a fill that can be added to scene.
@@ -430,7 +525,7 @@ public:
// Node implementation.
virtual NodeType GetType() const { return Node_Model; }
virtual void Render(const Matrix4f& ltw, RenderDevice* ren);
-
+
// Returns the index next added vertex will have.
UInt16 GetNextVertexIndex() const
@@ -440,7 +535,7 @@ public:
UInt16 AddVertex(const Vertex& v)
{
- assert(!VertexBuffer && !IndexBuffer);
+ OVR_ASSERT(!VertexBuffer && !IndexBuffer);
UInt16 index = (UInt16)Vertices.GetSize();
Vertices.PushBack(v);
return index;
@@ -455,8 +550,8 @@ public:
// Uses texture coordinates for uniform world scaling (must use a repeat sampler).
void AddSolidColorBox(float x1, float y1, float z1,
- float x2, float y2, float z2,
- Color c);
+ float x2, float y2, float z2,
+ Color c);
};
@@ -468,18 +563,18 @@ public:
Container() { }
~Container() { }
-
+
virtual NodeType GetType() const { return Node_Container; }
virtual void Render(const Matrix4f& ltw, RenderDevice* ren);
void Add(Node *n) { Nodes.PushBack(n); }
- void Clear() { Nodes.Clear(); }
+ void Clear() { Nodes.Clear(); }
};
// Scene combines a collection of model
-class Scene
+class Scene : public NewOverrideBase
{
public:
Container World;
@@ -493,7 +588,7 @@ public:
{
Lighting.Ambient = color;
}
-
+
void AddLight(Vector3f pos, Vector4f color)
{
int n = (int)Lighting.LightCount;
@@ -503,31 +598,23 @@ public:
Lighting.LightCount++;
}
- void Clear()
- {
- World.Clear();
- Lighting.Ambient = Vector4f(0.0f, 0.0f, 0.0f, 0.0f);
- Lighting.LightCount = 0;
- }
- };
+ void Clear()
+ {
+ World.Clear();
+ Lighting.Ambient = Vector4f(0.0f, 0.0f, 0.0f, 0.0f);
+ Lighting.LightCount = 0;
+ }
+};
//-----------------------------------------------------------------------------------
-// Post-processing type to apply to scene after rendering. PostProcess_Distortion
-// applied distortion as described by DistortionConfig.
-enum PostProcessType
-{
- PostProcess_None,
- PostProcess_Distortion
-};
-
enum DisplayMode
{
Display_Window = 0,
Display_Fullscreen = 1
};
-
+
// Rendering parameters used by RenderDevice::CreateDevice.
struct RendererParams
@@ -541,47 +628,28 @@ struct RendererParams
long DisplayId;
RendererParams(int ms = 1) : Multisample(ms), Fullscreen(0) {}
-
+
bool IsDisplaySet() const
{
return MonitorName.GetLength() || DisplayId;
}
};
+class RenderDevice : public RefCountBase<RenderDevice>
+{
-//-----------------------------------------------------------------------------------
-// ***** RenderDevice
-
-// Rendering device abstraction.
-// Provides platform-independent part of implementation, with platform-specific
-// part being in a separate derived class/file, such as D3D10::RenderDevice.
-//
-class RenderDevice : public RefCountBase<RenderDevice>
-{
protected:
int WindowWidth, WindowHeight;
RendererParams Params;
- Viewport VP;
+ Recti VP;
Matrix4f Proj;
Ptr<Buffer> pTextVertexBuffer;
- // For rendering with lens warping
- PostProcessType CurPostProcess;
- Ptr<Texture> pSceneColorTex; // Distortion render target, both eyes.
- int SceneColorTexW;
- int SceneColorTexH;
- Ptr<ShaderSet> pPostProcessShader;
- Ptr<Buffer> pFullScreenVertexBuffer;
- float SceneRenderScale;
- DistortionConfig Distortion;
-
// For lighting on platforms with uniform buffers
Ptr<Buffer> LightingBuffer;
- void FinishScene1();
-
public:
enum CompareFunc
{
@@ -590,127 +658,153 @@ public:
Compare_Greater = 2,
Compare_Count
};
- RenderDevice();
- virtual ~RenderDevice() { Shutdown(); }
- // This static function is implemented in each derived class
- // to support a specific renderer type.
- //static RenderDevice* CreateDevice(const RendererParams& rp, void* oswnd);
+ Ptr<IDXGIFactory> DXGIFactory;
+ HWND Window;
+ Ptr<ID3D11Device> Device;
+ Ptr<ID3D11DeviceContext> Context;
+ Ptr<IDXGISwapChain> SwapChain;
+ Ptr<IDXGIAdapter> Adapter;
+ Ptr<IDXGIOutput> FullscreenOutput;
+ int FSDesktopX, FSDesktopY;
- virtual void Init() {}
- virtual void Shutdown() {}
- virtual bool SetParams(const RendererParams&) { return 0; }
+ Ptr<ID3D11Texture2D> BackBuffer;
+ Ptr<ID3D11RenderTargetView> BackBufferRT;
+ Ptr<Texture> CurRenderTarget;
+ Ptr<Texture> CurDepthBuffer;
+ Ptr<ID3D11RasterizerState> Rasterizer;
+ Ptr<ID3D11BlendState> BlendState;
+ D3D11_VIEWPORT D3DViewport;
- const RendererParams& GetParams() const { return Params; }
+ Ptr<ID3D11DepthStencilState> DepthStates[1 + 2 * Compare_Count];
+ Ptr<ID3D11DepthStencilState> CurDepthState;
+ Ptr<ID3D11InputLayout> ModelVertexIL;
-
- // StereoParams apply Viewport, Projection and Distortion simultaneously,
- // doing full configuration for one eye.
- void ApplyStereoParams(const StereoEyeParams& params)
- {
- SetViewport(params.VP);
- SetProjection(params.Projection);
- if (params.pDistortion)
- SetDistortionConfig(*params.pDistortion, params.Eye);
- }
+ Ptr<ID3D11SamplerState> SamplerStates[Sample_Count];
+
+ struct StandardUniformData
+ {
+ Matrix4f Proj;
+ Matrix4f View;
+ } StdUniforms;
+ Ptr<Buffer> UniformBuffers[Shader_Count];
+ int MaxTextureSet[Shader_Count];
- virtual void SetViewport(const Viewport& vp);
- void SetViewport(int x, int y, int w, int h) { SetViewport(Viewport(x,y,w,h)); }
+ Ptr<VertexShader> VertexShaders[VShader_Count];
+ Ptr<PixelShader> PixelShaders[FShader_Count];
+ Ptr<Buffer> CommonUniforms[8];
+ Ptr<ShaderFill> DefaultFill;
- // PostProcess distortion
- void SetSceneRenderScale(float ss);
+ Ptr<Buffer> QuadVertexBuffer;
- void SetDistortionConfig(const DistortionConfig& config, StereoEye eye = StereoEye_Left)
+ Array<Ptr<Texture> > DepthBuffers;
+
+public:
+
+ // Slave parameters are used to create a renderer that uses an externally
+ // specified device.
+ struct SlaveRendererParams
{
- Distortion = config;
- if (eye == StereoEye_Right)
- Distortion.XCenterOffset = -Distortion.XCenterOffset;
- }
-
+ ID3D11Device* pDevice;
+ ID3D11DeviceContext* pDeviceContext;
+ ID3D11RenderTargetView* pBackBufferRT;
+ Sizei RTSize;
+ int Multisample;
+ };
+
+ RenderDevice();
+ RenderDevice(const RendererParams& p, HWND window);
+ RenderDevice(const SlaveRendererParams& p);
+ virtual ~RenderDevice();
+
+ // Implement static initializer function to create this class.
+ // Creates a new rendering device
+ static RenderDevice* CreateDevice(const RendererParams& rp, void* oswnd);
+
+ // Creates a "slave" renderer existing device.
+ static RenderDevice* CreateSlaveDevice(const SlaveRendererParams& srp);
+
+
+
+ // Constructor helper
+ void initShadersAndStates();
+ void InitShaders( const char * vertex_shader, const char * pixel_shader, ShaderSet ** pShaders, ID3D11InputLayout ** pVertexIL,
+ D3D11_INPUT_ELEMENT_DESC * DistortionMeshVertexDesc, int num_elements);
+
+
+
+ void UpdateMonitorOutputs();
+
+ void SetViewport(int x, int y, int w, int h) { SetViewport(Recti(x,y,w,h)); }
// Set viewport ignoring any adjustments used for the stereo mode.
- virtual void SetRealViewport(const Viewport& vp) = 0;
+ virtual void SetViewport(const Recti& vp);
+ virtual void SetFullViewport();
+
+ virtual bool SetParams(const RendererParams& newParams);
+ const RendererParams& GetParams() const { return Params; }
+
+ virtual void Present(bool vsyncEnabled);
- virtual void Clear(float r = 0, float g = 0, float b = 0, float a = 1, float depth = 1) = 0;
-
- virtual bool IsFullscreen() const { return Params.Fullscreen != Display_Window; }
- virtual void Present() = 0;
// Waits for rendering to complete; important for reducing latency.
- virtual void ForceFlushGPU() { }
+ virtual void WaitUntilGpuIdle();
+
+ // Don't call these directly, use App/Platform instead
+ virtual bool SetFullscreen(DisplayMode fullscreen);
+
+ virtual void Clear(float r = 0, float g = 0, float b = 0, float a = 1, float depth = 1);
// Resources
- virtual Buffer* CreateBuffer() { return NULL; }
- virtual Texture* CreateTexture(int format, int width, int height, const void* data, int mipcount=1)
- { OVR_UNUSED5(format,width,height,data, mipcount); return NULL; }
-
+ virtual Buffer* CreateBuffer();
+ virtual Texture* CreateTexture(int format, int width, int height, const void* data, int mipcount=1);
+
+ // Placeholder texture to come in externally
+ virtual Texture* CreatePlaceholderTexture(int format);
virtual ShaderSet* CreateShaderSet() { return new ShaderSet; }
- virtual Shader* LoadBuiltinShader(ShaderStage stage, int shader) = 0;
- // Rendering
+ Texture* GetDepthBuffer(int w, int h, int ms);
// Begin drawing directly to the currently selected render target, no post-processing.
- virtual void BeginRendering() {}
- // Begin drawing the primary scene. This will have post-processing applied (if enabled)
- // during FinishScene.
- virtual void BeginScene(PostProcessType pp = PostProcess_None);
- // Postprocess the scene and return to the screen render target.
+ virtual void BeginRendering();
+
+ // Begin drawing the primary scene, starting up whatever post-processing may be needed.
+ virtual void BeginScene();
virtual void FinishScene();
// Texture must have been created with Texture_RenderTarget. Use NULL for the default render target.
// NULL depth buffer means use an internal, temporary one.
- virtual void SetRenderTarget(Texture* color, Texture* depth = NULL, Texture* stencil = NULL)
- { OVR_UNUSED3(color, depth, stencil); }
- virtual void SetDepthMode(bool enable, bool write, CompareFunc func = Compare_Less) = 0;
- virtual void SetProjection(const Matrix4f& proj);
- virtual void SetWorldUniforms(const Matrix4f& proj) = 0;
+ virtual void SetRenderTarget(Texture* color,
+ Texture* depth = NULL,
+ Texture* stencil = NULL);
+ virtual void SetDepthMode(bool enable, bool write, CompareFunc func = Compare_Less);
+ virtual void SetProjection(const Matrix4f& proj);
+ virtual void SetWorldUniforms(const Matrix4f& proj);
+ // The index 0 is reserved for non-buffer uniforms, and so cannot be used with this function.
+ virtual void SetCommonUniformBuffer(int i, Buffer* buffer);
// The data is not copied, it must remain valid until the end of the frame
virtual void SetLighting(const LightingParams* light);
- // The index 0 is reserved for non-buffer uniforms, and so cannot be used with this function.
- virtual void SetCommonUniformBuffer(int i, Buffer* buffer) { OVR_UNUSED2(i, buffer); }
-
virtual Matrix4f GetProjection() const { return Proj; }
// This is a View matrix only, it will be combined with the projection matrix from SetProjection
- virtual void Render(const Matrix4f& matrix, Model* model) = 0;
- // offset is in bytes; indices can be null.
+ virtual void Render(const Matrix4f& view, Model* model);
+ virtual void Render(const ShaderFill* fill, Buffer* vertices, Buffer* indices);
virtual void Render(const ShaderFill* fill, Buffer* vertices, Buffer* indices,
- const Matrix4f& matrix, int offset, int count, PrimitiveType prim = Prim_Triangles) = 0;
+ const Matrix4f& matrix, int offset, int count, PrimitiveType prim = Prim_Triangles, bool updateUniformData = true);
- virtual ShaderFill *CreateSimpleFill() = 0;
+ virtual ShaderFill *CreateSimpleFill() { return DefaultFill; }
ShaderFill * CreateTextureFill(Texture* tex);
-
- // Don't call these directly, use App/Platform instead
- virtual bool SetFullscreen(DisplayMode fullscreen) { OVR_UNUSED(fullscreen); return false; }
-
-
- enum PostProcessShader
- {
- PostProcessShader_Distortion = 0,
- PostProcessShader_DistortionAndChromAb = 1,
- PostProcessShader_Count
- };
-
- PostProcessShader GetPostProcessShader()
- {
- return PostProcessShaderActive;
- }
+ virtual ShaderBase *LoadBuiltinShader(ShaderStage stage, int shader);
- void SetPostProcessShader(PostProcessShader newShader)
- {
- PostProcessShaderRequested = newShader;
- }
+ bool RecreateSwapChain();
+ virtual ID3D10Blob* CompileShader(const char* profile, const char* src, const char* mainName = "main");
+
+ ID3D11SamplerState* GetSamplerState(int sm);
-protected:
- // Stereo & post-processing
- virtual bool initPostProcessSupport(PostProcessType pptype);
-
-private:
- PostProcessShader PostProcessShaderRequested;
- PostProcessShader PostProcessShaderActive;
+ void SetTexture(ShaderStage stage, int slot, const Texture* t);
};
int GetNumMipLevels(int w, int h);
@@ -719,6 +813,12 @@ int GetNumMipLevels(int w, int h);
// Image size must be a power of 2.
void FilterRgba2x2(const UByte* src, int w, int h, UByte* dest);
-}} // OVR::RenderTiny
+}}
+
+
+//Anything including this file, uses these
+using namespace OVR;
+using namespace OVR::RenderTiny;
+
#endif
diff --git a/Samples/OculusRoomTiny/RenderTiny_D3D1X_Device.h b/Samples/OculusRoomTiny/RenderTiny_D3D1X_Device.h
deleted file mode 100644
index 1438611..0000000
--- a/Samples/OculusRoomTiny/RenderTiny_D3D1X_Device.h
+++ /dev/null
@@ -1,273 +0,0 @@
-/************************************************************************************
-
-Filename : RenderTiny_D3D1X_Device.h
-Content : RenderDevice implementation header for D3DX10.
-Created : September 10, 2012
-Authors : Andrew Reisse
-
-Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-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 INC_RenderTiny_D3D1X_Device_h
-#define INC_RenderTiny_D3D1X_Device_h
-
-#include "Kernel/OVR_String.h"
-#include "Kernel/OVR_Array.h"
-
-#include "RenderTiny_Device.h"
-#include <Windows.h>
-
-#define _OVR_RENDERER_D3D10
-#include <d3d10.h>
-
-namespace OVR { namespace RenderTiny { namespace D3D10 {
-
-class RenderDevice;
-class Buffer;
-
-typedef ID3D10Device ID3D1xDevice;
-typedef ID3D10Device ID3D1xDeviceContext;
-typedef ID3D10RenderTargetView ID3D1xRenderTargetView;
-typedef ID3D10Texture2D ID3D1xTexture2D;
-typedef ID3D10ShaderResourceView ID3D1xShaderResourceView;
-typedef ID3D10DepthStencilView ID3D1xDepthStencilView;
-typedef ID3D10DepthStencilState ID3D1xDepthStencilState;
-typedef ID3D10InputLayout ID3D1xInputLayout;
-typedef ID3D10Buffer ID3D1xBuffer;
-typedef ID3D10VertexShader ID3D1xVertexShader;
-typedef ID3D10PixelShader ID3D1xPixelShader;
-typedef ID3D10GeometryShader ID3D1xGeometryShader;
-typedef ID3D10BlendState ID3D1xBlendState;
-typedef ID3D10RasterizerState ID3D1xRasterizerState;
-typedef ID3D10SamplerState ID3D1xSamplerState;
-typedef ID3D10Query ID3D1xQuery;
-typedef ID3D10Blob ID3D1xBlob;
-typedef D3D10_VIEWPORT D3D1x_VIEWPORT;
-typedef D3D10_QUERY_DESC D3D1x_QUERY_DESC;
-#define D3D1x_(x) D3D10_##x
-#define ID3D1x(x) ID3D10##x
-
-
-
-class ShaderBase : public RenderTiny::Shader
-{
-public:
- RenderDevice* Ren;
- unsigned char* UniformData;
- int UniformsSize;
-
- struct Uniform
- {
- String Name;
- int Offset, Size;
- };
- Array<Uniform> UniformInfo;
-
- ShaderBase(RenderDevice* r, ShaderStage stage);
- ~ShaderBase();
-
- void InitUniforms(ID3D10Blob* s);
- bool SetUniform(const char* name, int n, const float* v);
-
- void UpdateBuffer(Buffer* b);
-};
-
-template<RenderTiny::ShaderStage SStage, class D3DShaderType>
-class Shader : public ShaderBase
-{
-public:
- D3DShaderType* D3DShader;
-
- Shader(RenderDevice* r, D3DShaderType* s) : ShaderBase(r, SStage), D3DShader(s) {}
- Shader(RenderDevice* r, ID3D1xBlob* s) : ShaderBase(r, SStage)
- {
- Load(s);
- InitUniforms(s);
- }
- ~Shader()
- {
- if (D3DShader)
- D3DShader->Release();
- }
- bool Load(ID3D1xBlob* shader)
- {
- return Load(shader->GetBufferPointer(), shader->GetBufferSize());
- }
-
- // These functions have specializations.
- bool Load(void* shader, size_t size);
- void Set(PrimitiveType prim) const;
- void SetUniformBuffer(RenderTiny::Buffer* buffers, int i = 0);
-};
-
-typedef Shader<RenderTiny::Shader_Vertex, ID3D1xVertexShader> VertexShader;
-typedef Shader<RenderTiny::Shader_Fragment, ID3D1xPixelShader> PixelShader;
-
-
-class Buffer : public RenderTiny::Buffer
-{
-public:
- RenderDevice* Ren;
- Ptr<ID3D1xBuffer> D3DBuffer;
- size_t Size;
- int Use;
- bool Dynamic;
-
-public:
- Buffer(RenderDevice* r) : Ren(r), Size(0), Use(0) {}
- ~Buffer();
-
- ID3D1xBuffer* GetBuffer()
- {
- return D3DBuffer;
- }
-
- virtual size_t GetSize()
- {
- return Size;
- }
- virtual void* Map(size_t start, size_t size, int flags = 0);
- virtual bool Unmap(void *m);
- virtual bool Data(int use, const void* buffer, size_t size);
-};
-
-class Texture : public RenderTiny::Texture
-{
-public:
- RenderDevice* Ren;
- Ptr<ID3D1xTexture2D> Tex;
- Ptr<ID3D1xShaderResourceView> TexSv;
- Ptr<ID3D1xRenderTargetView> TexRtv;
- Ptr<ID3D1xDepthStencilView> TexDsv;
- mutable Ptr<ID3D1xSamplerState> Sampler;
- int Width, Height;
- int Samples;
-
- Texture(RenderDevice* r, int fmt, int w, int h);
- ~Texture();
-
- virtual int GetWidth() const
- {
- return Width;
- }
- virtual int GetHeight() const
- {
- return Height;
- }
- virtual int GetSamples() const
- {
- return Samples;
- }
-
- virtual void SetSampleMode(int sm);
-
- virtual void Set(int slot, RenderTiny::ShaderStage stage = RenderTiny::Shader_Fragment) const;
-};
-
-class RenderDevice : public RenderTiny::RenderDevice
-{
-public:
- Ptr<IDXGIFactory> DXGIFactory;
- HWND Window;
-
- Ptr<ID3D1xDevice> Device;
- Ptr<ID3D1xDeviceContext> Context;
- Ptr<IDXGISwapChain> SwapChain;
- Ptr<IDXGIAdapter> Adapter;
- Ptr<IDXGIOutput> FullscreenOutput;
- int FSDesktopX, FSDesktopY;
-
- Ptr<ID3D1xTexture2D> BackBuffer;
- Ptr<ID3D1xRenderTargetView> BackBufferRT;
- Ptr<Texture> CurRenderTarget;
- Ptr<Texture> CurDepthBuffer;
- Ptr<ID3D1xRasterizerState> Rasterizer;
- Ptr<ID3D1xBlendState> BlendState;
- D3D1x_VIEWPORT D3DViewport;
-
- Ptr<ID3D1xDepthStencilState> DepthStates[1 + 2 * Compare_Count];
- Ptr<ID3D1xDepthStencilState> CurDepthState;
- Ptr<ID3D1xInputLayout> ModelVertexIL;
-
- Ptr<ID3D1xSamplerState> SamplerStates[Sample_Count];
-
- struct StandardUniformData
- {
- Matrix4f Proj;
- Matrix4f View;
- } StdUniforms;
- Ptr<Buffer> UniformBuffers[Shader_Count];
- int MaxTextureSet[Shader_Count];
-
- Ptr<VertexShader> VertexShaders[VShader_Count];
- Ptr<PixelShader> PixelShaders[FShader_Count];
- Ptr<Buffer> CommonUniforms[8];
- Ptr<ShaderFill> DefaultFill;
-
- Ptr<Buffer> QuadVertexBuffer;
-
- Array<Ptr<Texture> > DepthBuffers;
-
-public:
- RenderDevice(const RendererParams& p, HWND window);
- ~RenderDevice();
-
- // Implement static initializer function to create this class.
- static RenderTiny::RenderDevice* CreateDevice(const RendererParams& rp, void* oswnd);
-
- void UpdateMonitorOutputs();
-
- virtual void SetRealViewport(const Viewport& vp);
- virtual bool SetParams(const RendererParams& newParams);
-
- virtual void Present();
- virtual void ForceFlushGPU();
-
- virtual bool SetFullscreen(DisplayMode fullscreen);
-
- virtual void Clear(float r = 0, float g = 0, float b = 0, float a = 1, float depth = 1);
-
- virtual Buffer* CreateBuffer();
- virtual Texture* CreateTexture(int format, int width, int height, const void* data, int mipcount=1);
-
- Texture* GetDepthBuffer(int w, int h, int ms);
-
- virtual void BeginRendering();
- virtual void SetRenderTarget(RenderTiny::Texture* color,
- RenderTiny::Texture* depth = NULL, RenderTiny::Texture* stencil = NULL);
- virtual void SetDepthMode(bool enable, bool write, CompareFunc func = Compare_Less);
- virtual void SetWorldUniforms(const Matrix4f& proj);
- virtual void SetCommonUniformBuffer(int i, RenderTiny::Buffer* buffer);
-
- virtual void Render(const Matrix4f& matrix, Model* model);
- virtual void Render(const ShaderFill* fill, RenderTiny::Buffer* vertices, RenderTiny::Buffer* indices,
- const Matrix4f& matrix, int offset, int count, PrimitiveType prim = Prim_Triangles);
-
- virtual ShaderFill *CreateSimpleFill() { return DefaultFill; }
-
- virtual RenderTiny::Shader *LoadBuiltinShader(ShaderStage stage, int shader);
-
- bool RecreateSwapChain();
- virtual ID3D10Blob* CompileShader(const char* profile, const char* src, const char* mainName = "main");
-
- ID3D1xSamplerState* GetSamplerState(int sm);
-
- void SetTexture(RenderTiny::ShaderStage stage, int slot, const Texture* t);
-};
-
-}}} // Render::D3D10
-
-#endif
diff --git a/Samples/OculusRoomTiny/RenderTiny_Device.cpp b/Samples/OculusRoomTiny/RenderTiny_Device.cpp
deleted file mode 100644
index 2c363c2..0000000
--- a/Samples/OculusRoomTiny/RenderTiny_Device.cpp
+++ /dev/null
@@ -1,442 +0,0 @@
-/************************************************************************************
-
-Filename : RenderTiny_Device.cpp
-Content : Platform renderer for simple scene graph - implementation
-Created : September 6, 2012
-Authors : Andrew Reisse
-
-Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-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.
-
-************************************************************************************/
-
-#include "RenderTiny_Device.h"
-
-#include "Kernel/OVR_Log.h"
-
-namespace OVR { namespace RenderTiny {
-
-void Model::Render(const Matrix4f& ltw, RenderDevice* ren)
-{
- if (Visible)
- {
- Matrix4f m = ltw * GetMatrix();
- ren->Render(m, this);
- }
-}
-
-void Container::Render(const Matrix4f& ltw, RenderDevice* ren)
-{
- Matrix4f m = ltw * GetMatrix();
- for(unsigned i = 0; i < Nodes.GetSize(); i++)
- {
- Nodes[i]->Render(m, ren);
- }
-}
-
-void Scene::Render(RenderDevice* ren, const Matrix4f& view)
-{
- Lighting.Update(view, LightPos);
-
- ren->SetLighting(&Lighting);
-
- World.Render(view, ren);
-}
-
-
-
-UInt16 CubeIndices[] =
-{
- 0, 1, 3,
- 3, 1, 2,
-
- 5, 4, 6,
- 6, 4, 7,
-
- 8, 9, 11,
- 11, 9, 10,
-
- 13, 12, 14,
- 14, 12, 15,
-
- 16, 17, 19,
- 19, 17, 18,
-
- 21, 20, 22,
- 22, 20, 23
-};
-
-
-void Model::AddSolidColorBox(float x1, float y1, float z1,
- float x2, float y2, float z2,
- Color c)
-{
- float t;
-
- if(x1 > x2)
- {
- t = x1;
- x1 = x2;
- x2 = t;
- }
- if(y1 > y2)
- {
- t = y1;
- y1 = y2;
- y2 = t;
- }
- if(z1 > z2)
- {
- t = z1;
- z1 = z2;
- z2 = t;
- }
-
- // Cube vertices and their normals.
- Vector3f CubeVertices[][3] =
- {
- Vector3f(x1, y2, z1), Vector3f(z1, x1), Vector3f(0.0f, 1.0f, 0.0f),
- Vector3f(x2, y2, z1), Vector3f(z1, x2), Vector3f(0.0f, 1.0f, 0.0f),
- Vector3f(x2, y2, z2), Vector3f(z2, x2), Vector3f(0.0f, 1.0f, 0.0f),
- Vector3f(x1, y2, z2), Vector3f(z2, x1), Vector3f(0.0f, 1.0f, 0.0f),
-
- Vector3f(x1, y1, z1), Vector3f(z1, x1), Vector3f(0.0f, -1.0f, 0.0f),
- Vector3f(x2, y1, z1), Vector3f(z1, x2), Vector3f(0.0f, -1.0f, 0.0f),
- Vector3f(x2, y1, z2), Vector3f(z2, x2), Vector3f(0.0f, -1.0f, 0.0f),
- Vector3f(x1, y1, z2), Vector3f(z2, x1), Vector3f(0.0f, -1.0f, 0.0f),
-
- Vector3f(x1, y1, z2), Vector3f(z2, y1), Vector3f(-1.0f, 0.0f, 0.0f),
- Vector3f(x1, y1, z1), Vector3f(z1, y1), Vector3f(-1.0f, 0.0f, 0.0f),
- Vector3f(x1, y2, z1), Vector3f(z1, y2), Vector3f(-1.0f, 0.0f, 0.0f),
- Vector3f(x1, y2, z2), Vector3f(z2, y2), Vector3f(-1.0f, 0.0f, 0.0f),
-
- Vector3f(x2, y1, z2), Vector3f(z2, y1), Vector3f(1.0f, 0.0f, 0.0f),
- Vector3f(x2, y1, z1), Vector3f(z1, y1), Vector3f(1.0f, 0.0f, 0.0f),
- Vector3f(x2, y2, z1), Vector3f(z1, y2), Vector3f(1.0f, 0.0f, 0.0f),
- Vector3f(x2, y2, z2), Vector3f(z2, y2), Vector3f(1.0f, 0.0f, 0.0f),
-
- Vector3f(x1, y1, z1), Vector3f(x1, y1), Vector3f(0.0f, 0.0f, -1.0f),
- Vector3f(x2, y1, z1), Vector3f(x2, y1), Vector3f(0.0f, 0.0f, -1.0f),
- Vector3f(x2, y2, z1), Vector3f(x2, y2), Vector3f(0.0f, 0.0f, -1.0f),
- Vector3f(x1, y2, z1), Vector3f(x1, y2), Vector3f(0.0f, 0.0f, -1.0f),
-
- Vector3f(x1, y1, z2), Vector3f(x1, y1), Vector3f(0.0f, 0.0f, 1.0f),
- Vector3f(x2, y1, z2), Vector3f(x2, y1), Vector3f(0.0f, 0.0f, 1.0f),
- Vector3f(x2, y2, z2), Vector3f(x2, y2), Vector3f(0.0f, 0.0f, 1.0f),
- Vector3f(x1, y2, z2), Vector3f(x1, y2), Vector3f(0.0f, 0.0f, 1.0f)
- };
-
-
- UInt16 startIndex = GetNextVertexIndex();
-
- enum
- {
- CubeVertexCount = sizeof(CubeVertices) / sizeof(CubeVertices[0]),
- CubeIndexCount = sizeof(CubeIndices) / sizeof(CubeIndices[0])
- };
-
- for(int v = 0; v < CubeVertexCount; v++)
- {
- AddVertex(Vertex(CubeVertices[v][0], c, CubeVertices[v][1].x, CubeVertices[v][1].y, CubeVertices[v][2]));
- }
-
- // Renumber indices
- for(int i = 0; i < CubeIndexCount / 3; i++)
- {
- AddTriangle(CubeIndices[i * 3] + startIndex,
- CubeIndices[i * 3 + 1] + startIndex,
- CubeIndices[i * 3 + 2] + startIndex);
- }
-}
-
-
-//-------------------------------------------------------------------------------------
-
-
-void ShaderFill::Set(PrimitiveType prim) const
-{
- Shaders->Set(prim);
- for(int i = 0; i < 8; i++)
- {
- if(Textures[i])
- {
- Textures[i]->Set(i);
- }
- }
-}
-
-
-
-//-------------------------------------------------------------------------------------
-// ***** Rendering
-
-
-RenderDevice::RenderDevice()
- : CurPostProcess(PostProcess_None),
- SceneColorTexW(0), SceneColorTexH(0),
- SceneRenderScale(1),
- Distortion(1.0f, 0.18f, 0.115f),
- PostProcessShaderActive(PostProcessShader_DistortionAndChromAb)
-{
- PostProcessShaderRequested = PostProcessShaderActive;
-}
-
-ShaderFill* RenderDevice::CreateTextureFill(RenderTiny::Texture* t)
-{
- ShaderSet* shaders = CreateShaderSet();
- shaders->SetShader(LoadBuiltinShader(Shader_Vertex, VShader_MVP));
- shaders->SetShader(LoadBuiltinShader(Shader_Fragment, FShader_Texture));
- ShaderFill* f = new ShaderFill(*shaders);
- f->SetTexture(0, t);
- return f;
-}
-
-void RenderDevice::SetLighting(const LightingParams* lt)
-{
- if (!LightingBuffer)
- LightingBuffer = *CreateBuffer();
-
- LightingBuffer->Data(Buffer_Uniform, lt, sizeof(LightingParams));
- SetCommonUniformBuffer(1, LightingBuffer);
-}
-
-
-
-void RenderDevice::SetSceneRenderScale(float ss)
-{
- SceneRenderScale = ss;
- pSceneColorTex = NULL;
-}
-
-void RenderDevice::SetViewport(const Viewport& vp)
-{
- VP = vp;
-
- if (CurPostProcess == PostProcess_Distortion)
- {
- Viewport svp = vp;
- svp.w = (int)ceil(SceneRenderScale * vp.w);
- svp.h = (int)ceil(SceneRenderScale * vp.h);
- svp.x = (int)ceil(SceneRenderScale * vp.x);
- svp.y = (int)ceil(SceneRenderScale * vp.y);
- SetRealViewport(svp);
- }
- else
- {
- SetRealViewport(vp);
- }
-}
-
-
-bool RenderDevice::initPostProcessSupport(PostProcessType pptype)
-{
- if (pptype != PostProcess_Distortion)
- return true;
-
-
- if (PostProcessShaderRequested != PostProcessShaderActive)
- {
- pPostProcessShader.Clear();
- PostProcessShaderActive = PostProcessShaderRequested;
- }
-
- if (!pPostProcessShader)
- {
- Shader *vs = LoadBuiltinShader(Shader_Vertex, VShader_PostProcess);
-
- Shader *ppfs = NULL;
- if (PostProcessShaderActive == PostProcessShader_Distortion)
- {
- ppfs = LoadBuiltinShader(Shader_Fragment, FShader_PostProcess);
- }
- else if (PostProcessShaderActive == PostProcessShader_DistortionAndChromAb)
- {
- ppfs = LoadBuiltinShader(Shader_Fragment, FShader_PostProcessWithChromAb);
- }
- else
- OVR_ASSERT(false);
-
- pPostProcessShader = *CreateShaderSet();
- pPostProcessShader->SetShader(vs);
- pPostProcessShader->SetShader(ppfs);
- }
-
-
- int texw = (int)ceil(SceneRenderScale * WindowWidth),
- texh = (int)ceil(SceneRenderScale * WindowHeight);
-
- // If pSceneColorTex is already created and is of correct size, we are done.
- // It's important to check width/height in case window size changed.
- if (pSceneColorTex && (texw == SceneColorTexW) && (texh == SceneColorTexH))
- {
- return true;
- }
-
- pSceneColorTex = *CreateTexture(Texture_RGBA | Texture_RenderTarget | Params.Multisample,
- texw, texh, NULL);
- if (!pSceneColorTex)
- {
- return false;
- }
- SceneColorTexW = texw;
- SceneColorTexH = texh;
- pSceneColorTex->SetSampleMode(Sample_ClampBorder | Sample_Linear);
-
-
- if (!pFullScreenVertexBuffer)
- {
- pFullScreenVertexBuffer = *CreateBuffer();
- const RenderTiny::Vertex QuadVertices[] =
- {
- Vertex(Vector3f(0, 1, 0), Color(1, 1, 1, 1), 0, 0),
- Vertex(Vector3f(1, 1, 0), Color(1, 1, 1, 1), 1, 0),
- Vertex(Vector3f(0, 0, 0), Color(1, 1, 1, 1), 0, 1),
- Vertex(Vector3f(1, 0, 0), Color(1, 1, 1, 1), 1, 1)
- };
- pFullScreenVertexBuffer->Data(Buffer_Vertex, QuadVertices, sizeof(QuadVertices));
- }
- return true;
-}
-
-void RenderDevice::SetProjection(const Matrix4f& proj)
-{
- Proj = proj;
- SetWorldUniforms(proj);
-}
-
-void RenderDevice::BeginScene(PostProcessType pptype)
-{
- BeginRendering();
-
- if ((pptype != PostProcess_None) && initPostProcessSupport(pptype))
- {
- CurPostProcess = pptype;
- }
- else
- {
- CurPostProcess = PostProcess_None;
- }
-
- if (CurPostProcess == PostProcess_Distortion)
- {
- SetRenderTarget(pSceneColorTex);
- SetViewport(VP);
- }
- else
- {
- SetRenderTarget(0);
- }
-
- SetWorldUniforms(Proj);
-}
-
-void RenderDevice::FinishScene()
-{
- if (CurPostProcess == PostProcess_None)
- return;
-
- SetRenderTarget(0);
- SetRealViewport(VP);
- FinishScene1();
-
- CurPostProcess = PostProcess_None;
-}
-
-
-
-void RenderDevice::FinishScene1()
-{
- // Clear with black
- Clear(0.0f, 0.0f, 0.0f, 1.0f);
-
- float w = float(VP.w) / float(WindowWidth),
- h = float(VP.h) / float(WindowHeight),
- x = float(VP.x) / float(WindowWidth),
- y = float(VP.y) / float(WindowHeight);
-
- float as = float(VP.w) / float(VP.h);
-
- // We are using 1/4 of DistortionCenter offset value here, since it is
- // relative to [-1,1] range that gets mapped to [0, 0.5].
- pPostProcessShader->SetUniform2f("LensCenter",
- x + (w + Distortion.XCenterOffset * 0.5f)*0.5f, y + h*0.5f);
- pPostProcessShader->SetUniform2f("ScreenCenter", x + w*0.5f, y + h*0.5f);
-
- // MA: This is more correct but we would need higher-res texture vertically; we should adopt this
- // once we have asymmetric input texture scale.
- float scaleFactor = 1.0f / Distortion.Scale;
-
- pPostProcessShader->SetUniform2f("Scale", (w/2) * scaleFactor, (h/2) * scaleFactor * as);
- pPostProcessShader->SetUniform2f("ScaleIn", (2/w), (2/h) / as);
-
- pPostProcessShader->SetUniform4f("HmdWarpParam",
- Distortion.K[0], Distortion.K[1], Distortion.K[2], Distortion.K[3]);
-
- if (PostProcessShaderRequested == PostProcessShader_DistortionAndChromAb)
- {
- pPostProcessShader->SetUniform4f("ChromAbParam",
- Distortion.ChromaticAberration[0],
- Distortion.ChromaticAberration[1],
- Distortion.ChromaticAberration[2],
- Distortion.ChromaticAberration[3]);
- }
-
- Matrix4f texm(w, 0, 0, x,
- 0, h, 0, y,
- 0, 0, 0, 0,
- 0, 0, 0, 1);
- pPostProcessShader->SetUniform4x4f("Texm", texm);
-
- Matrix4f view(2, 0, 0, -1,
- 0, 2, 0, -1,
- 0, 0, 0, 0,
- 0, 0, 0, 1);
-
- ShaderFill fill(pPostProcessShader);
- fill.SetTexture(0, pSceneColorTex);
- Render(&fill, pFullScreenVertexBuffer, NULL, view, 0, 4, Prim_TriangleStrip);
-}
-
-
-int GetNumMipLevels(int w, int h)
-{
- int n = 1;
- while(w > 1 || h > 1)
- {
- w >>= 1;
- h >>= 1;
- n++;
- }
- return n;
-}
-
-void FilterRgba2x2(const UByte* src, int w, int h, UByte* dest)
-{
- for(int j = 0; j < (h & ~1); j += 2)
- {
- const UByte* psrc = src + (w * j * 4);
- UByte* pdest = dest + ((w >> 1) * (j >> 1) * 4);
-
- for(int i = 0; i < w >> 1; i++, psrc += 8, pdest += 4)
- {
- pdest[0] = (((int)psrc[0]) + psrc[4] + psrc[w * 4 + 0] + psrc[w * 4 + 4]) >> 2;
- pdest[1] = (((int)psrc[1]) + psrc[5] + psrc[w * 4 + 1] + psrc[w * 4 + 5]) >> 2;
- pdest[2] = (((int)psrc[2]) + psrc[6] + psrc[w * 4 + 2] + psrc[w * 4 + 6]) >> 2;
- pdest[3] = (((int)psrc[3]) + psrc[7] + psrc[w * 4 + 3] + psrc[w * 4 + 7]) >> 2;
- }
- }
-}
-
-
-}}
diff --git a/Samples/OculusRoomTiny/RenderTiny_GL_Device.cpp b/Samples/OculusRoomTiny/RenderTiny_GL_Device.cpp
deleted file mode 100644
index 07460c3..0000000
--- a/Samples/OculusRoomTiny/RenderTiny_GL_Device.cpp
+++ /dev/null
@@ -1,784 +0,0 @@
-/************************************************************************************
-
-Filename : RenderTiny_GL_Device.cpp
-Content : RenderDevice implementation for OpenGL (tiny version)
-Created : September 10, 2012
-Authors : Andrew Reisse, Artem Bolgar
-
-Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-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.
-
-************************************************************************************/
-
-#include "RenderTiny_GL_Device.h"
-#include "Kernel/OVR_Log.h"
-
-namespace OVR { namespace RenderTiny { namespace GL {
-
-
-
-static const char* StdVertexShaderSrc =
- "uniform mat4 Proj;\n"
- "uniform mat4 View;\n"
- "attribute vec4 Position;\n"
- "attribute vec4 Color;\n"
- "attribute vec2 TexCoord;\n"
- "attribute vec3 Normal;\n"
- "varying vec4 oColor;\n"
- "varying vec2 oTexCoord;\n"
- "varying vec3 oNormal;\n"
- "varying vec3 oVPos;\n"
- "void main()\n"
- "{\n"
- " gl_Position = Proj * (View * Position);\n"
- " oNormal = vec3(View * vec4(Normal,0));\n"
- " oVPos = vec3(View * Position);\n"
- " oTexCoord = TexCoord;\n"
- " oColor = Color;\n"
- "}\n";
-
-static const char* DirectVertexShaderSrc =
- "uniform mat4 View;\n"
- "attribute vec4 Position;\n"
- "attribute vec4 Color;\n"
- "attribute vec2 TexCoord;\n"
- "attribute vec3 Normal;\n"
- "varying vec4 oColor;\n"
- "varying vec2 oTexCoord;\n"
- "varying vec3 oNormal;\n"
- "void main()\n"
- "{\n"
- " gl_Position = View * Position;\n"
- " oTexCoord = TexCoord;\n"
- " oColor = Color;\n"
- " oNormal = vec3(View * vec4(Normal,0));\n"
- "}\n";
-
-static const char* SolidFragShaderSrc =
- "uniform vec4 Color;\n"
- "void main()\n"
- "{\n"
- " gl_FragColor = Color;\n"
- "}\n";
-
-static const char* GouraudFragShaderSrc =
- "varying vec4 oColor;\n"
- "void main()\n"
- "{\n"
- " gl_FragColor = oColor;\n"
- "}\n";
-
-static const char* TextureFragShaderSrc =
- "uniform sampler2D Texture0;\n"
- "varying vec4 oColor;\n"
- "varying vec2 oTexCoord;\n"
- "void main()\n"
- "{\n"
- " gl_FragColor = oColor * texture2D(Texture0, oTexCoord);\n"
- " if (gl_FragColor.a < 0.4)\n"
- " discard;\n"
- "}\n";
-
-#define LIGHTING_COMMON \
- "uniform vec3 Ambient;\n" \
- "uniform vec4 LightPos[8];\n" \
- "uniform vec4 LightColor[8];\n" \
- "uniform float LightCount;\n" \
- "varying vec4 oColor;\n" \
- "varying vec2 oTexCoord;\n" \
- "varying vec3 oNormal;\n" \
- "varying vec3 oVPos;\n" \
- "vec4 DoLight()\n" \
- "{\n" \
- " vec3 norm = normalize(oNormal);\n" \
- " vec3 light = Ambient;\n" \
- " for (int i = 0; i < int(LightCount); i++)\n" \
- " {\n" \
- " vec3 ltp = (LightPos[i].xyz - oVPos);\n" \
- " float ldist = length(ltp);\n" \
- " ltp = normalize(ltp);\n" \
- " light += clamp(LightColor[i].rgb * oColor.rgb * (dot(norm, ltp) / ldist), 0.0,1.0);\n" \
- " }\n" \
- " return vec4(light, oColor.a);\n" \
- "}\n"
-
-static const char* LitSolidFragShaderSrc =
- LIGHTING_COMMON
- "void main()\n"
- "{\n"
- " gl_FragColor = DoLight() * oColor;\n"
- "}\n";
-
-static const char* LitTextureFragShaderSrc =
- "uniform sampler2D Texture0;\n"
- LIGHTING_COMMON
- "void main()\n"
- "{\n"
- " gl_FragColor = DoLight() * texture2D(Texture0, oTexCoord);\n"
- "}\n";
-
-static const char* PostProcessVertexShaderSrc =
- "uniform mat4 View;\n"
- "uniform mat4 Texm;\n"
- "attribute vec4 Position;\n"
- "attribute vec2 TexCoord;\n"
- "varying vec2 oTexCoord;\n"
- "void main()\n"
- "{\n"
- " gl_Position = View * Position;\n"
- " oTexCoord = vec2(Texm * vec4(TexCoord,0,1));\n"
- " oTexCoord.y = 1.0-oTexCoord.y;\n"
- "}\n";
-
-static const char* PostProcessFragShaderSrc =
- "uniform vec2 LensCenter;\n"
- "uniform vec2 ScreenCenter;\n"
- "uniform vec2 Scale;\n"
- "uniform vec2 ScaleIn;\n"
- "uniform vec4 HmdWarpParam;\n"
- "uniform sampler2D Texture0;\n"
- "varying vec2 oTexCoord;\n"
- "\n"
- "vec2 HmdWarp(vec2 in01)\n"
- "{\n"
- " vec2 theta = (in01 - LensCenter) * ScaleIn;\n" // Scales to [-1, 1]
- " float rSq = theta.x * theta.x + theta.y * theta.y;\n"
- " vec2 theta1 = theta * (HmdWarpParam.x + HmdWarpParam.y * rSq + "
- " HmdWarpParam.z * rSq * rSq + HmdWarpParam.w * rSq * rSq * rSq);\n"
- " return LensCenter + Scale * theta1;\n"
- "}\n"
- "void main()\n"
- "{\n"
- " vec2 tc = HmdWarp(oTexCoord);\n"
- " if (!all(equal(clamp(tc, ScreenCenter-vec2(0.25,0.5), ScreenCenter+vec2(0.25,0.5)), tc)))\n"
- " gl_FragColor = vec4(0);\n"
- " else\n"
- " gl_FragColor = texture2D(Texture0, tc);\n"
- "}\n";
-
-// Shader with lens distortion and chromatic aberration correction.
-static const char* PostProcessFullFragShaderSrc =
- "uniform vec2 LensCenter;\n"
- "uniform vec2 ScreenCenter;\n"
- "uniform vec2 Scale;\n"
- "uniform vec2 ScaleIn;\n"
- "uniform vec4 HmdWarpParam;\n"
- "uniform vec4 ChromAbParam;\n"
- "uniform sampler2D Texture0;\n"
- "varying vec2 oTexCoord;\n"
- "\n"
- // Scales input texture coordinates for distortion.
- // ScaleIn maps texture coordinates to Scales to ([-1, 1]), although top/bottom will be
- // larger due to aspect ratio.
- "void main()\n"
- "{\n"
- " vec2 theta = (oTexCoord - LensCenter) * ScaleIn;\n" // Scales to [-1, 1]
- " float rSq= theta.x * theta.x + theta.y * theta.y;\n"
- " vec2 theta1 = theta * (HmdWarpParam.x + HmdWarpParam.y * rSq + "
- " HmdWarpParam.z * rSq * rSq + HmdWarpParam.w * rSq * rSq * rSq);\n"
- " \n"
- " // Detect whether blue texture coordinates are out of range since these will scaled out the furthest.\n"
- " vec2 thetaBlue = theta1 * (ChromAbParam.z + ChromAbParam.w * rSq);\n"
- " vec2 tcBlue = LensCenter + Scale * thetaBlue;\n"
- " if (!all(equal(clamp(tcBlue, ScreenCenter-vec2(0.25,0.5), ScreenCenter+vec2(0.25,0.5)), tcBlue)))\n"
- " {\n"
- " gl_FragColor = vec4(0);\n"
- " return;\n"
- " }\n"
- " \n"
- " // Now do blue texture lookup.\n"
- " float blue = texture2D(Texture0, tcBlue).b;\n"
- " \n"
- " // Do green lookup (no scaling).\n"
- " vec2 tcGreen = LensCenter + Scale * theta1;\n"
- " vec4 center = texture2D(Texture0, tcGreen);\n"
- " \n"
- " // Do red scale and lookup.\n"
- " vec2 thetaRed = theta1 * (ChromAbParam.x + ChromAbParam.y * rSq);\n"
- " vec2 tcRed = LensCenter + Scale * thetaRed;\n"
- " float red = texture2D(Texture0, tcRed).r;\n"
- " \n"
- " gl_FragColor = vec4(red, center.g, blue, 1);\n"
- "}\n";
-
-static const char* VShaderSrcs[VShader_Count] =
-{
- DirectVertexShaderSrc,
- StdVertexShaderSrc,
- PostProcessVertexShaderSrc
-};
-static const char* FShaderSrcs[FShader_Count] =
-{
- SolidFragShaderSrc,
- GouraudFragShaderSrc,
- TextureFragShaderSrc,
- PostProcessFragShaderSrc,
- PostProcessFullFragShaderSrc,
- LitSolidFragShaderSrc,
- LitTextureFragShaderSrc
-};
-
-
-
-RenderDevice::RenderDevice(const RendererParams& p)
-{
- for (int i = 0; i < VShader_Count; i++)
- VertexShaders[i] = *new Shader(this, Shader_Vertex, VShaderSrcs[i]);
-
- for (int i = 0; i < FShader_Count; i++)
- FragShaders[i] = *new Shader(this, Shader_Fragment, FShaderSrcs[i]);
-
- Ptr<ShaderSet> gouraudShaders = *new ShaderSet();
- gouraudShaders->SetShader(VertexShaders[VShader_MVP]);
- gouraudShaders->SetShader(FragShaders[FShader_Gouraud]);
- DefaultFill = *new ShaderFill(gouraudShaders);
-
- glGenFramebuffersEXT(1, &CurrentFbo);
-}
-
-Shader *RenderDevice::LoadBuiltinShader(ShaderStage stage, int shader)
-{
- switch (stage)
- {
- case Shader_Vertex: return VertexShaders[shader];
- case Shader_Fragment: return FragShaders[shader];
- default:
- return NULL;
- }
-}
-
-
-void RenderDevice::BeginRendering()
-{
- glEnable(GL_DEPTH_TEST);
- glEnable(GL_CULL_FACE);
- glFrontFace(GL_CW);
-
- glLineWidth(3.0f);
- glEnable(GL_LINE_SMOOTH);
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
-}
-
-void RenderDevice::SetDepthMode(bool enable, bool write, CompareFunc func)
-{
- if (enable)
- {
- glEnable(GL_DEPTH_TEST);
- glDepthMask(write);
- switch (func)
- {
- case Compare_Always: glDepthFunc(GL_ALWAYS); break;
- case Compare_Less: glDepthFunc(GL_LESS); break;
- case Compare_Greater: glDepthFunc(GL_GREATER); break;
- default: assert(0);
- }
- }
- else
- glDisable(GL_DEPTH_TEST);
-}
-
-void RenderDevice::SetRealViewport(const Viewport& vp)
-{
- int wh;
- if (CurRenderTarget)
- wh = CurRenderTarget->Height;
- else
- wh = WindowHeight;
- glViewport(vp.x, wh-vp.y-vp.h, vp.w, vp.h);
-
- glEnable(GL_SCISSOR_TEST);
- glScissor(vp.x, wh-vp.y-vp.h, vp.w, vp.h);
-}
-
-void RenderDevice::Clear(float r, float g, float b, float a, float depth)
-{
- glClearColor(r,g,b,a);
- glClearDepth(depth);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
-}
-
-RBuffer* RenderDevice::GetDepthBuffer(int w, int h, int ms)
-{
- for (unsigned i = 0; i < DepthBuffers.GetSize(); i++)
- if (w == DepthBuffers[i]->Width && h == DepthBuffers[i]->Height)// && ms == DepthBuffers[i]->Samples)
- return DepthBuffers[i];
-
- //Ptr<Texture> newDepth = *CreateTexture(Texture_Depth|Texture_RenderTarget|ms, w, h, NULL);
- Ptr<RBuffer> newDepth = *new RBuffer(GL_DEPTH24_STENCIL8, w, h); // combined depth stencil
- DepthBuffers.PushBack(newDepth);
- return newDepth.GetPtr();
-}
-
-void RenderDevice::SetRenderTarget(RenderTiny::Texture* color, RenderTiny::Texture*, RenderTiny::Texture* stencil)
-{
- OVR_UNUSED(stencil);
-
- CurRenderTarget = (Texture*)color;
- if (color == NULL)
- {
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- return;
- }
- //if (depth == NULL)
- RBuffer* depth = GetDepthBuffer(color->GetWidth(), color->GetHeight(), 0); //CurRenderTarget->Samples);
-
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, CurrentFbo);
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, ((Texture*)color)->TexId, 0);
- if (depth)
- //glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, ((Texture*)depth)->TexId, 0);
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, ((RBuffer*)depth)->BufId);
- else
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0);
-
- GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
- if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
- OVR_DEBUG_LOG(("framebuffer not complete: %x", status));
-}
-
-
-void RenderDevice::SetWorldUniforms(const Matrix4f& proj)
-{
- Proj = proj.Transposed();
-}
-
-void RenderDevice::SetTexture(RenderTiny::ShaderStage, int slot, const Texture* t)
-{
- glActiveTexture(GL_TEXTURE0 + slot);
- glBindTexture(GL_TEXTURE_2D, ((Texture*)t)->TexId);
- glActiveTexture(GL_TEXTURE0);
-}
-
-Buffer* RenderDevice::CreateBuffer()
-{
- return new Buffer(this);
-}
-
-void RenderDevice::Render(const Matrix4f& matrix, Model* model)
-{
- // Store data in buffers if not already
- if (!model->VertexBuffer)
- {
- Ptr<RenderTiny::Buffer> vb = *CreateBuffer();
- vb->Data(Buffer_Vertex, &model->Vertices[0], model->Vertices.GetSize() * sizeof(Vertex));
- model->VertexBuffer = vb;
- }
- if (!model->IndexBuffer)
- {
- Ptr<RenderTiny::Buffer> ib = *CreateBuffer();
- ib->Data(Buffer_Index, &model->Indices[0], model->Indices.GetSize() * 2);
- model->IndexBuffer = ib;
- }
-
- Render(model->Fill ? (const ShaderFill*)model->Fill : (const ShaderFill*)DefaultFill,
- model->VertexBuffer, model->IndexBuffer,
- matrix, 0, (int)model->Indices.GetSize(), model->GetPrimType());
-}
-
-void RenderDevice::Render(const ShaderFill* fill, RenderTiny::Buffer* vertices, RenderTiny::Buffer* indices,
- const Matrix4f& matrix, int offset, int count, PrimitiveType rprim)
-{
- ShaderSet* shaders = (ShaderSet*) ((ShaderFill*)fill)->GetShaders();
-
- GLenum prim;
- switch (rprim)
- {
- case Prim_Triangles:
- prim = GL_TRIANGLES;
- break;
- case Prim_Lines:
- prim = GL_LINES;
- break;
- case Prim_TriangleStrip:
- prim = GL_TRIANGLE_STRIP;
- break;
- default:
- assert(0);
- return;
- }
-
- fill->Set();
- if (shaders->ProjLoc >= 0)
- glUniformMatrix4fv(shaders->ProjLoc, 1, 0, &Proj.M[0][0]);
- if (shaders->ViewLoc >= 0)
- glUniformMatrix4fv(shaders->ViewLoc, 1, 0, &matrix.Transposed().M[0][0]);
-
- if (shaders->UsesLighting && Lighting->Version != shaders->LightingVer)
- {
- shaders->LightingVer = Lighting->Version;
- Lighting->Set(shaders);
- }
-
- glBindBuffer(GL_ARRAY_BUFFER, ((Buffer*)vertices)->GLBuffer);
- for (int i = 0; i < 4; i++)
- glEnableVertexAttribArray(i);
-
- glVertexAttribPointer(0, 3, GL_FLOAT, false, sizeof(Vertex), (char*)offset + offsetof(Vertex, Pos));
- glVertexAttribPointer(1, 4, GL_UNSIGNED_BYTE, true, sizeof(Vertex), (char*)offset + offsetof(Vertex, C));
- glVertexAttribPointer(2, 2, GL_FLOAT, false, sizeof(Vertex), (char*)offset + offsetof(Vertex, U));
- glVertexAttribPointer(3, 3, GL_FLOAT, false, sizeof(Vertex), (char*)offset + offsetof(Vertex, Norm));
-
- if (indices)
- {
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ((Buffer*)indices)->GLBuffer);
- glDrawElements(prim, count, GL_UNSIGNED_SHORT, NULL);
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
- }
- else
- {
- glDrawArrays(prim, 0, count);
- }
-
- for (int i = 0; i < 4; i++)
- glDisableVertexAttribArray(i);
-}
-
-void RenderDevice::SetLighting(const LightingParams* lt)
-{
- Lighting = lt;
-}
-
-Buffer::~Buffer()
-{
- if (GLBuffer)
- glDeleteBuffers(1, &GLBuffer);
-}
-
-bool Buffer::Data(int use, const void* buffer, size_t size)
-{
- switch (use & Buffer_TypeMask)
- {
- case Buffer_Index: Use = GL_ELEMENT_ARRAY_BUFFER; break;
- default: Use = GL_ARRAY_BUFFER; break;
- }
-
- if (!GLBuffer)
- glGenBuffers(1, &GLBuffer);
-
- int mode = GL_DYNAMIC_DRAW;
- if (use & Buffer_ReadOnly)
- mode = GL_STATIC_DRAW;
-
- glBindBuffer(Use, GLBuffer);
- glBufferData(Use, size, buffer, mode);
- glBindBuffer(Use, 0);
- return 1;
-}
-
-void* Buffer::Map(size_t start, size_t size, int flags)
-{
- int mode = GL_WRITE_ONLY;
- //if (flags & Map_Unsynchronized)
- // mode |= GL_MAP_UNSYNCHRONIZED;
-
- glBindBuffer(Use, GLBuffer);
- void* v = glMapBuffer(Use, mode);
- glBindBuffer(Use, 0);
- return v;
-}
-
-bool Buffer::Unmap(void*)
-{
- glBindBuffer(Use, GLBuffer);
- int r = glUnmapBuffer(Use);
- glBindBuffer(Use, 0);
- return r;
-}
-
-bool Shader::Compile(const char* src)
-{
- if (!GLShader)
- GLShader = glCreateShader(GLStage());
-
- glShaderSource(GLShader, 1, &src, 0);
- glCompileShader(GLShader);
- GLint r;
- glGetShaderiv(GLShader, GL_COMPILE_STATUS, &r);
- if (!r)
- {
- GLchar msg[1024];
- glGetShaderInfoLog(GLShader, sizeof(msg), 0, msg);
- if (msg[0])
- OVR_DEBUG_LOG(("Compiling shader\n%s\nfailed: %s\n", src, msg));
- if (!r)
- return 0;
- }
- return 1;
-}
-
-ShaderSet::ShaderSet()
-{
- Prog = glCreateProgram();
-}
-ShaderSet::~ShaderSet()
-{
- glDeleteProgram(Prog);
-}
-
-bool ShaderSet::Link()
-{
- glBindAttribLocation(Prog, 0, "Position");
- glBindAttribLocation(Prog, 1, "Color");
- glBindAttribLocation(Prog, 2, "TexCoord");
- glBindAttribLocation(Prog, 3, "Normal");
-
- glLinkProgram(Prog);
- GLint r;
- glGetProgramiv(Prog, GL_LINK_STATUS, &r);
- if (!r)
- {
- GLchar msg[1024];
- glGetProgramInfoLog(Prog, sizeof(msg), 0, msg);
- OVR_DEBUG_LOG(("Linking shaders failed: %s\n", msg));
- if (!r)
- return 0;
- }
- glUseProgram(Prog);
-
- UniformInfo.Clear();
- LightingVer = 0;
- UsesLighting = 0;
- GLuint i = 0;
- for(;; i++)
- {
- GLsizei namelen;
- GLint size = 0;
- GLenum type;
- GLchar name[32];
- glGetActiveUniform(Prog, i, sizeof(name), &namelen, &size, &type, name);
- if (size)
- {
- int l = glGetUniformLocation(Prog, name);
- char *np = name;
- while (*np)
- {
- if (*np == '[')
- *np = 0;
- np++;
- }
- Uniform u;
- u.Name = name;
- u.Location = l;
- u.Size = size;
- switch (type)
- {
- case GL_FLOAT: u.Type = 1; break;
- case GL_FLOAT_VEC2: u.Type = 2; break;
- case GL_FLOAT_VEC3: u.Type = 3; break;
- case GL_FLOAT_VEC4: u.Type = 4; break;
- case GL_FLOAT_MAT4: u.Type = 16; break;
- default:
- continue;
- }
- UniformInfo.PushBack(u);
- if (!strcmp(name, "LightCount"))
- UsesLighting = 1;
- }
- else
- break;
- }
-
- ProjLoc = glGetUniformLocation(Prog, "Proj");
- ViewLoc = glGetUniformLocation(Prog, "View");
- for (int i = 0; i < 8; i++)
- {
- char texv[32];
- sprintf(texv, "Texture%d", i);
- TexLoc[i] = glGetUniformLocation(Prog, texv);
- if (TexLoc[i] < 0)
- break;
-
- glUniform1i(TexLoc[i], i);
- }
- if (UsesLighting)
- OVR_ASSERT(ProjLoc >= 0 && ViewLoc >= 0);
- return 1;
-}
-
-void ShaderSet::Set(PrimitiveType) const
-{
- glUseProgram(Prog);
-}
-
-bool ShaderSet::SetUniform(const char* name, int n, const float* v)
-{
- for (int i = 0; i < UniformInfo.GetSize(); i++)
- if (!strcmp(UniformInfo[i].Name.ToCStr(), name))
- {
- OVR_ASSERT(UniformInfo[i].Location >= 0);
- glUseProgram(Prog);
- switch (UniformInfo[i].Type)
- {
- case 1: glUniform1fv(UniformInfo[i].Location, n, v); break;
- case 2: glUniform2fv(UniformInfo[i].Location, n/2, v); break;
- case 3: glUniform3fv(UniformInfo[i].Location, n/3, v); break;
- case 4: glUniform4fv(UniformInfo[i].Location, n/4, v); break;
- default: OVR_ASSERT(0);
- }
- return 1;
- }
-
- OVR_DEBUG_LOG(("Warning: uniform %s not present in selected shader", name));
- return 0;
-}
-
-bool ShaderSet::SetUniform4x4f(const char* name, const Matrix4f& m)
-{
- for (int i = 0; i < UniformInfo.GetSize(); i++)
- if (!strcmp(UniformInfo[i].Name.ToCStr(), name))
- {
- glUseProgram(Prog);
- glUniformMatrix4fv(UniformInfo[i].Location, 1, 1, &m.M[0][0]);
- return 1;
- }
-
- OVR_DEBUG_LOG(("Warning: uniform %s not present in selected shader", name));
- return 0;
-}
-
-Texture::Texture(RenderDevice* r, int w, int h) : Ren(r), Width(w), Height(h)
-{
- glGenTextures(1, &TexId);
-}
-
-Texture::~Texture()
-{
- if (TexId)
- glDeleteTextures(1, &TexId);
-}
-
-void Texture::Set(int slot, RenderTiny::ShaderStage stage) const
-{
- Ren->SetTexture(stage, slot, this);
-}
-
-void Texture::SetSampleMode(int sm)
-{
- glBindTexture(GL_TEXTURE_2D, TexId);
- switch (sm & Sample_FilterMask)
- {
- case Sample_Linear:
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 0);
- break;
-
- case Sample_Anisotropic:
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 8);
- break;
-
- case Sample_Nearest:
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 0);
- break;
- }
-
- switch (sm & Sample_AddressMask)
- {
- case Sample_Repeat:
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- break;
-
- case Sample_Clamp:
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- break;
-
- case Sample_ClampBorder:
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
- break;
- }
- glBindTexture(GL_TEXTURE_2D, 0);
-}
-
-Texture* RenderDevice::CreateTexture(int format, int width, int height, const void* data, int mipcount)
-{
- GLenum glformat, gltype = GL_UNSIGNED_BYTE;
- switch(format & Texture_TypeMask)
- {
- case Texture_RGBA: glformat = GL_RGBA; break;
- case Texture_Depth: glformat = GL_DEPTH; gltype = GL_DEPTH_COMPONENT; break;
- default:
- return NULL;
- }
- Texture* NewTex = new Texture(this, width, height);
- glBindTexture(GL_TEXTURE_2D, NewTex->TexId);
- glGetError();
-
- glTexImage2D(GL_TEXTURE_2D, 0, glformat, width, height, 0, glformat, gltype, data);
- OVR_ASSERT(!glGetError());
-
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-
- if (format == (Texture_RGBA|Texture_GenMipmaps)) // not render target
- {
- int srcw = width, srch = height;
- int level = 0;
- UByte* mipmaps = NULL;
- do
- {
- level++;
- int mipw = srcw >> 1; if (mipw < 1) mipw = 1;
- int miph = srch >> 1; if (miph < 1) miph = 1;
- if (mipmaps == NULL)
- mipmaps = (UByte*)OVR_ALLOC(mipw * miph * 4);
- FilterRgba2x2(level == 1 ? (const UByte*)data : mipmaps, srcw, srch, mipmaps);
- glTexImage2D(GL_TEXTURE_2D, level, glformat, mipw, miph, 0, glformat, gltype, mipmaps);
- OVR_ASSERT(!glGetError());
- srcw = mipw;
- srch = miph;
- } while (srcw > 1 || srch > 1);
- if (mipmaps)
- OVR_FREE(mipmaps);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, level);
- OVR_ASSERT(!glGetError());
- }
- else
- {
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, mipcount-1);
- OVR_ASSERT(!glGetError());
- }
-
- OVR_ASSERT(!glGetError());
- glBindTexture(GL_TEXTURE_2D, 0);
- return NewTex;
-}
-
-RBuffer::RBuffer(GLenum format, GLint w, GLint h)
-{
- Width = w;
- Height = h;
- glGenRenderbuffersEXT(1, &BufId);
- glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, BufId);
- glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, format, w, h);
- glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
-}
-
-RBuffer::~RBuffer()
-{
- glDeleteRenderbuffersEXT(1, &BufId);
-}
-
-}}}
diff --git a/Samples/OculusRoomTiny/RenderTiny_GL_Device.h b/Samples/OculusRoomTiny/RenderTiny_GL_Device.h
deleted file mode 100644
index 5d88180..0000000
--- a/Samples/OculusRoomTiny/RenderTiny_GL_Device.h
+++ /dev/null
@@ -1,228 +0,0 @@
-/************************************************************************************
-
-Filename : RenderTiny_GL_Device.h
-Content : RenderDevice implementation header for OpenGL (tiny version)
-Created : September 10, 2012
-Authors : Andrew Reisse, Artem Bolgar
-
-Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-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_Render_GL_Device_h
-#define OVR_Render_GL_Device_h
-
-#include "RenderTiny_Device.h"
-
-#if defined(OVR_OS_WIN32)
-#include <Windows.h>
-#endif
-
-#if defined(OVR_OS_MAC)
-#include <OpenGL/gl.h>
-#include <OpenGL/glext.h>
-#else
-#define GL_GLEXT_PROTOTYPES
-#include <GL/gl.h>
-#include <GL/glext.h>
-#endif
-
-namespace OVR { namespace RenderTiny { namespace GL {
-
-class RenderDevice;
-
-class Buffer : public RenderTiny::Buffer
-{
-public:
- RenderDevice* Ren;
- size_t Size;
- GLenum Use;
- GLuint GLBuffer;
-
-public:
- Buffer(RenderDevice* r) : Ren(r), Size(0), Use(0), GLBuffer(0) {}
- ~Buffer();
-
- GLuint GetBuffer() { return GLBuffer; }
-
- virtual size_t GetSize() { return Size; }
- virtual void* Map(size_t start, size_t size, int flags = 0);
- virtual bool Unmap(void *m);
- virtual bool Data(int use, const void* buffer, size_t size);
-};
-
-class Texture : public RenderTiny::Texture
-{
-public:
- RenderDevice* Ren;
- GLuint TexId;
- int Width, Height;
-
- Texture(RenderDevice* r, int w, int h);
- ~Texture();
-
- virtual int GetWidth() const { return Width; }
- virtual int GetHeight() const { return Height; }
-
- virtual void SetSampleMode(int);
-
- virtual void Set(int slot, ShaderStage stage = Shader_Fragment) const;
-};
-
-class Shader : public RenderTiny::Shader
-{
-public:
- GLuint GLShader;
-
- Shader(RenderDevice*, ShaderStage st, GLuint s) : RenderTiny::Shader(st), GLShader(s) {}
- Shader(RenderDevice*, ShaderStage st, const char* src) : RenderTiny::Shader(st), GLShader(0)
- {
- Compile(src);
- }
- ~Shader()
- {
- if (GLShader)
- glDeleteShader(GLShader);
- }
- bool Compile(const char* src);
-
- GLenum GLStage() const
- {
- switch (Stage)
- {
- default: OVR_ASSERT(0); return GL_NONE;
- case Shader_Vertex: return GL_VERTEX_SHADER;
- case Shader_Fragment: return GL_FRAGMENT_SHADER;
- }
- }
-
- //void Set(PrimitiveType prim) const;
- //void SetUniformBuffer(Render::Buffer* buffers, int i = 0);
-};
-
-class ShaderSet : public RenderTiny::ShaderSet
-{
-public:
- GLuint Prog;
-
- struct Uniform
- {
- String Name;
- int Location, Size;
- int Type; // currently number of floats in vector
- };
- Array<Uniform> UniformInfo;
-
- int ProjLoc, ViewLoc;
- int TexLoc[8];
- bool UsesLighting;
- int LightingVer;
-
- ShaderSet();
- ~ShaderSet();
-
- virtual void SetShader(RenderTiny::Shader *s)
- {
- Shaders[s->GetStage()] = s;
- Shader* gls = (Shader*)s;
- glAttachShader(Prog, gls->GLShader);
- if (Shaders[Shader_Vertex] && Shaders[Shader_Fragment])
- Link();
- }
- virtual void UnsetShader(int stage)
- {
- Shader* gls = (Shader*)(RenderTiny::Shader*)Shaders[stage];
- if (gls)
- glDetachShader(Prog, gls->GLShader);
- Shaders[stage] = NULL;
- Link();
- }
-
- virtual void Set(PrimitiveType prim) const;
-
- // Set a uniform (other than the standard matrices). It is undefined whether the
- // uniforms from one shader occupy the same space as those in other shaders
- // (unless a buffer is used, then each buffer is independent).
- virtual bool SetUniform(const char* name, int n, const float* v);
- virtual bool SetUniform4x4f(const char* name, const Matrix4f& m);
-
- bool Link();
-};
-
- class RBuffer : public RefCountBase<RBuffer>
-{
- public:
- int Width, Height;
- GLuint BufId;
-
- RBuffer(GLenum format, GLint w, GLint h);
- ~RBuffer();
-};
-
-class RenderDevice : public RenderTiny::RenderDevice
-{
- Ptr<Shader> VertexShaders[VShader_Count];
- Ptr<Shader> FragShaders[FShader_Count];
-
- Ptr<ShaderFill> DefaultFill;
-
- Matrix4f Proj;
-
- Ptr<Texture> CurRenderTarget;
- Array<Ptr<RBuffer> > DepthBuffers;
- GLuint CurrentFbo;
-
- const LightingParams* Lighting;
-
-
-public:
- RenderDevice(const RendererParams& p);
-
- virtual void SetRealViewport(const Viewport& vp);
-
- //virtual void SetScissor(int x, int y, int w, int h);
-
- virtual void Clear(float r = 0, float g = 0, float b = 0, float a = 1, float depth = 1);
- virtual void Rect(float left, float top, float right, float bottom) { OVR_UNUSED4(left,top,right,bottom); }
-
- virtual void BeginRendering();
- virtual void SetDepthMode(bool enable, bool write, CompareFunc func = Compare_Less);
- virtual void SetWorldUniforms(const Matrix4f& proj);
-
- RBuffer* GetDepthBuffer(int w, int h, int ms);
-
- virtual void SetRenderTarget(RenderTiny::Texture* color,
- RenderTiny::Texture* depth = NULL, RenderTiny::Texture* stencil = NULL);
-
- virtual void SetLighting(const LightingParams* lt);
-
- virtual void Render(const Matrix4f& matrix, Model* model);
- virtual void Render(const ShaderFill* fill, RenderTiny::Buffer* vertices, RenderTiny::Buffer* indices,
- const Matrix4f& matrix, int offset, int count, PrimitiveType prim = Prim_Triangles);
-
- virtual Buffer* CreateBuffer();
- virtual Texture* CreateTexture(int format, int width, int height, const void* data, int mipcount=1);
- virtual ShaderSet* CreateShaderSet() { return new ShaderSet; }
-
- virtual ShaderFill *CreateSimpleFill() { return DefaultFill; }
-
- virtual Shader *LoadBuiltinShader(ShaderStage stage, int shader);
-
- void SetTexture(RenderTiny::ShaderStage, int slot, const Texture* t);
-};
-
-}}}
-
-#endif
diff --git a/Samples/OculusRoomTiny/Win32_DistortionMesh.cpp b/Samples/OculusRoomTiny/Win32_DistortionMesh.cpp
new file mode 100644
index 0000000..3356467
--- /dev/null
+++ b/Samples/OculusRoomTiny/Win32_DistortionMesh.cpp
@@ -0,0 +1,244 @@
+/************************************************************************************
+
+Filename : Win32_DistortionMesh.cpp
+Content : Manual creation and rendering of a distortion mesh
+Created : March 5, 2014
+Authors : Tom Heath, Volga Aksoy
+Copyright : Copyright 2012 Oculus, Inc. All Rights reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+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.
+*************************************************************************************/
+
+//-----------------------------------------------------------------------------------
+// If we decide to do our own rendering, then we need to make sure that
+// we are creating the distortion mesh manually using the data provided by the LibOVR SDK
+
+#include "OVR_CAPI.h"
+#include "RenderTiny_D3D11_Device.h"
+
+//-----------------------------------------------------------------------------------
+
+// Contains render data required to render the distortion mesh with the proper shaders
+// NOTE: For *demostration purposes*, the C-style functions in Win32_OculusRoomTiny.cpp
+// actually render the distortion mesh, while this struct only stores the data in a logical group
+struct DistortionRenderData
+{
+ ShaderSet * Shaders;
+ ID3D11InputLayout * VertexIL;
+ Vector2f UVScaleOffset[2][2];
+ Ptr<Buffer> MeshVBs[2];
+ Ptr<Buffer> MeshIBs[2];
+} DistortionData;
+
+//Format for mesh and shaders
+struct DistortionVertex
+{
+ Vector2f Pos;
+ Vector2f TexR;
+ Vector2f TexG;
+ Vector2f TexB;
+ Color Col;
+};
+static D3D11_INPUT_ELEMENT_DESC DistortionMeshVertexDesc[] =
+{
+ {"Position", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
+ {"TexCoord", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0},
+ {"TexCoord", 1, DXGI_FORMAT_R32G32_FLOAT, 0, 16, D3D11_INPUT_PER_VERTEX_DATA, 0},
+ {"TexCoord", 2, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0},
+ {"Color", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, 32, D3D11_INPUT_PER_VERTEX_DATA, 0},
+};
+
+
+
+void DistortionMeshInit(unsigned distortionCaps, ovrHmd HMD,
+ ovrEyeRenderDesc eyeRenderDesc[2], RenderDevice* pRender)
+{
+ //Generate distortion mesh for each eye
+ for ( int eyeNum = 0; eyeNum < 2; eyeNum++ )
+ {
+ // Allocate & generate distortion mesh vertices.
+ ovrDistortionMesh meshData;
+ ovrHmd_CreateDistortionMesh(HMD, eyeRenderDesc[eyeNum].Desc, distortionCaps,
+ (ovrVector2f* ) DistortionData.UVScaleOffset[eyeNum],
+ &meshData);
+
+ // Now parse the vertex data and create a render ready vertex buffer from it
+ DistortionVertex * pVBVerts = (DistortionVertex*)OVR_ALLOC(
+ sizeof(DistortionVertex) * meshData.VertexCount );
+ DistortionVertex * v = pVBVerts;
+ ovrDistortionVertex * ov = meshData.pVertexData;
+ for ( unsigned vertNum = 0; vertNum < meshData.VertexCount; vertNum++ )
+ {
+ v->Pos.x = ov->Pos.x;
+ v->Pos.y = ov->Pos.y;
+ v->TexR = (*(Vector2f*)&ov->TexR);
+ v->TexG = (*(Vector2f*)&ov->TexG);
+ v->TexB = (*(Vector2f*)&ov->TexB);
+ v->Col.R = v->Col.G = v->Col.B = (OVR::UByte)( ov->VignetteFactor * 255.99f );
+ v->Col.A = (OVR::UByte)( ov->TimeWarpFactor * 255.99f );
+ v++; ov++;
+ }
+ //Register this mesh with the renderer
+ DistortionData.MeshVBs[eyeNum] = *pRender->CreateBuffer();
+ DistortionData.MeshVBs[eyeNum]->Data ( Buffer_Vertex, pVBVerts,
+ sizeof(DistortionVertex) * meshData.VertexCount );
+ DistortionData.MeshIBs[eyeNum] = *pRender->CreateBuffer();
+ DistortionData.MeshIBs[eyeNum]->Data ( Buffer_Index, meshData.pIndexData,
+ sizeof(unsigned short) * meshData.IndexCount );
+
+ OVR_FREE ( pVBVerts );
+ ovrHmd_DestroyDistortionMesh( &meshData );
+ }
+
+ // Pixel shader for the mesh
+ //-------------------------------------------------------------------------------------------
+ const char* pixelShader =
+ "Texture2D Texture : register(t0); \n"
+ "SamplerState Linear : register(s0); \n"
+
+ "float4 main(in float4 oPosition : SV_Position, in float4 oColor : COLOR, \n"
+ " in float2 oTexCoord0 : TEXCOORD0, in float2 oTexCoord1 : TEXCOORD1, \n"
+ " in float2 oTexCoord2 : TEXCOORD2) : SV_Target \n"
+ "{ \n"
+ // 3 samples for fixing chromatic aberrations
+ " float ResultR = Texture.Sample(Linear, oTexCoord0.xy).r; \n"
+ " float ResultG = Texture.Sample(Linear, oTexCoord1.xy).g; \n"
+ " float ResultB = Texture.Sample(Linear, oTexCoord2.xy).b; \n"
+ " return float4(ResultR * oColor.r, ResultG * oColor.g, ResultB * oColor.b, 1.0); \n"
+ "}";
+
+
+ // Choose the vertex shader, according to if you have timewarp enabled
+ if (distortionCaps & ovrDistortion_TimeWarp)
+ { // TIMEWARP
+ //--------------------------------------------------------------------------------------------
+ const char* vertexShader =
+ "float2 EyeToSourceUVScale; \n"
+ "float2 EyeToSourceUVOffset; \n"
+ "float4x4 EyeRotationStart; \n"
+ "float4x4 EyeRotationEnd; \n"
+ "float2 TimewarpTexCoord(float2 TexCoord, float4x4 rotMat) \n"
+ "{ \n"
+ // Vertex inputs are in TanEyeAngle space for the R,G,B channels (i.e. after chromatic
+ // aberration and distortion). These are now "real world" vectors in direction (x,y,1)
+ // relative to the eye of the HMD. Apply the 3x3 timewarp rotation to these vectors.
+ " float3 transformed = float3( mul ( rotMat, float4(TexCoord.xy, 1, 1) ).xyz); \n"
+ // Project them back onto the Z=1 plane of the rendered images.
+ " float2 flattened = (transformed.xy / transformed.z); \n"
+ // Scale them into ([0,0.5],[0,1]) or ([0.5,0],[0,1]) UV lookup space (depending on eye)
+ " return(EyeToSourceUVScale * flattened + EyeToSourceUVOffset); \n"
+ "} \n"
+ "void main(in float2 Position : POSITION, in float4 Color : COLOR0, \n"
+ " in float2 TexCoord0 : TEXCOORD0, in float2 TexCoord1 : TEXCOORD1, \n"
+ " in float2 TexCoord2 : TEXCOORD2, \n"
+ " out float4 oPosition : SV_Position, out float4 oColor : COLOR, \n"
+ " out float2 oTexCoord0 : TEXCOORD0, out float2 oTexCoord1 : TEXCOORD1, \n"
+ " out float2 oTexCoord2 : TEXCOORD2) \n"
+ "{ \n"
+ " float timewarpLerpFactor = Color.a; \n"
+ " float4x4 lerpedEyeRot = lerp(EyeRotationStart, EyeRotationEnd, timewarpLerpFactor);\n"
+ " oTexCoord0 = TimewarpTexCoord(TexCoord0,lerpedEyeRot); \n"
+ " oTexCoord1 = TimewarpTexCoord(TexCoord1,lerpedEyeRot); \n"
+ " oTexCoord2 = TimewarpTexCoord(TexCoord2,lerpedEyeRot); \n"
+ " oPosition = float4(Position.xy, 0.5, 1.0); \n"
+ " oColor = Color.r; /*For vignette fade*/ \n"
+ "}";
+
+ pRender->InitShaders(vertexShader, pixelShader, &DistortionData.Shaders,
+ &DistortionData.VertexIL,DistortionMeshVertexDesc,5);
+ }
+ else
+ {
+ //-------------------------------------------------------------------------------------------
+ const char* vertexShader =
+ "float2 EyeToSourceUVScale; \n"
+ "float2 EyeToSourceUVOffset; \n"
+ "void main(in float2 Position : POSITION, in float4 Color : COLOR0, \n"
+ " in float2 TexCoord0 : TEXCOORD0, in float2 TexCoord1 : TEXCOORD1, \n"
+ " in float2 TexCoord2 : TEXCOORD2, \n"
+ " out float4 oPosition : SV_Position, out float4 oColor : COLOR, \n"
+ " out float2 oTexCoord0 : TEXCOORD0, out float2 oTexCoord1 : TEXCOORD1, \n"
+ " out float2 oTexCoord2 : TEXCOORD2) \n"
+ "{ \n"
+ // Scale them into ([0,0.5],[0,1]) or ([0.5,0],[0,1]) UV lookup space (depending on eye)
+ " oTexCoord0 = EyeToSourceUVScale * TexCoord0 + EyeToSourceUVOffset; \n"
+ " oTexCoord1 = EyeToSourceUVScale * TexCoord1 + EyeToSourceUVOffset; \n"
+ " oTexCoord2 = EyeToSourceUVScale * TexCoord2 + EyeToSourceUVOffset; \n"
+ " oPosition = float4(Position.xy, 0.5, 1.0); \n"
+ " oColor = Color.r; /*For vignette fade*/ \n"
+ "}";
+
+ pRender->InitShaders(vertexShader, pixelShader, &DistortionData.Shaders,
+ &DistortionData.VertexIL,DistortionMeshVertexDesc,5);
+ }
+}
+
+
+void DistortionMeshRender(unsigned distortionCaps, ovrHmd HMD,
+ double timwarpTimePoint, ovrPosef eyeRenderPoses[2],
+ RenderDevice* pRender, Texture* pRendertargetTexture)
+{
+ if (distortionCaps & ovrDistortion_TimeWarp)
+ { // TIMEWARP
+ // Wait till time-warp to reduce latency.
+ ovr_WaitTillTime(timwarpTimePoint);
+ }
+
+ // Clear screen
+ pRender->SetRenderTarget(NULL);
+ pRender->SetFullViewport();
+ pRender->Clear(0.0f, 0.0f, 0.0f, 0.0f);
+
+ // Setup shader
+ ShaderFill distortionShaderFill(DistortionData.Shaders);
+ distortionShaderFill.SetTexture(0, pRendertargetTexture);
+ distortionShaderFill.SetInputLayout(DistortionData.VertexIL);
+
+ for(int eyeNum = 0; eyeNum < 2; eyeNum++)
+ {
+ // Setup shader constants
+ DistortionData.Shaders->SetUniform2f("EyeToSourceUVScale",
+ DistortionData.UVScaleOffset[eyeNum][0].x, DistortionData.UVScaleOffset[eyeNum][0].y);
+ DistortionData.Shaders->SetUniform2f("EyeToSourceUVOffset",
+ DistortionData.UVScaleOffset[eyeNum][1].x, DistortionData.UVScaleOffset[eyeNum][1].y);
+
+ if (distortionCaps & ovrDistortion_TimeWarp)
+ { // TIMEWARP - Additional shader constants required
+ ovrMatrix4f timeWarpMatrices[2];
+ ovrHmd_GetEyeTimewarpMatrices(HMD, (ovrEyeType)eyeNum, eyeRenderPoses[eyeNum], timeWarpMatrices);
+ DistortionData.Shaders->SetUniform4x4f("EyeRotationStart", Matrix4f(timeWarpMatrices[0]));
+ DistortionData.Shaders->SetUniform4x4f("EyeRotationEnd", Matrix4f(timeWarpMatrices[1]));
+ }
+ // Perform distortion
+ pRender->Render(&distortionShaderFill,
+ DistortionData.MeshVBs[eyeNum], DistortionData.MeshIBs[eyeNum]);
+ }
+
+ pRender->SetRenderTarget(NULL);
+}
+
+
+void DistortionMeshRelease(void)
+{
+ for(int eyeNum = 0; eyeNum < 2; eyeNum++)
+ {
+ DistortionData.MeshVBs[eyeNum].Clear();
+ DistortionData.MeshIBs[eyeNum].Clear();
+ }
+ if (DistortionData.Shaders)
+ {
+ DistortionData.Shaders->UnsetShader(Shader_Vertex);
+ DistortionData.Shaders->UnsetShader(Shader_Pixel);
+ }
+}
+
diff --git a/Samples/OculusRoomTiny/Win32_OculusRoomTiny.cpp b/Samples/OculusRoomTiny/Win32_OculusRoomTiny.cpp
index c27723f..5300537 100644
--- a/Samples/OculusRoomTiny/Win32_OculusRoomTiny.cpp
+++ b/Samples/OculusRoomTiny/Win32_OculusRoomTiny.cpp
@@ -1,6 +1,6 @@
/************************************************************************************
-Filename : Win32_OculusRoomTiny.cpp
+Filename : Win32_OculusRoomTiny2.cpp
Content : First-person view test application for Oculus Rift
Created : October 4, 2012
Authors : Michael Antonov, Andrew Reisse
@@ -18,695 +18,273 @@ 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.
-
*************************************************************************************/
-#include "Win32_OculusRoomTiny.h"
-#include "RenderTiny_D3D1X_Device.h"
-
//-------------------------------------------------------------------------------------
-// ***** OculusRoomTiny Class
-
-// Static pApp simplifies routing the window function.
-OculusRoomTinyApp* OculusRoomTinyApp::pApp = 0;
-
-
-OculusRoomTinyApp::OculusRoomTinyApp(HINSTANCE hinst)
- : pRender(0),
- LastUpdate(0),
-
- // Win32
- hWnd(NULL),
- hInstance(hinst), Quit(0), MouseCaptured(true),
- hXInputModule(0), pXInputGetState(0),
-
- // Initial location
- EyePos(0.0f, 1.6f, -5.0f),
- EyeYaw(YawInitial), EyePitch(0), EyeRoll(0),
- LastSensorYaw(0),
- SConfig(),
- PostProcess(PostProcess_Distortion),
- ShiftDown(false),
- ControlDown(false)
-{
- pApp = this;
-
- Width = 1280;
- Height = 800;
-
- StartupTicks = OVR::Timer::GetTicks();
- LastPadPacketNo = 0;
+// This app renders a simple flat-shaded room allowing the user to move along the
+// floor and look around with an HMD and mouse/keyboard.
+// The following keys work:
+// 'W', 'S', 'A', 'D', 'F' - Move forward, back; strafe left/right, toggle freeze in timewarp.
+// The world right handed coordinate system is defined as Y -> Up, Z -> Back, X -> Right
+
+//Include the OculusVR SDK
+#include "OVR_CAPI.h"
+
+// ***** Choices and settings
+
+// Whether the SDK performs rendering/distortion, or the app.
+//#define SDK_RENDER 1
+
+const unsigned DistortionCaps = ovrDistortion_Chromatic | ovrDistortion_TimeWarp;
+const bool VSyncEnabled = true;
+const bool FullScreen = true;
+
+// Include Non-SDK supporting Utilities from other files
+#include "RenderTiny_D3D11_Device.h"
+
+RenderDevice * Util_InitWindowAndGraphics (Recti vp, int fullscreen, int multiSampleCount);
+void Util_ReleaseWindowAndGraphics (RenderDevice* pRender);
+bool Util_RespondToControls (float & EyeYaw, Vector3f & EyePos,
+ float deltaTime, Quatf PoseOrientation);
+void PopulateRoomScene (Scene* scene, RenderDevice* render);
+
+//Structures for the application
+ovrHmd HMD;
+ovrHmdDesc HMDDesc;
+ovrEyeRenderDesc EyeRenderDesc[2];
+RenderDevice* pRender;
+Texture* pRendertargetTexture;
+Scene* pRoomScene;
+
+// Specifics for whether the SDK or the app is doing the distortion.
+#if SDK_RENDER
+ #define OVR_D3D_VERSION 11
+ #include "OVR_CAPI_D3D.h"
+ ovrD3D11Texture EyeTexture[2];
+#else
+ void DistortionMeshInit (unsigned distortionCaps, ovrHmd HMD,
+ ovrEyeRenderDesc eyeRenderDesc[2], RenderDevice * pRender);
+ void DistortionMeshRender(unsigned distortionCaps, ovrHmd HMD,
+ double timwarpTimePoint, ovrPosef eyeRenderPoses[2],
+ RenderDevice * pRender, Texture* pRendertargetTexture);
+#endif
- MoveForward = MoveBack = MoveLeft = MoveRight = 0;
- GamepadMove = Vector3f(0);
- GamepadRotate = Vector3f(0);
-}
-
-OculusRoomTinyApp::~OculusRoomTinyApp()
-{
- RemoveHandlerFromDevices();
- pSensor.Clear();
- pHMD.Clear();
- destroyWindow();
- pApp = 0;
-}
-
+//-------------------------------------------------------------------------------------
-int OculusRoomTinyApp::OnStartup(const char* args)
+int Init()
{
- OVR_UNUSED(args);
-
-
- // *** Oculus HMD & Sensor Initialization
-
- // Create DeviceManager and first available HMDDevice from it.
- // Sensor object is created from the HMD, to ensure that it is on the
- // correct device.
-
- pManager = *DeviceManager::Create();
-
- // We'll handle it's messages in this case.
- pManager->SetMessageHandler(this);
-
-
- int detectionResult = IDCONTINUE;
- const char* detectionMessage;
+ // Initializes LibOVR.
+ ovr_Initialize();
- do
+ HMD = ovrHmd_Create(0);
+ if (!HMD)
{
- // Release Sensor/HMD in case this is a retry.
- pSensor.Clear();
- pHMD.Clear();
- RenderParams.MonitorName.Clear();
-
- pHMD = *pManager->EnumerateDevices<HMDDevice>().CreateDevice();
- if (pHMD)
- {
- pSensor = *pHMD->GetSensor();
-
- // This will initialize HMDInfo with information about configured IPD,
- // screen size and other variables needed for correct projection.
- // We pass HMD DisplayDeviceName into the renderer to select the
- // correct monitor in full-screen mode.
- if (pHMD->GetDeviceInfo(&HMDInfo))
- {
- RenderParams.MonitorName = HMDInfo.DisplayDeviceName;
- RenderParams.DisplayId = HMDInfo.DisplayId;
- SConfig.SetHMDInfo(HMDInfo);
- }
- }
- else
- {
- // If we didn't detect an HMD, try to create the sensor directly.
- // This is useful for debugging sensor interaction; it is not needed in
- // a shipping app.
- pSensor = *pManager->EnumerateDevices<SensorDevice>().CreateDevice();
- }
-
-
- // If there was a problem detecting the Rift, display appropriate message.
- detectionResult = IDCONTINUE;
-
- if (!pHMD && !pSensor)
- detectionMessage = "Oculus Rift not detected.";
- else if (!pHMD)
- detectionMessage = "Oculus Sensor detected; HMD Display not detected.";
- else if (!pSensor)
- detectionMessage = "Oculus HMD Display detected; Sensor not detected.";
- else if (HMDInfo.DisplayDeviceName[0] == '\0')
- detectionMessage = "Oculus Sensor detected; HMD display EDID not detected.";
- else
- detectionMessage = 0;
-
- if (detectionMessage)
- {
- String messageText(detectionMessage);
- messageText += "\n\n"
- "Press 'Try Again' to run retry detection.\n"
- "Press 'Continue' to run full-screen anyway.";
-
- detectionResult = ::MessageBoxA(0, messageText.ToCStr(), "Oculus Rift Detection",
- MB_CANCELTRYCONTINUE|MB_ICONWARNING);
-
- if (detectionResult == IDCANCEL)
- return 1;
- }
-
- } while (detectionResult != IDCONTINUE);
-
-
- if (HMDInfo.HResolution > 0)
- {
- Width = HMDInfo.HResolution;
- Height = HMDInfo.VResolution;
+ MessageBoxA(NULL,"Oculus Rift not detected.","", MB_OK);
+ return(1);
}
-
-
- if (!setupWindow())
- return 1;
-
- if (pSensor)
- {
- // We need to attach sensor to SensorFusion object for it to receive
- // body frame messages and update orientation. SFusion.GetOrientation()
- // is used in OnIdle() to orient the view.
- SFusion.AttachToSensor(pSensor);
- SFusion.SetDelegateMessageHandler(this);
- SFusion.SetPredictionEnabled(true);
- }
-
+ //Get more details about the HMD
+ ovrHmd_GetDesc(HMD, &HMDDesc);
+ if (HMDDesc.DisplayDeviceName[0] == '\0')
+ MessageBoxA(NULL,"Rift detected, display not enabled.","", MB_OK);
+
+ //Setup Window and Graphics
+ const int backBufferMultisample = 1;
+ pRender = Util_InitWindowAndGraphics(Recti(HMDDesc.WindowsPos, HMDDesc.Resolution),
+ FullScreen, backBufferMultisample);
+ if (!pRender) return 1;
+
+ //Configure Stereo settings.
+ Sizei recommenedTex0Size = ovrHmd_GetFovTextureSize(HMD, ovrEye_Left, HMDDesc.DefaultEyeFov[0], 1.0f);
+ Sizei recommenedTex1Size = ovrHmd_GetFovTextureSize(HMD, ovrEye_Right, HMDDesc.DefaultEyeFov[1], 1.0f);
+ Sizei RenderTargetSize;
+ RenderTargetSize.w = recommenedTex0Size.w + recommenedTex1Size.w;
+ RenderTargetSize.h = max ( recommenedTex0Size.h, recommenedTex1Size.h );
+
+ const int eyeRenderMultisample = 1;
+ pRendertargetTexture = pRender->CreateTexture(Texture_RGBA | Texture_RenderTarget |
+ eyeRenderMultisample,
+ RenderTargetSize.w, RenderTargetSize.h, NULL);
+ // The actual RT size may be different due to HW limits.
+ RenderTargetSize.w = pRendertargetTexture->GetWidth();
+ RenderTargetSize.h = pRendertargetTexture->GetHeight();
+
+ // Initialize eye rendering information for ovrHmd_Configure.
+ // The viewport sizes are re-computed in case RenderTargetSize changed due to HW limitations.
+ ovrEyeDesc eyes[2];
+ eyes[0].Eye = ovrEye_Left;
+ eyes[1].Eye = ovrEye_Right;
+ eyes[0].Fov = HMDDesc.DefaultEyeFov[0];
+ eyes[1].Fov = HMDDesc.DefaultEyeFov[1];
+ eyes[0].TextureSize = RenderTargetSize;
+ eyes[1].TextureSize = RenderTargetSize;
+ eyes[0].RenderViewport.Pos = Vector2i(0,0);
+ eyes[0].RenderViewport.Size = Sizei(RenderTargetSize.w / 2, RenderTargetSize.h);
+ eyes[1].RenderViewport.Pos = Vector2i((RenderTargetSize.w + 1) / 2, 0);
+ eyes[1].RenderViewport.Size = eyes[0].RenderViewport.Size;
+
+#if SDK_RENDER
+ // Query D3D texture data.
+ Texture* rtt = (Texture*)pRendertargetTexture;
+ EyeTexture[0].D3D11.Header.API = ovrRenderAPI_D3D11;
+ EyeTexture[0].D3D11.Header.TextureSize = RenderTargetSize;
+ EyeTexture[0].D3D11.Header.RenderViewport = eyes[0].RenderViewport;
+ EyeTexture[0].D3D11.pTexture = rtt->Tex.GetPtr();
+ EyeTexture[0].D3D11.pSRView = rtt->TexSv.GetPtr();
+
+ // Right eye uses the same texture, but different rendering viewport.
+ EyeTexture[1] = EyeTexture[0];
+ EyeTexture[1].D3D11.Header.RenderViewport = eyes[1].RenderViewport;
+
+ // Configure d3d11.
+ RenderDevice* render = (RenderDevice*)pRender;
+ ovrD3D11Config d3d11cfg;
+ d3d11cfg.D3D11.Header.API = ovrRenderAPI_D3D11;
+ d3d11cfg.D3D11.Header.RTSize = Sizei(HMDDesc.Resolution.w, HMDDesc.Resolution.h);
+ d3d11cfg.D3D11.Header.Multisample = backBufferMultisample;
+ d3d11cfg.D3D11.pDevice = render->Device;
+ d3d11cfg.D3D11.pDeviceContext = render->Context;
+ d3d11cfg.D3D11.pBackBufferRT = render->BackBufferRT;
+ d3d11cfg.D3D11.pSwapChain = render->SwapChain;
+
+ if (!ovrHmd_ConfigureRendering(HMD, &d3d11cfg.Config,
+ (VSyncEnabled ? 0 : ovrHmdCap_NoVSync), DistortionCaps,
+ eyes, EyeRenderDesc)) return(1);
+#else // !SDK_RENDER
+ EyeRenderDesc[0] = ovrHmd_GetRenderDesc(HMD, eyes[0]);
+ EyeRenderDesc[1] = ovrHmd_GetRenderDesc(HMD, eyes[1]);
- // *** Initialize Rendering
-
- // Enable multi-sampling by default.
- RenderParams.Multisample = 4;
- RenderParams.Fullscreen = true;
-
- // Setup Graphics.
- pRender = *RenderTiny::D3D10::RenderDevice::CreateDevice(RenderParams, (void*)hWnd);
- if (!pRender)
- return 1;
-
-
- // *** Configure Stereo settings.
-
- SConfig.SetFullViewport(Viewport(0,0, Width, Height));
- SConfig.SetStereoMode(Stereo_LeftRight_Multipass);
-
- // Configure proper Distortion Fit.
- // For 7" screen, fit to touch left side of the view, leaving a bit of invisible
- // screen on the top (saves on rendering cost).
- // For smaller screens (5.5"), fit to the top.
- if (HMDInfo.HScreenSize > 0.0f)
- {
- if (HMDInfo.HScreenSize > 0.140f) // 7"
- SConfig.SetDistortionFitPointVP(-1.0f, 0.0f);
- else
- SConfig.SetDistortionFitPointVP(0.0f, 1.0f);
- }
+ // Create our own distortion mesh and shaders
+ DistortionMeshInit(DistortionCaps, HMD, EyeRenderDesc, pRender);
+#endif
- pRender->SetSceneRenderScale(SConfig.GetDistortionScale());
-
- SConfig.Set2DAreaFov(DegreeToRad(85.0f));
-
-
- // *** Populate Room Scene
+ // Start the sensor which informs of the Rift's pose and motion
+ ovrHmd_StartSensor(HMD, ovrHmdCap_Orientation |
+ ovrHmdCap_YawCorrection |
+ ovrHmdCap_Position |
+ ovrHmdCap_LowPersistence |
+ ovrHmdCap_LatencyTest, 0);
// This creates lights and models.
- PopulateRoomScene(&Scene, pRender);
+ pRoomScene = new Scene;
+ PopulateRoomScene(pRoomScene, pRender);
-
- LastUpdate = GetAppTime();
return 0;
}
-void OculusRoomTinyApp::OnMessage(const Message& msg)
-{
- if (msg.Type == Message_DeviceAdded && msg.pDevice == pManager)
- {
- LogText("DeviceManager reported device added.\n");
- }
- else if (msg.Type == Message_DeviceRemoved && msg.pDevice == pManager)
- {
- LogText("DeviceManager reported device removed.\n");
- }
- else if (msg.Type == Message_DeviceAdded && msg.pDevice == pSensor)
- {
- LogText("Sensor reported device added.\n");
- }
- else if (msg.Type == Message_DeviceRemoved && msg.pDevice == pSensor)
- {
- LogText("Sensor reported device removed.\n");
- }
-}
-
-
-void OculusRoomTinyApp::OnGamepad(float padLx, float padLy, float padRx, float padRy)
-{
- GamepadMove = Vector3f(padLx * padLx * (padLx > 0 ? 1 : -1),
- 0,
- padLy * padLy * (padLy > 0 ? -1 : 1));
- GamepadRotate = Vector3f(2 * padRx, -2 * padRy, 0);
-}
-
-void OculusRoomTinyApp::OnMouseMove(int x, int y, int modifiers)
-{
- OVR_UNUSED(modifiers);
-
- // Mouse motion here is always relative.
- int dx = x, dy = y;
- const float maxPitch = ((3.1415f/2)*0.98f);
-
- // Apply to rotation. Subtract for right body frame rotation,
- // since yaw rotation is positive CCW when looking down on XZ plane.
- EyeYaw -= (Sensitivity * dx)/ 360.0f;
-
- if (!pSensor)
- {
- EyePitch -= (Sensitivity * dy)/ 360.0f;
-
- if (EyePitch > maxPitch)
- EyePitch = maxPitch;
- if (EyePitch < -maxPitch)
- EyePitch = -maxPitch;
- }
-}
-
-void OculusRoomTinyApp::OnKey(unsigned vk, bool down)
-{
- switch (vk)
- {
- case 'Q':
- if (down && ControlDown)
- Quit = true;
- break;
- case VK_ESCAPE:
- if (!down)
- Quit = true;
- break;
-
- // Handle player movement keys.
- // We just update movement state here, while the actual translation is done in OnIdle()
- // based on time.
- case 'W': MoveForward = down ? (MoveForward | 1) : (MoveForward & ~1); break;
- case 'S': MoveBack = down ? (MoveBack | 1) : (MoveBack & ~1); break;
- case 'A': MoveLeft = down ? (MoveLeft | 1) : (MoveLeft & ~1); break;
- case 'D': MoveRight = down ? (MoveRight | 1) : (MoveRight & ~1); break;
- case VK_UP: MoveForward = down ? (MoveForward | 2) : (MoveForward & ~2); break;
- case VK_DOWN: MoveBack = down ? (MoveBack | 2) : (MoveBack & ~2); break;
-
- case 'R':
- SFusion.Reset();
- break;
-
- case 'P':
- if (down)
- {
- // Toggle chromatic aberration correction on/off.
- RenderDevice::PostProcessShader shader = pRender->GetPostProcessShader();
-
- if (shader == RenderDevice::PostProcessShader_Distortion)
- {
- pRender->SetPostProcessShader(RenderDevice::PostProcessShader_DistortionAndChromAb);
- }
- else if (shader == RenderDevice::PostProcessShader_DistortionAndChromAb)
- {
- pRender->SetPostProcessShader(RenderDevice::PostProcessShader_Distortion);
- }
- else
- OVR_ASSERT(false);
- }
- break;
-
- // Switch rendering modes/distortion.
- case VK_F1:
- SConfig.SetStereoMode(Stereo_None);
- PostProcess = PostProcess_None;
- break;
- case VK_F2:
- SConfig.SetStereoMode(Stereo_LeftRight_Multipass);
- PostProcess = PostProcess_None;
- break;
- case VK_F3:
- SConfig.SetStereoMode(Stereo_LeftRight_Multipass);
- PostProcess = PostProcess_Distortion;
- break;
-
- // Stereo IPD adjustments, in meter (default IPD is 64mm).
- case VK_OEM_PLUS:
- case VK_INSERT:
- if (down)
- SConfig.SetIPD(SConfig.GetIPD() + 0.0005f * (ShiftDown ? 5.0f : 1.0f));
- break;
- case VK_OEM_MINUS:
- case VK_DELETE:
- if (down)
- SConfig.SetIPD(SConfig.GetIPD() - 0.0005f * (ShiftDown ? 5.0f : 1.0f));
- break;
-
- // Holding down Shift key accelerates adjustment velocity.
- case VK_SHIFT:
- ShiftDown = down;
- break;
- case VK_CONTROL:
- ControlDown = down;
- break;
- }
-}
-
+//-------------------------------------------------------------------------------------
-void OculusRoomTinyApp::OnIdle()
+void ProcessAndRender()
{
- double curtime = GetAppTime();
- float dt = float(curtime - LastUpdate);
- LastUpdate = curtime;
-
-
- // Handle Sensor motion.
- // We extract Yaw, Pitch, Roll instead of directly using the orientation
- // to allow "additional" yaw manipulation with mouse/controller.
- if (pSensor)
- {
- Quatf hmdOrient = SFusion.GetOrientation();
- float yaw = 0.0f;
-
- hmdOrient.GetEulerAngles<Axis_Y, Axis_X, Axis_Z>(&yaw, &EyePitch, &EyeRoll);
-
- EyeYaw += (yaw - LastSensorYaw);
- LastSensorYaw = yaw;
- }
-
-
- // Gamepad rotation.
- EyeYaw -= GamepadRotate.x * dt;
-
- if (!pSensor)
- {
- // Allow gamepad to look up/down, but only if there is no Rift sensor.
- EyePitch -= GamepadRotate.y * dt;
-
- const float maxPitch = ((3.1415f/2)*0.98f);
- if (EyePitch > maxPitch)
- EyePitch = maxPitch;
- if (EyePitch < -maxPitch)
- EyePitch = -maxPitch;
- }
-
- // Handle keyboard movement.
- // This translates EyePos based on Yaw vector direction and keys pressed.
- // Note that Pitch and Roll do not affect movement (they only affect view).
- if (MoveForward || MoveBack || MoveLeft || MoveRight)
- {
- Vector3f localMoveVector(0,0,0);
- Matrix4f yawRotate = Matrix4f::RotationY(EyeYaw);
-
- if (MoveForward)
- localMoveVector = ForwardVector;
- else if (MoveBack)
- localMoveVector = -ForwardVector;
-
- if (MoveRight)
- localMoveVector += RightVector;
- else if (MoveLeft)
- localMoveVector -= RightVector;
-
- // Normalize vector so we don't move faster diagonally.
- localMoveVector.Normalize();
- Vector3f orientationVector = yawRotate.Transform(localMoveVector);
- orientationVector *= MoveSpeed * dt * (ShiftDown ? 3.0f : 1.0f);
+#if SDK_RENDER
+ ovrFrameTiming frameTiming = ovrHmd_BeginFrame(HMD, 0);
+#else
+ ovrFrameTiming frameTiming = ovrHmd_BeginFrameTiming(HMD, 0);
+#endif
- EyePos += orientationVector;
- }
-
- else if (GamepadMove.LengthSq() > 0)
- {
- Matrix4f yawRotate = Matrix4f::RotationY(EyeYaw);
- Vector3f orientationVector = yawRotate.Transform(GamepadMove);
- orientationVector *= MoveSpeed * dt;
- EyePos += orientationVector;
- }
+ //Adjust eye position and rotation from controls, maintaining y position from HMD.
+ static Vector3f EyePos(0.0f, 1.6f, -5.0f);
+ static float EyeYaw(3.141592f);
+ Posef movePose = ovrHmd_GetSensorState(HMD, frameTiming.ScanoutMidpointSeconds).Predicted.Pose;
+ ovrPosef eyeRenderPose[2];
- // Rotate and position View Camera, using YawPitchRoll in BodyFrame coordinates.
- //
- Matrix4f rollPitchYaw = Matrix4f::RotationY(EyeYaw) * Matrix4f::RotationX(EyePitch) *
- Matrix4f::RotationZ(EyeRoll);
- Vector3f up = rollPitchYaw.Transform(UpVector);
- Vector3f forward = rollPitchYaw.Transform(ForwardVector);
+ EyePos.y = ovrHmd_GetFloat(HMD, OVR_KEY_EYE_HEIGHT, EyePos.y);
+ bool freezeEyeRender = Util_RespondToControls(EyeYaw, EyePos,
+ frameTiming.DeltaSeconds, movePose.Orientation);
+ pRender->BeginScene();
- // Minimal head modelling.
- float headBaseToEyeHeight = 0.15f; // Vertical height of eye from base of head
- float headBaseToEyeProtrusion = 0.09f; // Distance forward of eye from base of head
-
- Vector3f eyeCenterInHeadFrame(0.0f, headBaseToEyeHeight, -headBaseToEyeProtrusion);
- Vector3f shiftedEyePos = EyePos + rollPitchYaw.Transform(eyeCenterInHeadFrame);
- shiftedEyePos.y -= eyeCenterInHeadFrame.y; // Bring the head back down to original height
-
- View = Matrix4f::LookAtRH(shiftedEyePos, shiftedEyePos + forward, up);
-
- // This is what transformation would be without head modeling.
- // View = Matrix4f::LookAtRH(EyePos, EyePos + forward, up);
-
- switch(SConfig.GetStereoMode())
+ //Render the two undistorted eye views into their render buffers.
+ if (!freezeEyeRender) // freeze to debug, especially for time warp
{
- case Stereo_None:
- Render(SConfig.GetEyeRenderParams(StereoEye_Center));
- break;
-
- case Stereo_LeftRight_Multipass:
- Render(SConfig.GetEyeRenderParams(StereoEye_Left));
- Render(SConfig.GetEyeRenderParams(StereoEye_Right));
- break;
+ pRender->SetRenderTarget ( pRendertargetTexture );
+ pRender->SetViewport (Recti(0,0, pRendertargetTexture->GetWidth(),
+ pRendertargetTexture->GetHeight() ));
+ pRender->Clear();
+ for (int eyeIndex = 0; eyeIndex < ovrEye_Count; eyeIndex++)
+ {
+ ovrEyeType eye = HMDDesc.EyeRenderOrder[eyeIndex];
+#if SDK_RENDER
+ eyeRenderPose[eye] = ovrHmd_BeginEyeRender(HMD, eye);
+#else
+ eyeRenderPose[eye] = ovrHmd_GetEyePose(HMD, eye);
+#endif
+
+ // Get view matrix
+ Matrix4f rollPitchYaw = Matrix4f::RotationY(EyeYaw);
+ Matrix4f finalRollPitchYaw = rollPitchYaw * Matrix4f(eyeRenderPose[eye].Orientation);
+ Vector3f finalUp = finalRollPitchYaw.Transform(Vector3f(0,1,0));
+ Vector3f finalForward = finalRollPitchYaw.Transform(Vector3f(0,0,-1));
+ Vector3f shiftedEyePos = EyePos + rollPitchYaw.Transform(eyeRenderPose[eye].Position);
+
+ Matrix4f view = Matrix4f::LookAtRH(shiftedEyePos,
+ shiftedEyePos + finalForward, finalUp);
+
+ Matrix4f proj = ovrMatrix4f_Projection(EyeRenderDesc[eye].Desc.Fov, 0.01f, 10000.0f, true);
+
+ pRender->SetViewport(EyeRenderDesc[eye].Desc.RenderViewport.Pos.x,
+ EyeRenderDesc[eye].Desc.RenderViewport.Pos.y,
+ EyeRenderDesc[eye].Desc.RenderViewport.Size.w,
+ EyeRenderDesc[eye].Desc.RenderViewport.Size.h);
+ pRender->SetProjection(proj);
+ pRender->SetDepthMode(true, true);
+ pRoomScene->Render(pRender, Matrix4f::Translation(EyeRenderDesc[eye].ViewAdjust) * view);
+
+ #if SDK_RENDER
+ ovrHmd_EndEyeRender(HMD, eye, eyeRenderPose[eye], &EyeTexture[eye].Texture);
+ #endif
+ }
}
-
- pRender->Present();
- // Force GPU to flush the scene, resulting in the lowest possible latency.
- pRender->ForceFlushGPU();
-}
-
-
-// Render the scene for one eye.
-void OculusRoomTinyApp::Render(const StereoEyeParams& stereo)
-{
- pRender->BeginScene(PostProcess);
-
- // Apply Viewport/Projection for the eye.
- pRender->ApplyStereoParams(stereo);
- pRender->Clear();
- pRender->SetDepthMode(true, true);
-
- Scene.Render(pRender, stereo.ViewAdjust * View);
-
pRender->FinishScene();
-}
-
-
-//-------------------------------------------------------------------------------------
-// ***** Win32-Specific Logic
-
-bool OculusRoomTinyApp::setupWindow()
-{
- WNDCLASS wc;
- memset(&wc, 0, sizeof(wc));
- wc.lpszClassName = L"OVRAppWindow";
- wc.style = CS_OWNDC;
- wc.lpfnWndProc = systemWindowProc;
- wc.cbWndExtra = sizeof(OculusRoomTinyApp*);
- RegisterClass(&wc);
-
-
- RECT winSize = { 0, 0, Width, Height };
- AdjustWindowRect(&winSize, WS_POPUP, false);
- hWnd = CreateWindowA("OVRAppWindow", "OculusRoomTiny", WS_POPUP|WS_VISIBLE,
- HMDInfo.DesktopX, HMDInfo.DesktopY,
- winSize.right-winSize.left, winSize.bottom-winSize.top,
- NULL, NULL, hInstance, (LPVOID)this);
-
-
- // Initialize Window center in screen coordinates
- POINT center = { Width / 2, Height / 2 };
- ::ClientToScreen(hWnd, &center);
- WindowCenter = center;
-
-
- return (hWnd != NULL);
+ // Now render the distorted view and finish.
+#if SDK_RENDER
+ // Let OVR do distortion rendering, Present and flush/sync
+ ovrHmd_EndFrame(HMD);
+
+#else
+ DistortionMeshRender(DistortionCaps, HMD, frameTiming.TimewarpPointSeconds,
+ eyeRenderPose, pRender, pRendertargetTexture);
+ pRender->Present( VSyncEnabled );
+ pRender->WaitUntilGpuIdle(); //for lowest latency
+ ovrHmd_EndFrameTiming(HMD);
+#endif
}
-void OculusRoomTinyApp::destroyWindow()
+/*
+void RenderFramePseudoCode()
{
- pRender.Clear();
-
- if (hWnd)
- {
- // Release window resources.
- ::DestroyWindow(hWnd);
- UnregisterClass(L"OVRAppWindow", hInstance);
- hWnd = 0;
- Width = Height = 0;
- }
-}
-
-
-LRESULT CALLBACK OculusRoomTinyApp::systemWindowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
-{
- if (msg == WM_NCCREATE)
- pApp->hWnd = hwnd;
- return pApp->windowProc(msg, wp, lp);
-}
-
-void OculusRoomTinyApp::giveUsFocus(bool setFocus)
-{
- if (setFocus)
- {
- ::SetCursorPos(WindowCenter.x, WindowCenter.y);
-
- MouseCaptured = true;
- ::SetCapture(hWnd);
- ::ShowCursor(FALSE);
+ovrFrame hmdFrameState = ovrHmd_BeginFrame(hmd);
- }
- else
- {
- MouseCaptured = false;
- ::ReleaseCapture();
- ::ShowCursor(TRUE);
- }
-}
-
-LRESULT OculusRoomTinyApp::windowProc(UINT msg, WPARAM wp, LPARAM lp)
+for (int eyeIndex = 0; eyeIndex < ovrEye_Count; eyeIndex++)
{
- switch (msg)
- {
- case WM_MOUSEMOVE:
- {
- if (MouseCaptured)
- {
- // Convert mouse motion to be relative (report the offset and re-center).
- POINT newPos = { LOWORD(lp), HIWORD(lp) };
- ::ClientToScreen(hWnd, &newPos);
- if ((newPos.x == WindowCenter.x) && (newPos.y == WindowCenter.y))
- break;
- ::SetCursorPos(WindowCenter.x, WindowCenter.y);
-
- LONG dx = newPos.x - WindowCenter.x;
- LONG dy = newPos.y - WindowCenter.y;
- pApp->OnMouseMove(dx, dy, 0);
- }
- }
- break;
-
- case WM_MOVE:
- {
- RECT r;
- GetClientRect(hWnd, &r);
- WindowCenter.x = r.right/2;
- WindowCenter.y = r.bottom/2;
- ::ClientToScreen(hWnd, &WindowCenter);
- }
- break;
-
- case WM_KEYDOWN:
- OnKey((unsigned)wp, true);
- break;
- case WM_KEYUP:
- OnKey((unsigned)wp, false);
- break;
-
- case WM_SETFOCUS:
- giveUsFocus(true);
- break;
-
- case WM_KILLFOCUS:
- giveUsFocus(false);
- break;
-
- case WM_CREATE:
- // Hack to position mouse in fullscreen window shortly after startup.
- SetTimer(hWnd, 0, 100, NULL);
- break;
-
- case WM_TIMER:
- KillTimer(hWnd, 0);
- giveUsFocus(true);
- break;
-
- case WM_QUIT:
- case WM_CLOSE:
- Quit = true;
- return 0;
- }
-
- return DefWindowProc(hWnd, msg, wp, lp);
-}
+ ovrEyeType eye = HMDDesc.EyeRenderOrder[eyeIndex];
+ ovrPosef eyeRenderPose = ovrHmd_BeginEyeRender(hmd, eye);
-static inline float GamepadStick(short in)
-{
- float v;
- if (abs(in) < 9000)
- return 0;
- else if (in > 9000)
- v = (float) in - 9000;
- else
- v = (float) in + 9000;
- return v / (32767 - 9000);
-}
+ RenderGameView(RenderViewports[eye], eyeRenderPose);
-static inline float GamepadTrigger(BYTE in)
-{
- return (in < 30) ? 0.0f : (float(in-30) / 225);
+ ovrHmd_EndEyeRender(hmd, eye, &EyeTexture[eye].Texture);
}
-
-int OculusRoomTinyApp::Run()
-{
- // Loop processing messages until Quit flag is set,
- // rendering game scene inside of OnIdle().
-
- while (!Quit)
- {
- MSG msg;
- if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- else
- {
- // Read game-pad.
- XINPUT_STATE xis;
-
- if (pXInputGetState && !pXInputGetState(0, &xis) &&
- (xis.dwPacketNumber != LastPadPacketNo))
- {
- OnGamepad(GamepadStick(xis.Gamepad.sThumbLX),
- GamepadStick(xis.Gamepad.sThumbLY),
- GamepadStick(xis.Gamepad.sThumbRX),
- GamepadStick(xis.Gamepad.sThumbRY));
- //pad.LT = GamepadTrigger(xis.Gamepad.bLeftTrigger);
- LastPadPacketNo = xis.dwPacketNumber;
- }
-
- pApp->OnIdle();
-
- // Keep sleeping when we're minimized.
- if (IsIconic(hWnd))
- Sleep(10);
- }
- }
-
- return 0;
+// Let OVR do distortion rendering, Present and Flush+Sync.
+ovrHmd_EndFrame(hmd);
}
-
+*/
//-------------------------------------------------------------------------------------
-// ***** Program Startup
-
-int WINAPI WinMain(HINSTANCE hinst, HINSTANCE, LPSTR inArgs, int)
+void Release(void)
{
- int exitCode = 0;
-
- // Initializes LibOVR. This LogMask_All enables maximum logging.
- // Custom allocator can also be specified here.
- OVR::System::Init(OVR::Log::ConfigureDefaultLog(OVR::LogMask_All));
-
- // Scope to force application destructor before System::Destroy.
+ pRendertargetTexture->Release();
+ pRendertargetTexture = 0;
+ ovrHmd_Destroy(HMD);
+ Util_ReleaseWindowAndGraphics(pRender);
+ pRender = 0;
+ if (pRoomScene)
{
- OculusRoomTinyApp app(hinst);
- //app.hInstance = hinst;
-
- exitCode = app.OnStartup(inArgs);
- if (!exitCode)
- {
- // Processes messages and calls OnIdle() to do rendering.
- exitCode = app.Run();
- }
- }
-
+ delete pRoomScene;
+ pRoomScene = 0;
+ }
// No OVR functions involving memory are allowed after this.
- OVR::System::Destroy();
-
- OVR_DEBUG_STATEMENT(_CrtDumpMemoryLeaks());
- return exitCode;
+ ovr_Shutdown();
}
+
diff --git a/Samples/OculusRoomTiny/Win32_OculusRoomTiny.h b/Samples/OculusRoomTiny/Win32_OculusRoomTiny.h
deleted file mode 100644
index a86dd47..0000000
--- a/Samples/OculusRoomTiny/Win32_OculusRoomTiny.h
+++ /dev/null
@@ -1,189 +0,0 @@
-/************************************************************************************
-
-Filename : OculusRoomTiny.h
-Content : Simplest possible first-person view test application for Oculus Rift
-Created : March 10, 2012
-Authors : Michael Antonov, Andrew Reisse
-
-Copyright : Copyright 2012 Oculus, Inc. All Rights reserved.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-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 INC_OculusRoomTiny_h
-#define INC_OculusRoomTiny_h
-
-#include <Windows.h>
-#include <xinput.h>
-
-#include "OVR.h"
-#include "Util/Util_Render_Stereo.h"
-#include "../../LibOVR/Src/Kernel/OVR_Timer.h"
-#include "RenderTiny_D3D1X_Device.h"
-
-using namespace OVR;
-using namespace OVR::RenderTiny;
-
-
-//-------------------------------------------------------------------------------------
-// ***** OculusRoomTiny Description
-
-// This app renders a simple flat-shaded room allowing the user to move along the
-// floor and look around with an HMD, mouse, keyboard and gamepad.
-// By default, the application will start full-screen on Oculus Rift.
-//
-// The following keys work:
-//
-// 'W', 'S', 'A', 'D' - Move forward, back; strafe left/right.
-// F1 - No stereo, no distortion.
-// F2 - Stereo, no distortion.
-// F3 - Stereo and distortion.
-//
-
-// The world RHS coordinate system is defines as follows (as seen in perspective view):
-// Y - Up
-// Z - Back
-// X - Right
-const Vector3f UpVector(0.0f, 1.0f, 0.0f);
-const Vector3f ForwardVector(0.0f, 0.0f, -1.0f);
-const Vector3f RightVector(1.0f, 0.0f, 0.0f);
-
-// We start out looking in the positive Z (180 degree rotation).
-const float YawInitial = 3.141592f;
-const float Sensitivity = 1.0f;
-const float MoveSpeed = 3.0f; // m/s
-
-
-//-------------------------------------------------------------------------------------
-// ***** OculusRoomTiny Application class
-
-// An instance of this class is created on application startup (main/WinMain).
-//
-// It then works as follows:
-//
-// OnStartup - Window, graphics and HMD setup is done here.
-// This function will initialize OVR::DeviceManager and HMD,
-// creating SensorDevice and attaching it to SensorFusion.
-// This needs to be done before obtaining sensor data.
-//
-// OnIdle - Does per-frame processing, processing SensorFusion and
-// movement input and rendering the frame.
-
-class OculusRoomTinyApp : public MessageHandler
-{
-public:
- OculusRoomTinyApp(HINSTANCE hinst);
- ~OculusRoomTinyApp();
-
- // Initializes graphics, Rift input and creates world model.
- virtual int OnStartup(const char* args);
- // Called per frame to sample SensorFucion and render the world.
- virtual void OnIdle();
-
- // Installed for Oculus device messages. Optional.
- virtual void OnMessage(const Message& msg);
-
- // Handle input events for movement.
- virtual void OnGamepad(float padLx, float padLY, float padRx, float padRy);
- virtual void OnMouseMove(int x, int y, int modifiers);
- virtual void OnKey(unsigned vk, bool down);
-
- // Render the view for one eye.
- void Render(const StereoEyeParams& stereo);
-
- // Main application loop.
- int Run();
-
- // Return amount of time passed since application started in seconds.
- double GetAppTime() const
- {
- return (OVR::Timer::GetTicks() - StartupTicks) * (1.0 / (double)OVR::Timer::MksPerSecond);
- }
-
-
-protected:
-
- // Win32 window setup interface.
- LRESULT windowProc(UINT msg, WPARAM wp, LPARAM lp);
- bool setupWindow();
- void destroyWindow();
- // Win32 static function that delegates to WindowProc member function.
- static LRESULT CALLBACK systemWindowProc(HWND window, UINT msg, WPARAM wp, LPARAM lp);
-
- void giveUsFocus(bool setFocus);
-
- static OculusRoomTinyApp* pApp;
-
- // *** Rendering Variables
- Ptr<RenderDevice> pRender;
- RendererParams RenderParams;
- int Width, Height;
-
-
- // *** Win32 System Variables
- HWND hWnd;
- HINSTANCE hInstance;
- POINT WindowCenter; // In desktop coordinates
- bool Quit;
- bool MouseCaptured;
-
- // Dynamically ink to XInput to simplify projects.
- typedef DWORD (WINAPI *PFn_XInputGetState)(DWORD dwUserIndex, XINPUT_STATE* pState);
- PFn_XInputGetState pXInputGetState;
- HMODULE hXInputModule;
- UInt32 LastPadPacketNo;
-
-
- // *** Oculus HMD Variables
-
- Ptr<DeviceManager> pManager;
- Ptr<SensorDevice> pSensor;
- Ptr<HMDDevice> pHMD;
- SensorFusion SFusion;
- OVR::HMDInfo HMDInfo;
-
- // Last update seconds, used for move speed timing.
- double LastUpdate;
- UInt64 StartupTicks;
-
- // Position and look. The following apply:
- Vector3f EyePos;
- float EyeYaw; // Rotation around Y, CCW positive when looking at RHS (X,Z) plane.
- float EyePitch; // Pitch. If sensor is plugged in, only read from sensor.
- float EyeRoll; // Roll, only accessible from Sensor.
- float LastSensorYaw; // Stores previous Yaw value from to support computing delta.
-
- // Movement state; different bits may be set based on the state of keys.
- UByte MoveForward;
- UByte MoveBack;
- UByte MoveLeft;
- UByte MoveRight;
- Vector3f GamepadMove, GamepadRotate;
-
- Matrix4f View;
- RenderTiny::Scene Scene;
-
- // Stereo view parameters.
- StereoConfig SConfig;
- PostProcessType PostProcess;
-
- // Shift accelerates movement/adjustment velocity.
- bool ShiftDown;
- bool ControlDown;
-};
-
-// Adds sample models and lights to the argument scene.
-void PopulateRoomScene(Scene* scene, RenderDevice* render);
-
-
-#endif
diff --git a/Samples/OculusRoomTiny/Win32_OculusRoomTiny_Util.cpp b/Samples/OculusRoomTiny/Win32_OculusRoomTiny_Util.cpp
new file mode 100644
index 0000000..ab0f252
--- /dev/null
+++ b/Samples/OculusRoomTiny/Win32_OculusRoomTiny_Util.cpp
@@ -0,0 +1,254 @@
+/************************************************************************************
+
+Filename : Win32_OculusRoomTiny_Util.cpp
+Content : Win32 system interface & app/graphics initialization ligic
+Created : October 4, 2012
+
+Copyright : Copyright 2012 Oculus, Inc. All Rights reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+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.
+*************************************************************************************/
+
+#include "RenderTiny_D3D11_Device.h"
+
+// Win32 System Variables
+HWND hWnd = NULL;
+HINSTANCE hInstance;
+POINT WindowCenter;
+
+// User inputs
+bool Quit = 0;
+UByte MoveForward = 0,
+ MoveBack = 0,
+ MoveLeft = 0,
+ MoveRight = 0;
+
+bool ShiftDown = false,
+ ControlDown = false;
+
+// Freezes the scene during timewarp rendering.
+bool FreezeEyeRender = false;
+
+float AdditionalYawFromMouse = 0;
+
+// Movement speed, in m/s applied during keyboard motion.
+const float MoveSpeed = 3.0f;
+
+// Functions from Win32_OculusRoomTiny.cpp and DistortionMesh.cpp
+int Init();
+void ProcessAndRender();
+void Release();
+void DistortionMeshRelease(void);
+
+
+//-------------------------------------------------------------------------------------
+
+void OnKey(unsigned vk, bool down)
+{
+ switch (vk)
+ {
+ case 'Q': if (down && ControlDown) Quit = true; break;
+ case VK_ESCAPE: if (!down) Quit = true; break;
+
+ case 'W': MoveForward = down ? (MoveForward | 1) : (MoveForward & ~1); break;
+ case 'S': MoveBack = down ? (MoveBack | 1) : (MoveBack & ~1); break;
+ case 'A': MoveLeft = down ? (MoveLeft | 1) : (MoveLeft & ~1); break;
+ case 'D': MoveRight = down ? (MoveRight | 1) : (MoveRight & ~1); break;
+
+ case VK_UP: MoveForward = down ? (MoveForward | 2) : (MoveForward & ~2); break;
+ case VK_DOWN: MoveBack = down ? (MoveBack | 2) : (MoveBack & ~2); break;
+
+ case 'F': FreezeEyeRender = !down ? !FreezeEyeRender : FreezeEyeRender; break;
+
+ case VK_SHIFT: ShiftDown = down; break;
+ case VK_CONTROL:ControlDown = down; break;
+ }
+}
+
+void OnMouseMove(int x)
+{
+ const float Sensitivity = 1.0f;
+ AdditionalYawFromMouse -= (Sensitivity * x)/ 360.0f;
+}
+
+bool Util_RespondToControls(float & EyeYaw, Vector3f & EyePos,
+ float deltaTime, Quatf PoseOrientation)
+{
+ #if 0//Optional debug output
+ char debugString[1000];
+ sprintf_s(debugString,"Pos = (%0.2f, %0.2f, %0.2f)\n",EyePos.x,EyePos.y,EyePos.z);
+ OutputDebugStringA(debugString);
+ #endif
+
+ //Mouse rotation
+ EyeYaw += AdditionalYawFromMouse;
+ AdditionalYawFromMouse = 0;
+
+ //Get HeadYaw
+ float HeadPitch, HeadRoll, HeadYaw;
+ PoseOrientation.GetEulerAngles<Axis_Y, Axis_X, Axis_Z>(&HeadYaw,&HeadPitch, &HeadRoll);
+
+ //Move on Eye pos from controls
+ Vector3f localMoveVector(0,0,0);
+ Matrix4f yawRotate = Matrix4f::RotationY(EyeYaw + HeadYaw);
+
+ if (MoveForward) localMoveVector += Vector3f(0,0,-1);
+ if (MoveBack) localMoveVector += Vector3f(0,0,+1);
+ if (MoveRight) localMoveVector += Vector3f(1,0,0);
+ if (MoveLeft) localMoveVector += Vector3f(-1,0,0);
+
+ Vector3f orientationVector = yawRotate.Transform(localMoveVector);
+
+ orientationVector *= MoveSpeed * deltaTime * (ShiftDown ? 3.0f : 1.0f);
+ EyePos += orientationVector;
+
+ //Some rudimentary limitation of movement, so not to go through walls
+ const float minDistanceToWall = 0.30f;
+ EyePos.x = max(EyePos.x,-10.0f + minDistanceToWall);
+ EyePos.x = min(EyePos.x, 10.0f - minDistanceToWall);
+ EyePos.z = max(EyePos.z,-20.0f + minDistanceToWall);
+
+ //Return if need to freeze or not
+ return(FreezeEyeRender);
+}
+
+
+LRESULT CALLBACK systemWindowProc(HWND arg_hwnd, UINT msg, WPARAM wp, LPARAM lp)
+{
+ switch (msg)
+ {
+ case(WM_NCCREATE): hWnd = arg_hwnd; break;
+
+ case WM_MOUSEMOVE: {
+ // Convert mouse motion to be relative
+ // (report the offset and re-center).
+ POINT newPos = { LOWORD(lp), HIWORD(lp) };
+ ::ClientToScreen(hWnd, &newPos);
+ if ((newPos.x == WindowCenter.x) && (newPos.y == WindowCenter.y))
+ break;
+ ::SetCursorPos(WindowCenter.x, WindowCenter.y);
+ OnMouseMove(newPos.x - WindowCenter.x);
+ break;
+ }
+
+ case WM_MOVE: RECT r;
+ GetClientRect(hWnd, &r);
+ WindowCenter.x = r.right/2;
+ WindowCenter.y = r.bottom/2;
+ ::ClientToScreen(hWnd, &WindowCenter);
+ break;
+
+ case WM_KEYDOWN: OnKey((unsigned)wp, true); break;
+ case WM_KEYUP: OnKey((unsigned)wp, false); break;
+ case WM_CREATE: SetTimer(hWnd, 0, 100, NULL); break;
+ case WM_TIMER: KillTimer(hWnd, 0);
+
+ case WM_SETFOCUS:
+ SetCursorPos(WindowCenter.x, WindowCenter.y);
+ SetCapture(hWnd);
+ ShowCursor(FALSE);
+ break;
+ case WM_KILLFOCUS:
+ ReleaseCapture();
+ ShowCursor(TRUE);
+ break;
+
+ case WM_QUIT:
+ case WM_CLOSE: Quit = true;
+ return 0;
+ }
+
+ return DefWindowProc(hWnd, msg, wp, lp);
+}
+
+
+RenderDevice* Util_InitWindowAndGraphics(Recti vp, int fullscreen, int multiSampleCount)
+{
+ // Window
+ WNDCLASS wc;
+ memset(&wc, 0, sizeof(wc));
+ wc.lpszClassName = L"OVRAppWindow";
+ wc.style = CS_OWNDC;
+ wc.lpfnWndProc = systemWindowProc;
+ wc.cbWndExtra = NULL;
+ RegisterClass(&wc);
+
+ RECT winSize = { 0, 0, vp.w, vp.h };
+ AdjustWindowRect(&winSize, WS_POPUP, false);
+ hWnd = CreateWindowA("OVRAppWindow", "OculusRoomTiny", WS_POPUP |WS_VISIBLE,
+ vp.x, vp.y,
+ winSize.right-winSize.left, winSize.bottom-winSize.top,
+ NULL, NULL, hInstance, NULL);
+
+ POINT center = { vp.w / 2, vp.h / 2 };
+ ::ClientToScreen(hWnd, &center);
+ WindowCenter = center;
+
+ if (!hWnd) return(NULL);
+
+ // Graphics
+ RendererParams renderParams;
+ renderParams.Multisample = multiSampleCount;
+ renderParams.Fullscreen = fullscreen;
+ return (RenderDevice::CreateDevice(renderParams, (void*)hWnd));
+}
+
+
+void Util_ReleaseWindowAndGraphics(RenderDevice * prender)
+{
+ if (prender)
+ prender->Release();
+
+ DistortionMeshRelease();
+
+ if (hWnd)
+ {
+ // Release window resources.
+ ::DestroyWindow(hWnd);
+ UnregisterClass(L"OVRAppWindow", hInstance);
+ }
+}
+
+
+//-------------------------------------------------------------------------------------
+// ***** Program Startup
+//
+int WINAPI WinMain(HINSTANCE hinst, HINSTANCE, LPSTR , int)
+{
+ hInstance = hinst;
+
+ if (!Init())
+ {
+ // Processes messages and calls OnIdle() to do rendering.
+ while (!Quit)
+ {
+ MSG msg;
+ if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ else
+ {
+ ProcessAndRender();
+
+ // Keep sleeping when we're minimized.
+ if (IsIconic(hWnd)) Sleep(10);
+ }
+ }
+ }
+ Release();
+ OVR_DEBUG_STATEMENT(_CrtDumpMemoryLeaks());
+ return (0);
+}
+
diff --git a/Samples/OculusWorldDemo/Assets/Tuscany/Tuscany_OculusCube.tga b/Samples/OculusWorldDemo/Assets/Tuscany/Tuscany_OculusCube.tga
new file mode 100644
index 0000000..be8b5de
--- /dev/null
+++ b/Samples/OculusWorldDemo/Assets/Tuscany/Tuscany_OculusCube.tga
Binary files differ
diff --git a/Samples/OculusWorldDemo/Assets/Tuscany/Tuscany_blueCube.tga b/Samples/OculusWorldDemo/Assets/Tuscany/Tuscany_blueCube.tga
new file mode 100644
index 0000000..fe4768e
--- /dev/null
+++ b/Samples/OculusWorldDemo/Assets/Tuscany/Tuscany_blueCube.tga
Binary files differ
diff --git a/Samples/OculusWorldDemo/Assets/Tuscany/Tuscany_redCube.tga b/Samples/OculusWorldDemo/Assets/Tuscany/Tuscany_redCube.tga
new file mode 100644
index 0000000..7b90b82
--- /dev/null
+++ b/Samples/OculusWorldDemo/Assets/Tuscany/Tuscany_redCube.tga
Binary files differ
diff --git a/Samples/OculusWorldDemo/Makefile b/Samples/OculusWorldDemo/Makefile
deleted file mode 100644
index 6015560..0000000
--- a/Samples/OculusWorldDemo/Makefile
+++ /dev/null
@@ -1,135 +0,0 @@
-#############################################################################
-#
-# Filename : Makefile
-# Content : Makefile for building linux OculusWorldDemo
-# Created : 2013
-# Authors : Simon Hallam and Peter Giokaris
-# Copyright : Copyright 2013 OculusVR, Inc. All Rights Reserved
-# Instruction : The g++ compiler and stdndard lib packages need to be
-# installed on the system. Navigate in a shell to the
-# directory where this Makefile is located and enter:
-#
-# make builds the release version for the
-# current architechture
-# make clean delete intermediate release object files
-# and the executabe file
-# make DEBUG=1 builds the debug version for the current
-# architechture
-# make clean DEBUG=1 deletes intermediate debug object files
-# and the executable file
-#
-# Output : Relative to the directory this Makefile lives in, executable
-# files get built at the following locations depending upon the
-# architechture of the system you are running:
-#
-# ./Release/OculusWorldDemo_i386_Release
-# ./Release/OculusWorldDemo_x86_64_Release
-# ./Release/OculusWorldDemo_i386_Debug
-# ./Release/OculusWorldDemo_x86_64_Debug
-#
-#############################################################################
-
-####### Detect system architecture
-
-SYSARCH = i386
-ifeq ($(shell uname -m),x86_64)
-SYSARCH = x86_64
-endif
-
-####### Compiler, tools and options
-
-CXX = g++
-LINK = g++
-MAKE = make
-DELETEFILE = rm -f
-DEFINES = -DQT_WEBKIT -DGL_GLEXT_PROTOTYPES
-
-####### Detect debug or release
-
-DEBUG = 0
-ifeq ($(DEBUG), 1)
- CXXFLAGS = -pipe -DDEBUG -g $(DEFINES)
- LFLAGS =
- RELEASETYPE = Debug
-else
- CXXFLAGS = -pipe -O2 $(DEFINES)
- LFLAGS = -O1
- RELEASETYPE = Release
-endif
-
-####### Paths
-
-LIBOVRPATH = ../../LibOVR
-COMMONSRCPATH = ../CommonSrc
-3RDPARTYPATH = ../../3rdParty
-INCPATH = -I. -I.. -I$(COMMONSRCPATH) -I$(LIBOVRPATH)/Include -I$(LIBOVRPATH)/Src
-OBJPATH = ./Obj/Linux/$(RELEASETYPE)/$(SYSARCH)
-CXX_BUILD = $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $(OBJPATH)/
-
-####### Files
-
-LIBS = -L$(LIBOVRPATH)/Lib/Linux/$(RELEASETYPE)/$(SYSARCH) \
- -lovr \
- -ludev \
- -lpthread \
- -lGL \
- -lX11 \
- -lXinerama
-
-OBJECTS = $(OBJPATH)/OculusWorldDemo.o \
- $(OBJPATH)/Player.o \
- $(OBJPATH)/Platform.o \
- $(OBJPATH)/Linux_Platform.o \
- $(OBJPATH)/Linux_Gamepad.o \
- $(OBJPATH)/Render_Device.o \
- $(OBJPATH)/Render_GL_Device.o \
- $(OBJPATH)/Render_LoadTextureDDS.o \
- $(OBJPATH)/Render_LoadTextureTGA.o \
- $(OBJPATH)/Render_XmlSceneLoader.o
-
-TARGET = ./Release/OculusWorldDemo_$(SYSARCH)_$(RELEASETYPE)
-
-####### Rules
-
-all: $(TARGET)
-
-$(TARGET): $(LIBOVRPATH)/Lib/Linux/$(RELEASETYPE)/$(SYSARCH)/libovr.a
- $(MAKE) -C $(LIBOVRPATH) DEBUG=$(DEBUG)
-
-$(TARGET): $(OBJECTS)
- $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(LIBS)
-
-$(OBJPATH)/OculusWorldDemo.o: OculusWorldDemo.cpp
- $(CXX_BUILD)OculusWorldDemo.o OculusWorldDemo.cpp
-
-$(OBJPATH)/Player.o: Player.cpp
- $(CXX_BUILD)Player.o Player.cpp
-
-$(OBJPATH)/Platform.o: ../../Samples/CommonSrc/Platform/Platform.cpp
- $(CXX_BUILD)Platform.o ../../Samples/CommonSrc/Platform/Platform.cpp
-
-$(OBJPATH)/Linux_Platform.o: ../../Samples/CommonSrc/Platform/Linux_Platform.cpp
- $(CXX_BUILD)Linux_Platform.o ../../Samples/CommonSrc/Platform/Linux_Platform.cpp
-
-$(OBJPATH)/Linux_Gamepad.o: ../../Samples/CommonSrc/Platform/Linux_Gamepad.cpp
- $(CXX_BUILD)Linux_Gamepad.o ../../Samples/CommonSrc/Platform/Linux_Gamepad.cpp
-
-$(OBJPATH)/Render_Device.o: ../../Samples/CommonSrc/Render/Render_Device.cpp $
- $(CXX_BUILD)Render_Device.o ../../Samples/CommonSrc/Render/Render_Device.cpp
-
-$(OBJPATH)/Render_GL_Device.o: ../../Samples/CommonSrc/Render/Render_GL_Device.cpp
- $(CXX_BUILD)Render_GL_Device.o ../../Samples/CommonSrc/Render/Render_GL_Device.cpp
-
-$(OBJPATH)/Render_LoadTextureDDS.o: ../../Samples/CommonSrc/Render/Render_LoadTextureDDS.cpp
- $(CXX_BUILD)Render_LoadTextureDDS.o ../../Samples/CommonSrc/Render/Render_LoadTextureDDS.cpp
-
-$(OBJPATH)/Render_LoadTextureTGA.o: ../../Samples/CommonSrc/Render/Render_LoadTextureTGA.cpp
- $(CXX_BUILD)Render_LoadTextureTGA.o ../../Samples/CommonSrc/Render/Render_LoadTextureTGA.cpp
-
-$(OBJPATH)/Render_XmlSceneLoader.o: ../../Samples/CommonSrc/Render/Render_XmlSceneLoader.cpp
- $(CXX_BUILD)Render_XmlSceneLoader.o ../../Samples/CommonSrc/Render/Render_XmlSceneLoader.cpp
-
-clean:
- -$(DELETEFILE) $(OBJECTS)
- -$(DELETEFILE) $(TARGET)
-
diff --git a/Samples/OculusWorldDemo/Obj/Linux/Debug/i386/readme b/Samples/OculusWorldDemo/Obj/Linux/Debug/i386/readme
deleted file mode 100644
index c9d0bc0..0000000
--- a/Samples/OculusWorldDemo/Obj/Linux/Debug/i386/readme
+++ /dev/null
@@ -1,2 +0,0 @@
-This document exits to ensure that the required directory structure gets created correctly.
-
diff --git a/Samples/OculusWorldDemo/Obj/Linux/Debug/x86_64/readme b/Samples/OculusWorldDemo/Obj/Linux/Debug/x86_64/readme
deleted file mode 100644
index c9d0bc0..0000000
--- a/Samples/OculusWorldDemo/Obj/Linux/Debug/x86_64/readme
+++ /dev/null
@@ -1,2 +0,0 @@
-This document exits to ensure that the required directory structure gets created correctly.
-
diff --git a/Samples/OculusWorldDemo/Obj/Linux/Release/i386/readme b/Samples/OculusWorldDemo/Obj/Linux/Release/i386/readme
deleted file mode 100644
index c9d0bc0..0000000
--- a/Samples/OculusWorldDemo/Obj/Linux/Release/i386/readme
+++ /dev/null
@@ -1,2 +0,0 @@
-This document exits to ensure that the required directory structure gets created correctly.
-
diff --git a/Samples/OculusWorldDemo/Obj/Linux/Release/x86_64/readme b/Samples/OculusWorldDemo/Obj/Linux/Release/x86_64/readme
deleted file mode 100644
index c9d0bc0..0000000
--- a/Samples/OculusWorldDemo/Obj/Linux/Release/x86_64/readme
+++ /dev/null
@@ -1,2 +0,0 @@
-This document exits to ensure that the required directory structure gets created correctly.
-
diff --git a/Samples/OculusWorldDemo/OculusWorldDemo.cpp b/Samples/OculusWorldDemo/OculusWorldDemo.cpp
index 1a81c8d..e89403f 100644
--- a/Samples/OculusWorldDemo/OculusWorldDemo.cpp
+++ b/Samples/OculusWorldDemo/OculusWorldDemo.cpp
@@ -1,10 +1,10 @@
/************************************************************************************
Filename : OculusWorldDemo.cpp
-Content : First-person view test application for Oculus Rift
+Content : First-person view test application for Oculus Rift - Implementation
Created : October 4, 2012
-Authors : Michael Antonov, Andrew Reisse, Steve LaValle
- Peter Hoff, Dan Goodman, Bryan Croteau
+Authors : Michael Antonov, Andrew Reisse, Steve LaValle, Dov Katz
+ Peter Hoff, Dan Goodman, Bryan Croteau
Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
@@ -22,286 +22,82 @@ limitations under the License.
*************************************************************************************/
-#include "OVR.h"
+#include "OculusWorldDemo.h"
-#include "../CommonSrc/Platform/Platform_Default.h"
-#include "../CommonSrc/Render/Render_Device.h"
-#include "../CommonSrc/Render/Render_XmlSceneLoader.h"
-#include "../CommonSrc/Render/Render_FontEmbed_DejaVu48.h"
-#include "../CommonSrc/Platform/Gamepad.h"
-
-#include <Kernel/OVR_SysFile.h>
-#include <Kernel/OVR_Log.h>
-#include <Kernel/OVR_Timer.h>
-
-#include "Player.h"
-
-// Filename to be loaded by default, searching specified paths.
-#define WORLDDEMO_ASSET_FILE "Tuscany.xml"
-#define WORLDDEMO_ASSET_PATH1 "Assets/Tuscany/"
-#define WORLDDEMO_ASSET_PATH2 "../Assets/Tuscany/"
-// This path allows the shortcut to work.
-#define WORLDDEMO_ASSET_PATH3 "Samples/OculusWorldDemo/Assets/Tuscany/"
-
-
-using namespace OVR;
-using namespace OVR::Platform;
-using namespace OVR::Render;
-
-//-------------------------------------------------------------------------------------
-// ***** OculusWorldDemo Description
-
-// This app renders a simple flat-shaded room allowing the user to move along the
-// floor and look around with an HMD, mouse and keyboard. The following keys work:
-//
-// 'W', 'S', 'A', 'D' and Arrow Keys - Move forward, back; strafe left/right.
-// F1 - No stereo, no distortion.
-// F2 - Stereo, no distortion.
-// F3 - Stereo and distortion.
-// F4 - Toggle MSAA.
-// F9 - Cycle through fullscreen and windowed modes. Necessary for previewing content with Rift.
-//
-// Important Oculus-specific logic can be found at following locations:
-//
-// OculusWorldDemoApp::OnStartup - This function will initialize OVR::DeviceManager and HMD,
-// creating SensorDevice and attaching it to SensorFusion.
-// This needs to be done before obtaining sensor data.
-//
-// OculusWorldDemoApp::OnIdle - Here we poll SensorFusion for orientation, apply it
-// to the scene and handle movement.
-// Stereo rendering is also done here, by delegating to
-// to Render function for each eye.
-//
-
-//-------------------------------------------------------------------------------------
-// ***** OculusWorldDemo Application class
-
-// An instance of this class is created on application startup (main/WinMain).
-// It then works as follows:
-// - Graphics and HMD setup is done OculusWorldDemoApp::OnStartup(). This function
-// also creates the room model from Slab declarations.
-// - Per-frame processing is done in OnIdle(). This function processes
-// sensor and movement input and then renders the frame.
-// - Additional input processing is done in OnMouse, OnKey.
-
-class OculusWorldDemoApp : public Application, public MessageHandler
-{
-public:
- OculusWorldDemoApp();
- ~OculusWorldDemoApp();
-
- virtual int OnStartup(int argc, const char** argv);
- virtual void OnIdle();
-
- virtual void OnMouseMove(int x, int y, int modifiers);
- virtual void OnKey(OVR::KeyCode key, int chr, bool down, int modifiers);
- virtual void OnResize(int width, int height);
-
- virtual void OnMessage(const Message& msg);
-
- void Render(const StereoEyeParams& stereo);
-
- // Sets temporarily displayed message for adjustments
- void SetAdjustMessage(const char* format, ...);
- // Overrides current timeout, in seconds (not the future default value);
- // intended to be called right after SetAdjustMessage.
- void SetAdjustMessageTimeout(float timeout);
-
- // Stereo setting adjustment functions.
- // Called with deltaTime when relevant key is held.
- void AdjustFov(float dt);
- void AdjustAspect(float dt);
- void AdjustIPD(float dt);
- void AdjustEyeHeight(float dt);
-
- void AdjustMotionPrediction(float dt);
-
- void AdjustDistortion(float dt, int kIndex, const char* label);
- void AdjustDistortionK0(float dt) { AdjustDistortion(dt, 0, "K0"); }
- void AdjustDistortionK1(float dt) { AdjustDistortion(dt, 1, "K1"); }
- void AdjustDistortionK2(float dt) { AdjustDistortion(dt, 2, "K2"); }
- void AdjustDistortionK3(float dt) { AdjustDistortion(dt, 3, "K3"); }
-
- void AdjustDistortion(float val, int kIndex);
- void AdjustEsd(float val);
-
- // Adds room model to scene.
- void PopulateScene(const char* fileName);
- void PopulatePreloadScene();
- void ClearScene();
-
- // Magnetometer calibration procedure
- void UpdateManualMagCalibration();
-
-protected:
- RenderDevice* pRender;
- RendererParams RenderParams;
- int Width, Height;
- int Screen;
- int FirstScreenInCycle;
-
- // *** Oculus HMD Variables
- Ptr<DeviceManager> pManager;
- Ptr<SensorDevice> pSensor;
- Ptr<HMDDevice> pHMD;
- Ptr<Profile> pUserProfile;
- SensorFusion SFusion;
- HMDInfo TheHMDInfo;
-
- Ptr<LatencyTestDevice> pLatencyTester;
- Util::LatencyTest LatencyUtil;
-
- double LastUpdate;
- int FPS;
- int FrameCounter;
- double NextFPSUpdate;
-
- Array<Ptr<CollisionModel> > CollisionModels;
- Array<Ptr<CollisionModel> > GroundCollisionModels;
-
- // Loading process displays screenshot in first frame
- // and then proceeds to load until finished.
- enum LoadingStateType
- {
- LoadingState_Frame0,
- LoadingState_DoLoad,
- LoadingState_Finished
- };
-
- // Player
- Player ThePlayer;
- Matrix4f View;
- Scene MainScene;
- Scene LoadingScene;
- Scene GridScene;
- Scene YawMarkGreenScene;
- Scene YawMarkRedScene;
- Scene YawLinesScene;
-
- LoadingStateType LoadingState;
-
- Ptr<ShaderFill> LitSolid, LitTextures[4];
-
- // Stereo view parameters.
- StereoConfig SConfig;
- PostProcessType PostProcess;
-
- // LOD
- String MainFilePath;
- Array<String> LODFilePaths;
- int ConsecutiveLowFPSFrames;
- int CurrentLODFileIndex;
-
- float DistortionK0;
- float DistortionK1;
- float DistortionK2;
- float DistortionK3;
-
- String AdjustMessage;
- double AdjustMessageTimeout;
-
- // Saved distortion state.
- float SavedK0, SavedK1, SavedK2, SavedK3;
- float SavedESD, SavedAspect, SavedEyeDistance;
-
- // Allows toggling color around distortion.
- Color DistortionClearColor;
-
- // Stereo settings adjustment state.
- typedef void (OculusWorldDemoApp::*AdjustFuncType)(float);
- bool ShiftDown;
- AdjustFuncType pAdjustFunc;
- float AdjustDirection;
-
- enum SceneRenderMode
- {
- Scene_World,
- Scene_Grid,
- Scene_Both,
- Scene_YawView
- };
- SceneRenderMode SceneMode;
-
-
- enum TextScreen
- {
- Text_None,
- Text_Orientation,
- Text_Config,
- Text_Help,
- Text_Count
- };
- TextScreen TextScreen;
-
- struct DeviceStatusNotificationDesc
- {
- DeviceHandle Handle;
- MessageType Action;
-
- DeviceStatusNotificationDesc():Action(Message_None) {}
- DeviceStatusNotificationDesc(MessageType mt, const DeviceHandle& dev)
- : Handle(dev), Action(mt) {}
- };
- Array<DeviceStatusNotificationDesc> DeviceStatusNotificationsQueue;
-
-
- Model* CreateModel(Vector3f pos, struct SlabModel* sm);
- Model* CreateBoundingModel(CollisionModel &cm);
- void PopulateLODFileNames();
- void DropLOD();
- void RaiseLOD();
- void CycleDisplay();
- void GamepadStateChanged(const GamepadState& pad);
-};
//-------------------------------------------------------------------------------------
+// ***** OculusWorldDemoApp
OculusWorldDemoApp::OculusWorldDemoApp()
: pRender(0),
- LastUpdate(0),
+ WindowSize(1280,800),
+ ScreenNumber(0),
+ FirstScreenInCycle(0),
+ Hmd(0),
+ StartSensorCaps(0),
+ UsingDebugHmd(false),
LoadingState(LoadingState_Frame0),
+ HaveVisionTracking(false),
+ HmdStatus(0),
+
// Initial location
- SConfig(),
- PostProcess(PostProcess_Distortion),
- DistortionClearColor(0, 0, 0),
-
+ DistortionClearBlue(0),
ShiftDown(false),
- pAdjustFunc(0),
- AdjustDirection(1.0f),
+ CtrlDown(false),
+ HmdSettingsChanged(false),
+
+ // Modifiable options.
+ RendertargetIsSharedByBothEyes(false),
+ DynamicRezScalingEnabled(false),
+ ForceZeroIpd(false),
+ DesiredPixelDensity(1.0f),
+ FovSideTanMax(1.0f), // Updated based on Hmd.
+ TimewarpEnabled(true),
+ TimewarpRenderIntervalInSeconds(0.0f),
+ FreezeEyeUpdate(false),
+ FreezeEyeOneFrameRendered(false),
+ CenterPupilDepthMeters(0.05f),
+ ForceZeroHeadMovement(false),
+ VsyncEnabled(true),
+ MultisampleEnabled(true),
+ IsLowPersistence(true),
+ DynamicPrediction(true),
+ PositionTrackingEnabled(true),
+
+ // Scene state
SceneMode(Scene_World),
- TextScreen(Text_None)
+ GridDisplayMode(GridDisplay_None),
+ GridMode(Grid_Lens),
+ TextScreen(Text_None),
+ BlocksShowType(0),
+ BlocksCenter(0.0f, 0.0f, 0.0f)
{
- Width = 1280;
- Height = 800;
- Screen = 0;
- FirstScreenInCycle = 0;
- FPS = 0;
- FrameCounter = 0;
- NextFPSUpdate = 0;
+ FPS = 0.0f;
+ SecondsPerFrame = 0.0f;
+ FrameCounter = 0;
+ LastFpsUpdate = 0;
- ConsecutiveLowFPSFrames = 0;
- CurrentLODFileIndex = 0;
-
- AdjustMessageTimeout = 0;
+ DistortionClearBlue = false;
}
OculusWorldDemoApp::~OculusWorldDemoApp()
{
- RemoveHandlerFromDevices();
+ CleanupDrawTextFont();
- if(DejaVu.fill)
+ if (Hmd)
{
- DejaVu.fill->Release();
+ ovrHmd_Destroy(Hmd);
+ Hmd = 0;
}
- pLatencyTester.Clear();
- pSensor.Clear();
- pHMD.Clear();
-
+
CollisionModels.ClearAndRelease();
GroundCollisionModels.ClearAndRelease();
+
+ ovr_Shutdown();
}
+
int OculusWorldDemoApp::OnStartup(int argc, const char** argv)
{
@@ -311,106 +107,84 @@ int OculusWorldDemoApp::OnStartup(int argc, const char** argv)
// Sensor object is created from the HMD, to ensure that it is on the
// correct device.
- pManager = *DeviceManager::Create();
+ ovr_Initialize();
- // We'll handle it's messages in this case.
- pManager->SetMessageHandler(this);
+ Hmd = ovrHmd_Create(0);
-
- pHMD = *pManager->EnumerateDevices<HMDDevice>().CreateDevice();
- if (pHMD)
+ if (!Hmd)
{
- pSensor = *pHMD->GetSensor();
-
- // This will initialize HMDInfo with information about configured IPD,
- // screen size and other variables needed for correct projection.
- // We pass HMD DisplayDeviceName into the renderer to select the
- // correct monitor in full-screen mode.
- if(pHMD->GetDeviceInfo(&TheHMDInfo))
- {
- //RenderParams.MonitorName = hmd.DisplayDeviceName;
- SConfig.SetHMDInfo(TheHMDInfo);
+ // If we didn't detect an Hmd, create a simulated one for debugging.
+ Hmd = ovrHmd_CreateDebug(ovrHmd_DK1);
+ UsingDebugHmd = true;
+ if (!Hmd)
+ { // Failed Hmd creation.
+ return 1;
}
-
- // Retrieve relevant profile settings.
- pUserProfile = pHMD->GetProfile();
- if (pUserProfile)
- {
- ThePlayer.UserEyeHeight = pUserProfile->GetEyeHeight();
- ThePlayer.EyePos.y = ThePlayer.UserEyeHeight;
- }
- }
- else
- {
- // If we didn't detect an HMD, try to create the sensor directly.
- // This is useful for debugging sensor interaction; it is not needed in
- // a shipping app.
- pSensor = *pManager->EnumerateDevices<SensorDevice>().CreateDevice();
- }
-
- // Create the Latency Tester device and assign it to the LatencyTesterUtil object.
- pLatencyTester = *pManager->EnumerateDevices<LatencyTestDevice>().CreateDevice();
- if (pLatencyTester)
- {
- LatencyUtil.SetDevice(pLatencyTester);
- }
- // Make the user aware which devices are present.
- if(pHMD == NULL && pSensor == NULL)
- {
- SetAdjustMessage("---------------------------------\nNO HMD DETECTED\nNO SENSOR DETECTED\n---------------------------------");
- }
- else if(pHMD == NULL)
- {
- SetAdjustMessage("----------------------------\nNO HMD DETECTED\n----------------------------");
- }
- else if(pSensor == NULL)
- {
- SetAdjustMessage("---------------------------------\nNO SENSOR DETECTED\n---------------------------------");
- }
- else
- {
- SetAdjustMessage("--------------------------------------------\n"
- "Press F9 for Full-Screen on Rift\n"
- "--------------------------------------------");
}
- // First message should be extra-long.
- SetAdjustMessageTimeout(10.0f);
+ // Get more details about the HMD.
+ ovrHmd_GetDesc(Hmd, &HmdDesc);
+ WindowSize = HmdDesc.Resolution;
- if(TheHMDInfo.HResolution > 0)
- {
- Width = TheHMDInfo.HResolution;
- Height = TheHMDInfo.VResolution;
- }
- if(!pPlatform->SetupWindow(Width, Height))
- {
+ // ***** Setup System Window & rendering.
+
+ if (!SetupWindowAndRendering(argc, argv))
return 1;
- }
- String Title = "Oculus World Demo";
- if(TheHMDInfo.ProductName[0])
- {
- Title += " : ";
- Title += TheHMDInfo.ProductName;
- }
- pPlatform->SetWindowTitle(Title);
+ // Initialize FovSideTanMax, which allows us to change all Fov sides at once - Fov
+ // starts at default and is clamped to this value.
+ FovSideTanLimit = FovPort::Max(HmdDesc.MaxEyeFov[0], HmdDesc.MaxEyeFov[1]).GetMaxSideTan();
+ FovSideTanMax = FovPort::Max(HmdDesc.DefaultEyeFov[0], HmdDesc.DefaultEyeFov[1]).GetMaxSideTan();
- // Report relative mouse motion in OnMouseMove
- pPlatform->SetMouseMode(Mouse_Relative);
+ PositionTrackingEnabled = (HmdDesc.Caps & ovrHmdCap_Position) ? true : false;
+
+
+ // *** Configure HMD Stereo settings.
- if(pSensor)
- {
- // We need to attach sensor to SensorFusion object for it to receive
- // body frame messages and update orientation. SFusion.GetOrientation()
- // is used in OnIdle() to orient the view.
- SFusion.AttachToSensor(pSensor);
+ CalculateHmdValues();
- SFusion.SetDelegateMessageHandler(this);
+ // Query eye height.
+ ThePlayer.UserEyeHeight = ovrHmd_GetFloat(Hmd, OVR_KEY_EYE_HEIGHT, ThePlayer.UserEyeHeight);
+ ThePlayer.BodyPos.y = ThePlayer.UserEyeHeight;
+ // Center pupil for customization; real game shouldn't need to adjust this.
+ CenterPupilDepthMeters = ovrHmd_GetFloat(Hmd, "CenterPupilDepth", 0.0f);
- SFusion.SetPredictionEnabled(true);
- }
+
+ ThePlayer.bMotionRelativeToBody = false; // Default to head-steering for DK1
+
+ if (UsingDebugHmd)
+ Menu.SetPopupMessage("NO HMD DETECTED");
+ else if (!(ovrHmd_GetSensorState(Hmd, 0.0f).StatusFlags & ovrStatus_OrientationTracked))
+ Menu.SetPopupMessage("NO SENSOR DETECTED");
+ else
+ Menu.SetPopupMessage("Press F9 for Full-Screen on Rift");
+ // Give first message 10 sec timeout, add border lines.
+ Menu.SetPopupTimeout(10.0f, true);
+
+ PopulateOptionMenu();
+
+ // *** Identify Scene File & Prepare for Loading
+
+ InitMainFilePath();
+ PopulatePreloadScene();
+
+ LastUpdate = ovr_GetTimeInSeconds();
+
+ return 0;
+}
+
+
+bool OculusWorldDemoApp::SetupWindowAndRendering(int argc, const char** argv)
+{
+ // *** Window creation
+
+ if (!pPlatform->SetupWindow(WindowSize.w, WindowSize.h))
+ return false;
+
+ // Report relative mouse motion in OnMouseMove
+ pPlatform->SetMouseMode(Mouse_Relative);
// *** Initialize Rendering
@@ -430,1332 +204,1065 @@ int OculusWorldDemoApp::OnStartup(int argc, const char** argv)
}
}
+ String title = "Oculus World Demo ";
+ title += graphics;
+
+ if (HmdDesc.ProductName[0])
+ {
+ title += " : ";
+ title += HmdDesc.ProductName;
+ }
+ pPlatform->SetWindowTitle(title);
+
// Enable multi-sampling by default.
- RenderParams.Multisample = 4;
+ RenderParams.Display = DisplayId(HmdDesc.DisplayDeviceName, HmdDesc.DisplayId);
+ RenderParams.Multisample = 1;
+ //RenderParams.Fullscreen = true;
pRender = pPlatform->SetupGraphics(OVR_DEFAULT_RENDER_DEVICE_SET,
graphics, RenderParams);
+ if (!pRender)
+ return false;
+ return true;
+}
+// Custom formatter for Timewarp interval message.
+static String FormatTimewarp(OptionVar* var)
+{
+ char buff[64];
+ float timewarpInterval = *var->AsFloat();
+ OVR_sprintf(buff, sizeof(buff), "%.1fms, %.1ffps",
+ timewarpInterval * 1000.0f,
+ ( timewarpInterval > 0.000001f ) ? 1.0f / timewarpInterval : 10000.0f);
+ return String(buff);
+}
- // *** Configure Stereo settings.
+static String FormatMaxFromSideTan(OptionVar* var)
+{
+ char buff[64];
+ float degrees = 2.0f * atan(*var->AsFloat()) * (180.0f / Math<float>::Pi);
+ OVR_sprintf(buff, sizeof(buff), "%.1f Degrees", degrees);
+ return String(buff);
+}
- SConfig.SetFullViewport(Viewport(0, 0, Width, Height));
- SConfig.SetStereoMode(Stereo_LeftRight_Multipass);
- // Configure proper Distortion Fit.
- // For 7" screen, fit to touch left side of the view, leaving a bit of
- // invisible screen on the top (saves on rendering cost).
- // For smaller screens (5.5"), fit to the top.
- if (TheHMDInfo.HScreenSize > 0.0f)
+void OculusWorldDemoApp::PopulateOptionMenu()
+{
+ // For shortened function member access.
+ typedef OculusWorldDemoApp OWD;
+
+ // *** Scene Content Sub-Menu
+
+ // Test
+ /*
+ Menu.AddEnum("Scene Content.EyePoseMode", &FT_EyePoseState).AddShortcutKey(Key_Y).
+ AddEnumValue("Separate Pose", 0).
+ AddEnumValue("Same Pose", 1).
+ AddEnumValue("Same Pose+TW", 2);
+ */
+
+ // Navigate between scenes.
+ Menu.AddEnum("Scene Content.Rendered Scene ';'", &SceneMode).AddShortcutKey(Key_Semicolon).
+ AddEnumValue("World", Scene_World).
+ AddEnumValue("Cubes", Scene_Cubes).
+ AddEnumValue("Oculus Cubes", Scene_OculusCubes);
+ // Animating blocks
+ Menu.AddEnum("Scene Content.Animated Blocks", &BlocksShowType).
+ AddShortcutKey(Key_B).SetNotify(this, &OWD::BlockShowChange).
+ AddEnumValue("None", 0).
+ AddEnumValue("Horizontal Circle", 1).
+ AddEnumValue("Vertical Circle", 2).
+ AddEnumValue("Bouncing Blocks", 3);
+ // Toggle grid
+ Menu.AddEnum("Scene Content.Grid Display 'G'", &GridDisplayMode).AddShortcutKey(Key_G).
+ AddEnumValue("No Grid", GridDisplay_None).
+ AddEnumValue("Grid Only", GridDisplay_GridOnly).
+ AddEnumValue("Grid And Scene", GridDisplay_GridAndScene);
+ Menu.AddEnum("Scene Content.Grid Mode 'H'", &GridMode).AddShortcutKey(Key_H).
+ AddEnumValue("4-pixel RT-centered", Grid_Rendertarget4).
+ AddEnumValue("16-pixel RT-centered",Grid_Rendertarget16).
+ AddEnumValue("Lens-centered grid", Grid_Lens);
+
+ // *** Scene Content Sub-Menu
+ Menu.AddBool( "Render Target.Share RenderTarget", &RendertargetIsSharedByBothEyes).
+ AddShortcutKey(Key_F8).SetNotify(this, &OWD::HmdSettingChange);
+ Menu.AddBool( "Render Target.Dynamic Res Scaling", &DynamicRezScalingEnabled).
+ AddShortcutKey(Key_F8, ShortcutKey::Shift_RequireOn);
+ Menu.AddBool( "Render Target.Zero IPD 'F7'", &ForceZeroIpd).
+ AddShortcutKey(Key_F7).
+ SetNotify(this, &OWD::HmdSettingChangeFreeRTs);
+ Menu.AddFloat("Render Target.Max Fov", &FovSideTanMax, 0.2f, FovSideTanLimit, 0.02f,
+ "%.1f Degrees", 1.0f, &FormatMaxFromSideTan).
+ SetNotify(this, &OWD::HmdSettingChange).
+ AddShortcutUpKey(Key_I).AddShortcutDownKey(Key_K);
+ Menu.AddFloat("Render Target.Pixel Density", &DesiredPixelDensity, 0.5f, 1.5, 0.025f, "%3.2f", 1.0f).
+ SetNotify(this, &OWD::HmdSettingChange);
+ Menu.AddEnum( "Render Target.Distortion Clear Color", &DistortionClearBlue).
+ SetNotify(this, &OWD::DistortionClearColorChange).
+ AddEnumValue("Black", 0).
+ AddEnumValue("Blue", 1);
+
+ // Timewarp
+ Menu.AddBool( "Timewarp.TimewarpEnabled 'O'", &TimewarpEnabled).AddShortcutKey(Key_O).
+ SetNotify(this, &OWD::HmdSettingChange);
+ Menu.AddBool( "Timewarp.FreezeEyeUpdate 'C'", &FreezeEyeUpdate).AddShortcutKey(Key_C);
+ Menu.AddFloat("Timewarp.RenderIntervalSeconds", &TimewarpRenderIntervalInSeconds,
+ 0.0001f, 1.00f, 0.0001f, "%.1f", 1.0f, &FormatTimewarp).
+ AddShortcutUpKey(Key_J).AddShortcutDownKey(Key_U);
+
+ // First page properties
+ Menu.AddFloat("User Eye Height", &ThePlayer.UserEyeHeight, 0.2f, 2.5f, 0.02f,
+ "%4.2f m").SetNotify(this, &OWD::EyeHeightChange).
+ AddShortcutUpKey(Key_Equal).AddShortcutDownKey(Key_Minus);
+ Menu.AddFloat("Center Pupil Depth", &CenterPupilDepthMeters, 0.0f, 0.2f, 0.001f,
+ "%4.3f m").SetNotify(this, &OWD::CenterPupilDepthChange);
+ Menu.AddBool("Body Relative Motion",&ThePlayer.bMotionRelativeToBody).AddShortcutKey(Key_E);
+ Menu.AddBool("Zero Head Movement", &ForceZeroHeadMovement) .AddShortcutKey(Key_F7, ShortcutKey::Shift_RequireOn);
+ Menu.AddBool("VSync 'V'", &VsyncEnabled) .AddShortcutKey(Key_V).SetNotify(this, &OWD::HmdSettingChange);
+ Menu.AddBool("MultiSample 'F4'", &MultisampleEnabled) .AddShortcutKey(Key_F4).SetNotify(this, &OWD::MultisampleChange);
+
+ // Add DK2 options to menu only for that headset.
+ if (HmdDesc.Caps & ovrHmdCap_Position)
{
- if (TheHMDInfo.HScreenSize > 0.140f) // 7"
- SConfig.SetDistortionFitPointVP(-1.0f, 0.0f);
- else
- SConfig.SetDistortionFitPointVP(0.0f, 1.0f);
+ Menu.AddBool("Low Persistence 'P'", &IsLowPersistence).
+ AddShortcutKey(Key_P).SetNotify(this, &OWD::HmdSettingChange);
+ Menu.AddBool("Dynamic Prediction", &DynamicPrediction).
+ SetNotify(this, &OWD::HmdSettingChange);
+ Menu.AddBool("Positional Tracking 'X'", &PositionTrackingEnabled).
+ AddShortcutKey(Key_X).SetNotify(this, &OWD::HmdSettingChange);
}
+}
- pRender->SetSceneRenderScale(SConfig.GetDistortionScale());
- //pRender->SetSceneRenderScale(1.0f);
- SConfig.Set2DAreaFov(DegreeToRad(85.0f));
+void OculusWorldDemoApp::CalculateHmdValues()
+{
+ // Initialize eye rendering information for ovrHmd_Configure.
+ // The viewport sizes are re-computed in case RenderTargetSize changed due to HW limitations.
+ ovrEyeDesc eyes[2];
+ eyes[0].Eye = ovrEye_Left;
+ eyes[1].Eye = ovrEye_Right;
+ eyes[0].Fov = HmdDesc.DefaultEyeFov[0];
+ eyes[1].Fov = HmdDesc.DefaultEyeFov[1];
+ // Clamp Fov based on our dynamically adjustable FovSideTanMax.
+ // Most apps should use the default, but reducing Fov does reduce rendering cost.
+ eyes[0].Fov = FovPort::Min(eyes[0].Fov, FovPort(FovSideTanMax));
+ eyes[1].Fov = FovPort::Min(eyes[1].Fov, FovPort(FovSideTanMax));
- // *** Identify Scene File & Prepare for Loading
-
- // This creates lights and models.
- if (argc == 2)
- {
- MainFilePath = argv[1];
- PopulateLODFileNames();
+
+ if (ForceZeroIpd)
+ {
+ // ForceZeroIpd does three things:
+ // 1) Sets FOV to maximum symmetrical FOV based on both eyes
+ // 2) Sets eye ViewAdjust values to 0.0 (effective IPD == 0)
+ // 3) Uses only the Left texture for rendering.
+
+ eyes[0].Fov = FovPort::Max(eyes[0].Fov, eyes[1].Fov);
+ eyes[1].Fov = eyes[0].Fov;
+
+ Sizei recommenedTexSize = ovrHmd_GetFovTextureSize(Hmd, ovrEye_Left,
+ eyes[0].Fov, DesiredPixelDensity);
+
+ eyes[0].TextureSize = EnsureRendertargetAtLeastThisBig(Rendertarget_Left, recommenedTexSize);
+ eyes[1].TextureSize = eyes[0].TextureSize;
+ eyes[0].RenderViewport.Pos = Vector2i(0,0);
+ eyes[0].RenderViewport.Size = Sizei::Min(eyes[0].TextureSize, recommenedTexSize);
+ eyes[1].RenderViewport = eyes[0].RenderViewport;
+
+ // Store texture pointers that will be passed for rendering.
+ EyeTexture[0] = RenderTargets[Rendertarget_Left].Tex;
+ EyeTexture[1] = RenderTargets[Rendertarget_Left].Tex;
}
+
else
{
- fprintf(stderr, "Usage: OculusWorldDemo [input XML]\n");
- MainFilePath = WORLDDEMO_ASSET_FILE;
+ // Configure Stereo settings. Default pixel density is 1.0f.
+ Sizei recommenedTex0Size = ovrHmd_GetFovTextureSize(Hmd, ovrEye_Left, eyes[0].Fov, DesiredPixelDensity);
+ Sizei recommenedTex1Size = ovrHmd_GetFovTextureSize(Hmd, ovrEye_Right, eyes[1].Fov, DesiredPixelDensity);
+
+ if (RendertargetIsSharedByBothEyes)
+ {
+ Sizei rtSize(recommenedTex0Size.w + recommenedTex1Size.w,
+ Alg::Max(recommenedTex0Size.h, recommenedTex1Size.h));
+
+ // Use returned size as the actual RT size may be different due to HW limits.
+ rtSize = EnsureRendertargetAtLeastThisBig(Rendertarget_BothEyes, rtSize);
+
+ // Don't draw more then recommended size; this also ensures that resolution reported
+ // in the overlay HUD size is updated correctly for FOV/pixel density change.
+ Sizei leftSize = Sizei::Min(Sizei(rtSize.w/2, rtSize.h), recommenedTex0Size);
+ Sizei rightSize = Sizei::Min(Sizei(rtSize.w/2, rtSize.h), recommenedTex1Size);
+
+ eyes[0].TextureSize = rtSize;
+ eyes[1].TextureSize = rtSize;
+ eyes[0].RenderViewport = Recti(Vector2i(0), leftSize);
+ eyes[1].RenderViewport = Recti(Vector2i((rtSize.w+1)/2, 0), rightSize);
+
+ // Store texture pointers that will be passed for rendering.
+ // Same texture is used, but with different viewports.
+ EyeTexture[0] = RenderTargets[Rendertarget_BothEyes].Tex;
+ EyeTexture[1] = RenderTargets[Rendertarget_BothEyes].Tex;
+ EyeTexture[0].Header.RenderViewport = eyes[0].RenderViewport;
+ EyeTexture[1].Header.RenderViewport = eyes[1].RenderViewport;
+ }
+
+ else
+ {
+ eyes[0].TextureSize = EnsureRendertargetAtLeastThisBig(Rendertarget_Left, recommenedTex0Size);
+ eyes[1].TextureSize = EnsureRendertargetAtLeastThisBig(Rendertarget_Right, recommenedTex1Size);
+ eyes[0].RenderViewport = Recti(Sizei::Min(eyes[0].TextureSize, recommenedTex0Size));
+ eyes[1].RenderViewport = Recti(Sizei::Min(eyes[1].TextureSize, recommenedTex1Size));
+
+ // Store texture pointers that will be passed for rendering.
+ EyeTexture[0] = RenderTargets[Rendertarget_Left].Tex;
+ EyeTexture[1] = RenderTargets[Rendertarget_Right].Tex;
+ }
}
- // Try to modify path for correctness in case specified file is not found.
- if (!SysFile(MainFilePath).IsValid())
+
+ unsigned hmdCaps = ovrHmdCap_Orientation | (VsyncEnabled ? 0 : ovrHmdCap_NoVSync);
+ unsigned distortionCaps = ovrDistortion_Chromatic;
+
+ ovrRenderAPIConfig config = pRender->Get_ovrRenderAPIConfig();
+
+ if (TimewarpEnabled)
+ distortionCaps |= ovrDistortion_TimeWarp;
+
+ if (!ovrHmd_ConfigureRendering( Hmd, &config, hmdCaps, distortionCaps,
+ eyes, EyeRenderDesc ))
{
- String prefixPath1(pPlatform->GetContentDirectory() + "/" + WORLDDEMO_ASSET_PATH1),
- prefixPath2(WORLDDEMO_ASSET_PATH2),
- prefixPath3(WORLDDEMO_ASSET_PATH3);
- if (SysFile(prefixPath1 + MainFilePath).IsValid())
- MainFilePath = prefixPath1 + MainFilePath;
- else if (SysFile(prefixPath2 + MainFilePath).IsValid())
- MainFilePath = prefixPath2 + MainFilePath;
- else if (SysFile(prefixPath3 + MainFilePath).IsValid())
- MainFilePath = prefixPath3 + MainFilePath;
+ // Fail exit? TBD
+ return;
}
- PopulatePreloadScene();
+ if (ForceZeroIpd)
+ {
+ // Remove IPD adjust
+ EyeRenderDesc[0].ViewAdjust = Vector3f(0);
+ EyeRenderDesc[1].ViewAdjust = Vector3f(0);
+ }
- LastUpdate = pPlatform->GetAppTime();
- //pPlatform->PlayMusicFile(L"Loop.wav");
+ // ovrHmdCap_LatencyTest - enables internal latency feedback
+ unsigned sensorCaps = ovrHmdCap_Orientation|ovrHmdCap_YawCorrection|ovrHmdCap_LatencyTest;
+ if (PositionTrackingEnabled)
+ sensorCaps |= ovrHmdCap_Position;
+ if (IsLowPersistence)
+ sensorCaps |= ovrHmdCap_LowPersistence;
+ if (DynamicPrediction)
+ sensorCaps |= ovrHmdCap_DynamicPrediction;
- return 0;
+ if (StartSensorCaps != sensorCaps)
+ {
+ ovrHmd_StartSensor(Hmd, sensorCaps, 0);
+ StartSensorCaps = sensorCaps;
+ }
+
+ // Calculate projections
+ Projection[0] = ovrMatrix4f_Projection(EyeRenderDesc[0].Desc.Fov, 0.01f, 10000.0f, true);
+ Projection[1] = ovrMatrix4f_Projection(EyeRenderDesc[1].Desc.Fov, 0.01f, 10000.0f, true);
+
+ float orthoDistance = 0.8f; // 2D is 0.8 meter from camera
+ Vector2f orthoScale0 = Vector2f(1.0f) / Vector2f(EyeRenderDesc[0].PixelsPerTanAngleAtCenter);
+ Vector2f orthoScale1 = Vector2f(1.0f) / Vector2f(EyeRenderDesc[1].PixelsPerTanAngleAtCenter);
+
+ OrthoProjection[0] = ovrMatrix4f_OrthoSubProjection(Projection[0], orthoScale0, orthoDistance,
+ EyeRenderDesc[0].ViewAdjust.x);
+ OrthoProjection[1] = ovrMatrix4f_OrthoSubProjection(Projection[1], orthoScale1, orthoDistance,
+ EyeRenderDesc[1].ViewAdjust.x);
}
-void OculusWorldDemoApp::OnMessage(const Message& msg)
+
+
+// Returns the actual size present.
+Sizei OculusWorldDemoApp::EnsureRendertargetAtLeastThisBig(int rtNum, Sizei requestedSize)
{
- if (msg.Type == Message_DeviceAdded || msg.Type == Message_DeviceRemoved)
+ OVR_ASSERT((rtNum >= 0) && (rtNum < Rendertarget_LAST));
+
+ // Texture size that we already have might be big enough.
+ Sizei newRTSize;
+
+ RenderTarget& rt = RenderTargets[rtNum];
+ if (!rt.pTex)
{
- if (msg.pDevice == pManager)
- {
- const MessageDeviceStatus& statusMsg =
- static_cast<const MessageDeviceStatus&>(msg);
+ // Hmmm... someone nuked my texture. Rez change or similar. Make sure we reallocate.
+ rt.Tex.Header.TextureSize = Sizei(0);
+ newRTSize = requestedSize;
+ }
+ else
+ {
+ newRTSize = rt.Tex.Header.TextureSize;
+ }
- { // limit the scope of the lock
- Lock::Locker lock(pManager->GetHandlerLock());
- DeviceStatusNotificationsQueue.PushBack(
- DeviceStatusNotificationDesc(statusMsg.Type, statusMsg.Handle));
- }
+ // %50 linear growth each time is a nice balance between being too greedy
+ // for a 2D surface and too slow to prevent fragmentation.
+ while ( newRTSize.w < requestedSize.w )
+ {
+ newRTSize.w += newRTSize.w/2;
+ }
+ while ( newRTSize.h < requestedSize.h )
+ {
+ newRTSize.h += newRTSize.h/2;
+ }
- switch (statusMsg.Type)
- {
- case OVR::Message_DeviceAdded:
- LogText("DeviceManager reported device added.\n");
- break;
-
- case OVR::Message_DeviceRemoved:
- LogText("DeviceManager reported device removed.\n");
- break;
-
- default: OVR_ASSERT(0); // unexpected type
- }
- }
+ // Put some sane limits on it. 4k x 4k is fine for most modern video cards.
+ // Nobody should be messing around with surfaces smaller than 4k pixels these days.
+ newRTSize = Sizei::Max(Sizei::Min(newRTSize, Sizei(4096)), Sizei(64));
+
+ // Does that require actual reallocation?
+ if (Sizei(rt.Tex.Header.TextureSize) != newRTSize)
+ {
+ rt.pTex = *pRender->CreateTexture(Texture_RGBA | Texture_RenderTarget | (MultisampleEnabled ? 4 : 1),
+ newRTSize.w, newRTSize.h, NULL);
+ rt.pTex->SetSampleMode(Sample_ClampBorder | Sample_Linear);
+
+
+ // Configure texture for SDK Rendering.
+ rt.Tex = rt.pTex->Get_ovrTexture();
}
+
+ return newRTSize;
}
+
+//-----------------------------------------------------------------------------
+// ***** Message Handlers
+
void OculusWorldDemoApp::OnResize(int width, int height)
{
- Width = width;
- Height = height;
- SConfig.SetFullViewport(Viewport(0, 0, Width, Height));
+ WindowSize = Sizei(width, height);
+ // Re-calculate?
}
void OculusWorldDemoApp::OnMouseMove(int x, int y, int modifiers)
{
+ OVR_UNUSED(y);
if(modifiers & Mod_MouseRelative)
{
// Get Delta
- int dx = x, dy = y;
-
- const float maxPitch = ((3.1415f / 2) * 0.98f);
+ int dx = x;
// Apply to rotation. Subtract for right body frame rotation,
// since yaw rotation is positive CCW when looking down on XZ plane.
- ThePlayer.EyeYaw -= (Sensitivity * dx) / 360.0f;
-
- if(!pSensor)
- {
- ThePlayer.EyePitch -= (Sensitivity * dy) / 360.0f;
-
- if(ThePlayer.EyePitch > maxPitch)
- {
- ThePlayer.EyePitch = maxPitch;
- }
- if(ThePlayer.EyePitch < -maxPitch)
- {
- ThePlayer.EyePitch = -maxPitch;
- }
- }
+ ThePlayer.BodyYaw -= (Sensitivity * dx) / 360.0f;
}
}
void OculusWorldDemoApp::OnKey(OVR::KeyCode key, int chr, bool down, int modifiers)
{
- OVR_UNUSED(chr);
+ if (Menu.OnKey(key, chr, down, modifiers))
+ return;
+
+ // Handle player movement keys.
+ if (ThePlayer.HandleMoveKey(key, down))
+ return;
switch(key)
{
case Key_Q:
if (down && (modifiers & Mod_Control))
- {
pPlatform->Exit(0);
- }
- break;
-
- // Handle player movement keys.
- // We just update movement state here, while the actual translation is done in OnIdle()
- // based on time.
- case Key_W:
- ThePlayer.MoveForward = down ? (ThePlayer.MoveForward | 1) : (ThePlayer.MoveForward & ~1);
- break;
- case Key_S:
- ThePlayer.MoveBack = down ? (ThePlayer.MoveBack | 1) : (ThePlayer.MoveBack & ~1);
- break;
- case Key_A:
- ThePlayer.MoveLeft = down ? (ThePlayer.MoveLeft | 1) : (ThePlayer.MoveLeft & ~1);
- break;
- case Key_D:
- ThePlayer.MoveRight = down ? (ThePlayer.MoveRight | 1) : (ThePlayer.MoveRight & ~1);
- break;
- case Key_Up:
- ThePlayer.MoveForward = down ? (ThePlayer.MoveForward | 2) : (ThePlayer.MoveForward & ~2);
- break;
- case Key_Down:
- ThePlayer.MoveBack = down ? (ThePlayer.MoveBack | 2) : (ThePlayer.MoveBack & ~2);
- break;
- case Key_Left:
- ThePlayer.MoveLeft = down ? (ThePlayer.MoveLeft | 2) : (ThePlayer.MoveLeft & ~2);
break;
- case Key_Right:
- ThePlayer.MoveRight = down ? (ThePlayer.MoveRight | 2) : (ThePlayer.MoveRight & ~2);
- break;
-
- case Key_Minus:
- pAdjustFunc = down ? &OculusWorldDemoApp::AdjustEyeHeight : 0;
- AdjustDirection = -1;
- break;
- case Key_Equal:
- pAdjustFunc = down ? &OculusWorldDemoApp::AdjustEyeHeight : 0;
- AdjustDirection = 1;
- break;
-
- case Key_B:
- if (down)
- {
- if(SConfig.GetDistortionScale() == 1.0f)
- {
- if(SConfig.GetHMDInfo().HScreenSize > 0.140f) // 7"
- {
- SConfig.SetDistortionFitPointVP(-1.0f, 0.0f);
- }
- else
- {
- SConfig.SetDistortionFitPointVP(0.0f, 1.0f);
- }
- }
- else
- {
- // No fitting; scale == 1.0.
- SConfig.SetDistortionFitPointVP(0, 0);
- }
- }
- break;
-
- // Support toggling background color for distortion so that we can see
- // the effect on the periphery.
- case Key_V:
- if (down)
- {
- if(DistortionClearColor.B == 0)
- {
- DistortionClearColor = Color(0, 128, 255);
- }
- else
- {
- DistortionClearColor = Color(0, 0, 0);
- }
-
- pRender->SetDistortionClearColor(DistortionClearColor);
- }
- break;
-
-
- case Key_F1:
- SConfig.SetStereoMode(Stereo_None);
- PostProcess = PostProcess_None;
- SetAdjustMessage("StereoMode: None");
- break;
- case Key_F2:
- SConfig.SetStereoMode(Stereo_LeftRight_Multipass);
- PostProcess = PostProcess_None;
- SetAdjustMessage("StereoMode: Stereo + No Distortion");
- break;
- case Key_F3:
- SConfig.SetStereoMode(Stereo_LeftRight_Multipass);
- PostProcess = PostProcess_Distortion;
- SetAdjustMessage("StereoMode: Stereo + Distortion");
- break;
-
- case Key_R:
- SFusion.Reset();
- SetAdjustMessage("Sensor Fusion Reset");
- break;
-
- case Key_Space:
- if (!down)
- {
- TextScreen = (enum TextScreen)((TextScreen + 1) % Text_Count);
- }
+
+ case Key_Escape:
+ // Back to primary windowed
+ if (!down) ChangeDisplay ( true, false, false );
break;
- case Key_F4:
- if (!down)
- {
- RenderParams = pRender->GetParams();
- RenderParams.Multisample = RenderParams.Multisample > 1 ? 1 : 4;
- pRender->SetParams(RenderParams);
- if(RenderParams.Multisample > 1)
- {
- SetAdjustMessage("Multisampling On");
- }
- else
- {
- SetAdjustMessage("Multisampling Off");
- }
- }
- break;
case Key_F9:
-#ifndef OVR_OS_LINUX // On Linux F9 does the same as F11.
- if (!down)
- {
- CycleDisplay();
- }
+#ifndef OVR_OS_LINUX
+ // Cycle through displays, going fullscreen on each one.
+ if (!down) ChangeDisplay ( false, true, false );
break;
+#else
+ // On Linux, fallthrough to F10/F11
#endif
+
#ifdef OVR_OS_MAC
- case Key_F10: // F11 is reserved on Mac
+ // F11 is reserved on Mac, F10 doesn't work on Windows
+ case Key_F10:
#else
case Key_F11:
#endif
+ if (!down) ChangeDisplay ( false, false, true );
+ break;
+
+ case Key_R:
if (!down)
{
- RenderParams = pRender->GetParams();
- RenderParams.Display = DisplayId(SConfig.GetHMDInfo().DisplayDeviceName,SConfig.GetHMDInfo().DisplayId);
- pRender->SetParams(RenderParams);
-
- pPlatform->SetMouseMode(Mouse_Normal);
- pPlatform->SetFullscreen(RenderParams, pRender->IsFullscreen() ? Display_Window : Display_FakeFullscreen);
- pPlatform->SetMouseMode(Mouse_Relative); // Avoid mode world rotation jump.
- // If using an HMD, enable post-process (for distortion) and stereo.
- if(RenderParams.IsDisplaySet() && pRender->IsFullscreen())
- {
- SConfig.SetStereoMode(Stereo_LeftRight_Multipass);
- PostProcess = PostProcess_Distortion;
- }
+ ovrHmd_ResetSensor(Hmd);
+ Menu.SetPopupMessage("Sensor Fusion Reset");
}
break;
- case Key_Escape:
- if(!down)
+ case Key_Space:
+ if (!down)
{
- // switch to primary screen windowed mode
- pPlatform->SetFullscreen(RenderParams, Display_Window);
- RenderParams.Display = pPlatform->GetDisplay(0);
- pRender->SetParams(RenderParams);
- Screen = 0;
+ TextScreen = (enum TextScreen)((TextScreen + 1) % Text_Count);
}
break;
- // Stereo adjustments.
- case Key_BracketLeft:
- pAdjustFunc = down ? &OculusWorldDemoApp::AdjustFov : 0;
- AdjustDirection = 1;
- break;
- case Key_BracketRight:
- pAdjustFunc = down ? &OculusWorldDemoApp::AdjustFov : 0;
- AdjustDirection = -1;
- break;
-
- case Key_Insert:
- case Key_Num0:
- pAdjustFunc = down ? &OculusWorldDemoApp::AdjustIPD : 0;
- AdjustDirection = 1;
+ // Distortion correction adjustments
+ case Key_Backslash:
break;
- case Key_Delete:
- case Key_Num9:
- pAdjustFunc = down ? &OculusWorldDemoApp::AdjustIPD : 0;
- AdjustDirection = -1;
- break;
-
- case Key_PageUp:
- pAdjustFunc = down ? &OculusWorldDemoApp::AdjustAspect : 0;
- AdjustDirection = 1;
- break;
- case Key_PageDown:
- pAdjustFunc = down ? &OculusWorldDemoApp::AdjustAspect : 0;
- AdjustDirection = -1;
- break;
-
- // Distortion correction adjustments
- case Key_H:
- pAdjustFunc = down ? &OculusWorldDemoApp::AdjustDistortionK0 : NULL;
- AdjustDirection = -1;
- break;
- case Key_Y:
- pAdjustFunc = down ? &OculusWorldDemoApp::AdjustDistortionK0 : NULL;
- AdjustDirection = 1;
- break;
- case Key_J:
- pAdjustFunc = down ? &OculusWorldDemoApp::AdjustDistortionK1 : NULL;
- AdjustDirection = -1;
- break;
- case Key_U:
- pAdjustFunc = down ? &OculusWorldDemoApp::AdjustDistortionK1 : NULL;
- AdjustDirection = 1;
- break;
- case Key_K:
- pAdjustFunc = down ? &OculusWorldDemoApp::AdjustDistortionK2 : NULL;
- AdjustDirection = -1;
- break;
- case Key_I:
- pAdjustFunc = down ? &OculusWorldDemoApp::AdjustDistortionK2 : NULL;
- AdjustDirection = 1;
- break;
- case Key_L:
- pAdjustFunc = down ? &OculusWorldDemoApp::AdjustDistortionK3 : NULL;
- AdjustDirection = -1;
- break;
- case Key_O:
- pAdjustFunc = down ? &OculusWorldDemoApp::AdjustDistortionK3 : NULL;
- AdjustDirection = 1;
- break;
-
- case Key_Tab:
- if (down)
- {
- float t0 = SConfig.GetDistortionK(0),
- t1 = SConfig.GetDistortionK(1),
- t2 = SConfig.GetDistortionK(2),
- t3 = SConfig.GetDistortionK(3);
- float tESD = SConfig.GetEyeToScreenDistance(),
- taspect = SConfig.GetAspectMultiplier(),
- tipd = SConfig.GetIPD();
-
- if(SavedK0 > 0.0f)
- {
- SConfig.SetDistortionK(0, SavedK0);
- SConfig.SetDistortionK(1, SavedK1);
- SConfig.SetDistortionK(2, SavedK2);
- SConfig.SetDistortionK(3, SavedK3);
- SConfig.SetEyeToScreenDistance(SavedESD);
- SConfig.SetAspectMultiplier(SavedAspect);
- SConfig.SetIPD(SavedEyeDistance);
-
- if ( ShiftDown )
- {
- // Swap saved and current values. Good for doing direct comparisons.
- SetAdjustMessage("Swapped current and saved. New settings:\n"
- "ESD:\t120 %.3f\t350 Eye:\t490 %.3f\n"
- "K0: \t120 %.4f\t350 K2: \t490 %.4f\n"
- "K1: \t120 %.4f\t350 K3: \t490 %.4f\n",
- SavedESD, SavedEyeDistance,
- SavedK0, SavedK2,
- SavedK1, SavedK3);
- SavedK0 = t0;
- SavedK1 = t1;
- SavedK2 = t2;
- SavedK3 = t3;
- SavedESD = tESD;
- SavedAspect = taspect;
- SavedEyeDistance = tipd;
- }
- else
- {
- SetAdjustMessage("Restored:\n"
- "ESD:\t120 %.3f\t350 Eye:\t490 %.3f\n"
- "K0: \t120 %.4f\t350 K2: \t490 %.4f\n"
- "K1: \t120 %.4f\t350 K3: \t490 %.4f\n",
- SavedESD, SavedEyeDistance,
- SavedK0, SavedK2,
- SavedK1, SavedK3);
- }
- }
- else
- {
- SetAdjustMessage("Setting Saved");
- SavedK0 = t0;
- SavedK1 = t1;
- SavedK2 = t2;
- SavedK3 = t3;
- SavedESD = tESD;
- SavedAspect = taspect;
- SavedEyeDistance = tipd;
- }
-
- }
- break;
-
- case Key_G:
- if (down)
- {
- if(SceneMode == Scene_World)
- {
- SceneMode = Scene_Grid;
- SetAdjustMessage("Grid Only");
- }
- else if(SceneMode == Scene_Grid)
- {
- SceneMode = Scene_Both;
- SetAdjustMessage("Grid Overlay");
- }
- else if(SceneMode == Scene_Both)
- {
- SceneMode = Scene_World;
- SetAdjustMessage("Grid Off");
- }
- }
- break;
-
// Holding down Shift key accelerates adjustment velocity.
case Key_Shift:
ShiftDown = down;
break;
-
- // Reset the camera position in case we get stuck
- case Key_T:
- ThePlayer.EyePos = Vector3f(10.0f, ThePlayer.UserEyeHeight, 10.0f);
+ case Key_Control:
+ CtrlDown = down;
break;
- case Key_F5:
- if (!down)
+ // Reset the camera position in case we get stuck
+ case Key_T:
+ if (down)
{
- UPInt numNodes = MainScene.Models.GetSize();
- for(UPInt i = 0; i < numNodes; i++)
+ struct {
+ float x, z;
+ float YawDegrees;
+ } Positions[] =
{
- Ptr<OVR::Render::Model> nodePtr = MainScene.Models[i];
- Render::Model* pNode = nodePtr.GetPtr();
- if(pNode->IsCollisionModel)
- {
- pNode->Visible = !pNode->Visible;
- }
- }
+ // x z Yaw
+ { 7.7f, -1.0f, 180.0f }, // The starting position.
+ { 10.0f, 10.0f, 90.0f }, // Outside, looking at some trees.
+ { 19.26f, 5.43f, 22.0f }, // Outside, looking at the fountain.
+ };
+
+ static int nextPosition = 0;
+ nextPosition = (nextPosition + 1) % (sizeof(Positions)/sizeof(Positions[0]));
+
+ ThePlayer.BodyPos = Vector3f(Positions[nextPosition].x,
+ ThePlayer.UserEyeHeight, Positions[nextPosition].z);
+ ThePlayer.BodyYaw = DegreeToRad( Positions[nextPosition].YawDegrees );
}
break;
- case Key_N:
- pAdjustFunc = down ? &OculusWorldDemoApp::AdjustMotionPrediction : NULL;
- AdjustDirection = -1;
+ case Key_Num1:
+ ThePlayer.BodyPos = Vector3f(-1.85f, 6.0f, -0.52f);
+ ThePlayer.BodyPos.y += ThePlayer.UserEyeHeight;
+ ThePlayer.BodyYaw = 3.1415f / 2;
+ ThePlayer.HandleMovement(0, &CollisionModels, &GroundCollisionModels, ShiftDown);
break;
- case Key_M:
- pAdjustFunc = down ? &OculusWorldDemoApp::AdjustMotionPrediction : NULL;
- AdjustDirection = 1;
+ default:
break;
+ }
+}
-/*
- case Key_N:
- RaiseLOD();
- break;
- case Key_M:
- DropLOD();
- break;
-*/
+//-----------------------------------------------------------------------------
- // Cycle through drift correction options
- case Key_Z:
- if (down)
- {
- if (SFusion.IsYawCorrectionEnabled())
- {
- SFusion.SetGravityEnabled(false);
- SFusion.SetYawCorrectionEnabled(false);
- }
- else if (SFusion.IsGravityEnabled())
- {
- SFusion.SetYawCorrectionEnabled(true);
- }
- else
- {
- SFusion.SetGravityEnabled(true);
- }
- SetAdjustMessage("Tilt Correction %s\nYaw Correction %s",
- SFusion.IsGravityEnabled() ? "On" : "Off",
- SFusion.IsYawCorrectionEnabled() ? "On" : "Off");
- }
- break;
- // Show view of yaw angles (for mag calibration/analysis)
- case Key_F6:
- if (down)
- {
- if (SceneMode != Scene_YawView)
- {
- SceneMode = Scene_YawView;
- SetAdjustMessage("Magnetometer Yaw Angle Marks");
- }
- else
- {
- SceneMode = Scene_World;
- SetAdjustMessage("Magnetometer Marks Off");
- }
- }
- break;
+Matrix4f OculusWorldDemoApp::CalculateViewFromPose(const Posef& pose)
+{
+ Posef worldPose = ThePlayer.VirtualWorldPoseFromRealPose(pose);
- case Key_C:
- if (down)
- {
- // Toggle chromatic aberration correction on/off.
- RenderDevice::PostProcessShader shader = pRender->GetPostProcessShader();
+ // Rotate and position View Camera
+ Vector3f up = worldPose.Orientation.Rotate(UpVector);
+ Vector3f forward = worldPose.Orientation.Rotate(ForwardVector);
- if (shader == RenderDevice::PostProcessShader_Distortion)
- {
- pRender->SetPostProcessShader(RenderDevice::PostProcessShader_DistortionAndChromAb);
- SetAdjustMessage("Chromatic Aberration Correction On");
- }
- else if (shader == RenderDevice::PostProcessShader_DistortionAndChromAb)
- {
- pRender->SetPostProcessShader(RenderDevice::PostProcessShader_Distortion);
- SetAdjustMessage("Chromatic Aberration Correction Off");
- }
- else
- OVR_ASSERT(false);
- }
- break;
+ // Transform the position of the center eye in the real world (i.e. sitting in your chair)
+ // into the frame of the player's virtual body.
- case Key_P:
- if (down)
- {
- // Toggle motion prediction.
- if (SFusion.IsPredictionEnabled())
- {
- SFusion.SetPredictionEnabled(false);
- SetAdjustMessage("Motion Prediction Off");
- }
- else
- {
- SFusion.SetPredictionEnabled(true);
- SetAdjustMessage("Motion Prediction On");
- }
- }
- break;
- default:
- break;
- }
+ // It is important to have head movement in scale with IPD.
+ // If you shrink one, you should also shrink the other.
+ // So with zero IPD (i.e. everything at infinity),
+ // head movement should also be zero.
+ Vector3f viewPos = ForceZeroHeadMovement ? ThePlayer.BodyPos : worldPose.Position;
+
+ Matrix4f view = Matrix4f::LookAtRH(viewPos, viewPos + forward, up);
+ return view;
}
+
+
void OculusWorldDemoApp::OnIdle()
{
+ double curtime = ovr_GetTimeInSeconds();
+ // If running slower than 10fps, clamp. Helps when debugging, because then dt can be minutes!
+ float dt = Alg::Min<float>(float(curtime - LastUpdate), 0.1f);
+ LastUpdate = curtime;
- double curtime = pPlatform->GetAppTime();
- float dt = float(curtime - LastUpdate);
- LastUpdate = curtime;
-
- // Update gamepad.
- GamepadState gamepadState;
- if (GetPlatformCore()->GetGamepadManager()->GetGamepadState(0, &gamepadState))
- {
- GamepadStateChanged(gamepadState);
- }
+ Profiler.RecordSample(RenderProfiler::Sample_FrameStart);
if (LoadingState == LoadingState_DoLoad)
{
PopulateScene(MainFilePath.ToCStr());
LoadingState = LoadingState_Finished;
return;
- }
-
- // Check if any new devices were connected.
- {
- bool queueIsEmpty = false;
- while (!queueIsEmpty)
- {
- DeviceStatusNotificationDesc desc;
-
- {
- Lock::Locker lock(pManager->GetHandlerLock());
- if (DeviceStatusNotificationsQueue.GetSize() == 0)
- break;
- desc = DeviceStatusNotificationsQueue.Front();
-
- // We can't call Clear under the lock since this may introduce a dead lock:
- // this thread is locked by HandlerLock and the Clear might cause
- // call of Device->Release, which will use Manager->DeviceLock. The bkg
- // thread is most likely locked by opposite way:
- // Manager->DeviceLock ==> HandlerLock, therefore - a dead lock.
- // So, just grab the first element, save a copy of it and remove
- // the element (Device->Release won't be called since we made a copy).
-
- DeviceStatusNotificationsQueue.RemoveAt(0);
- queueIsEmpty = (DeviceStatusNotificationsQueue.GetSize() == 0);
- }
-
- bool wasAlreadyCreated = desc.Handle.IsCreated();
-
- if (desc.Action == Message_DeviceAdded)
- {
- switch(desc.Handle.GetType())
- {
- case Device_Sensor:
- if (desc.Handle.IsAvailable() && !desc.Handle.IsCreated())
- {
- if (!pSensor)
- {
- pSensor = *desc.Handle.CreateDeviceTyped<SensorDevice>();
- if (pSensor)
- {
- SFusion.AttachToSensor(pSensor);
-
- SetAdjustMessage("---------------------------\n"
- "SENSOR connected\n"
- "---------------------------");
- }
- else
- {
- SetAdjustMessage("----------------------------\n"
- "SENSOR connect failed\n"
- "Unplug and reconnect it.\n"
- "----------------------------");
- }
- }
- else if (!wasAlreadyCreated)
- {
- LogText("A new SENSOR has been detected, but it is not currently used.");
- }
- }
- break;
- case Device_LatencyTester:
- if (desc.Handle.IsAvailable() && !desc.Handle.IsCreated())
- {
- if (!pLatencyTester)
- {
- pLatencyTester = *desc.Handle.CreateDeviceTyped<LatencyTestDevice>();
- LatencyUtil.SetDevice(pLatencyTester);
- if (!wasAlreadyCreated)
- SetAdjustMessage("----------------------------------------\n"
- "LATENCY TESTER connected\n"
- "----------------------------------------");
- }
- }
- break;
- case Device_HMD:
- {
- OVR::HMDInfo info;
- desc.Handle.GetDeviceInfo(&info);
- // if strlen(info.DisplayDeviceName) == 0 then
- // this HMD is 'fake' (created using sensor).
- if (strlen(info.DisplayDeviceName) > 0 && (!pHMD || !info.IsSameDisplay(TheHMDInfo)))
- {
- SetAdjustMessage("------------------------\n"
- "HMD connected\n"
- "------------------------");
- if (!pHMD || !desc.Handle.IsDevice(pHMD))
- pHMD = *desc.Handle.CreateDeviceTyped<HMDDevice>();
- // update stereo config with new HMDInfo
- if (pHMD && pHMD->GetDeviceInfo(&TheHMDInfo))
- {
- //RenderParams.MonitorName = hmd.DisplayDeviceName;
- SConfig.SetHMDInfo(TheHMDInfo);
- }
- LogText("HMD device added.\n");
- }
- break;
- }
- default:;
- }
- }
- else if (desc.Action == Message_DeviceRemoved)
- {
- if (desc.Handle.IsDevice(pSensor))
- {
- LogText("Sensor reported device removed.\n");
- SFusion.AttachToSensor(NULL);
- pSensor.Clear();
- SetAdjustMessage("-------------------------------\n"
- "SENSOR disconnected.\n"
- "-------------------------------");
- }
- else if (desc.Handle.IsDevice(pLatencyTester))
- {
- LogText("Latency Tester reported device removed.\n");
- LatencyUtil.SetDevice(NULL);
- pLatencyTester.Clear();
- SetAdjustMessage("---------------------------------------------\n"
- "LATENCY SENSOR disconnected.\n"
- "---------------------------------------------");
- }
- else if (desc.Handle.IsDevice(pHMD))
- {
- if (pHMD && !pHMD->IsDisconnected())
- {
- SetAdjustMessage("---------------------------\n"
- "HMD disconnected\n"
- "---------------------------");
- // Disconnect HMD. pSensor is used to restore 'fake' HMD device
- // (can be NULL).
- pHMD = pHMD->Disconnect(pSensor);
-
- // This will initialize TheHMDInfo with information about configured IPD,
- // screen size and other variables needed for correct projection.
- // We pass HMD DisplayDeviceName into the renderer to select the
- // correct monitor in full-screen mode.
- if (pHMD && pHMD->GetDeviceInfo(&TheHMDInfo))
- {
- //RenderParams.MonitorName = hmd.DisplayDeviceName;
- SConfig.SetHMDInfo(TheHMDInfo);
- }
- LogText("HMD device removed.\n");
- }
- }
- }
- else
- OVR_ASSERT(0); // unexpected action
- }
- }
+ }
- // If one of Stereo setting adjustment keys is pressed, adjust related state.
- if (pAdjustFunc)
+ if (HmdSettingsChanged)
{
- (this->*pAdjustFunc)(dt * AdjustDirection * (ShiftDown ? 5.0f : 1.0f));
+ CalculateHmdValues();
+ HmdSettingsChanged = false;
}
- // Process latency tester results.
- const char* results = LatencyUtil.GetResultsString();
- if (results != NULL)
- {
- LogText("LATENCY TESTER: %s\n", results);
- }
+ HmdFrameTiming = ovrHmd_BeginFrame(Hmd, 0);
- // >>> THIS MUST BE PLACED AS CLOSE AS POSSIBLE TO WHERE THE HMD ORIENTATION IS READ <<<
- LatencyUtil.ProcessInputs();
- // Handle Sensor motion.
- // We extract Yaw, Pitch, Roll instead of directly using the orientation
- // to allow "additional" yaw manipulation with mouse/controller.
- if(pSensor)
+ // Update gamepad.
+ GamepadState gamepadState;
+ if (GetPlatformCore()->GetGamepadManager()->GetGamepadState(0, &gamepadState))
{
- Quatf hmdOrient = SFusion.GetPredictedOrientation();
+ GamepadStateChanged(gamepadState);
+ }
- float yaw = 0.0f;
- hmdOrient.GetEulerAngles<Axis_Y, Axis_X, Axis_Z>(&yaw, &ThePlayer.EyePitch, &ThePlayer.EyeRoll);
+ SensorState ss = ovrHmd_GetSensorState(Hmd, HmdFrameTiming.ScanoutMidpointSeconds);
+ HmdStatus = ss.StatusFlags;
- ThePlayer.EyeYaw += (yaw - ThePlayer.LastSensorYaw);
- ThePlayer.LastSensorYaw = yaw;
+ // Change message status around positional tracking.
+ bool hadVisionTracking = HaveVisionTracking;
+ HaveVisionTracking = (ss.StatusFlags & Status_PositionTracked) != 0;
+ if (HaveVisionTracking && !hadVisionTracking)
+ Menu.SetPopupMessage("Vision Tracking Acquired");
+ if (!HaveVisionTracking && hadVisionTracking)
+ Menu.SetPopupMessage("Lost Vision Tracking");
+
+ // Check if any new devices were connected.
+ ProcessDeviceNotificationQueue();
+ // FPS count and timing.
+ UpdateFrameRateCounter(curtime);
- // NOTE: We can get a matrix from orientation as follows:
- // Matrix4f hmdMat(hmdOrient);
+
+ // Update pose based on frame!
+ ThePlayer.HeadPose = ss.Predicted.Transform;
+ // Movement/rotation with the gamepad.
+ ThePlayer.BodyYaw -= ThePlayer.GamepadRotate.x * dt;
+ ThePlayer.HandleMovement(dt, &CollisionModels, &GroundCollisionModels, ShiftDown);
- // Test logic - assign quaternion result directly to view:
- // Quatf hmdOrient = SFusion.GetOrientation();
- // View = Matrix4f(hmdOrient.Inverted()) * Matrix4f::Translation(-EyePos);
- }
+ // Record after processing time.
+ Profiler.RecordSample(RenderProfiler::Sample_AfterGameProcessing);
- if(curtime >= NextFPSUpdate)
- {
- NextFPSUpdate = curtime + 1.0;
- FPS = FrameCounter;
- FrameCounter = 0;
- }
- FrameCounter++;
- if(FPS < 40)
- {
- ConsecutiveLowFPSFrames++;
- }
- else
+ // Determine if we are rendering this frame. Frame rendering may be
+ // skipped based on FreezeEyeUpdate and Time-warp timing state.
+ bool bupdateRenderedView = FrameNeedsRendering(curtime);
+
+ if (bupdateRenderedView)
{
- ConsecutiveLowFPSFrames = 0;
- }
+ // If render texture size is changing, apply dynamic changes to viewport.
+ ApplyDynamicResolutionScaling();
- if(ConsecutiveLowFPSFrames > 200)
- {
- DropLOD();
- ConsecutiveLowFPSFrames = 0;
- }
+ pRender->BeginScene(PostProcess_None);
- ThePlayer.EyeYaw -= ThePlayer.GamepadRotate.x * dt;
- ThePlayer.HandleCollision(dt, &CollisionModels, &GroundCollisionModels, ShiftDown);
+ if (ForceZeroIpd)
+ {
+ // Zero IPD eye rendering: draw into left eye only,
+ // re-use texture for right eye.
+ pRender->SetRenderTarget(RenderTargets[Rendertarget_Left].pTex);
+ pRender->Clear();
+
+ ovrPosef eyeRenderPose = ovrHmd_BeginEyeRender(Hmd, ovrEye_Left);
+
+ View = CalculateViewFromPose(eyeRenderPose);
+ RenderEyeView(ovrEye_Left);
+ ovrHmd_EndEyeRender(Hmd, ovrEye_Left, eyeRenderPose, &EyeTexture[ovrEye_Left]);
- if(!pSensor)
- {
- ThePlayer.EyePitch -= ThePlayer.GamepadRotate.y * dt;
+ // Second eye gets the same texture (initialized to same value above).
+ ovrHmd_BeginEyeRender(Hmd, ovrEye_Right);
+ ovrHmd_EndEyeRender(Hmd, ovrEye_Right, eyeRenderPose, &EyeTexture[ovrEye_Right]);
+ }
- const float maxPitch = ((3.1415f / 2) * 0.98f);
- if(ThePlayer.EyePitch > maxPitch)
+ else if (RendertargetIsSharedByBothEyes)
{
- ThePlayer.EyePitch = maxPitch;
+ // Shared render target eye rendering; set up RT once for both eyes.
+ pRender->SetRenderTarget(RenderTargets[Rendertarget_BothEyes].pTex);
+ pRender->Clear();
+
+ for (int eyeIndex = 0; eyeIndex < ovrEye_Count; eyeIndex++)
+ {
+ ovrEyeType eye = HmdDesc.EyeRenderOrder[eyeIndex];
+ ovrPosef eyeRenderPose = ovrHmd_BeginEyeRender(Hmd, eye);
+
+ View = CalculateViewFromPose(eyeRenderPose);
+ RenderEyeView(eye);
+ ovrHmd_EndEyeRender(Hmd, eye, eyeRenderPose, &EyeTexture[eye]);
+ }
}
- if(ThePlayer.EyePitch < -maxPitch)
+
+ else
{
- ThePlayer.EyePitch = -maxPitch;
- }
- }
+ // Separate eye rendering - each eye gets its own render target.
+ for (int eyeIndex = 0; eyeIndex < ovrEye_Count; eyeIndex++)
+ {
+ ovrEyeType eye = HmdDesc.EyeRenderOrder[eyeIndex];
+ pRender->SetRenderTarget(
+ RenderTargets[(eye == 0) ? Rendertarget_Left : Rendertarget_Right].pTex);
+ pRender->Clear();
+
+ ovrPosef eyeRenderPose = ovrHmd_BeginEyeRender(Hmd, eye);
- // Rotate and position View Camera, using YawPitchRoll in BodyFrame coordinates.
- //
- Matrix4f rollPitchYaw = Matrix4f::RotationY(ThePlayer.EyeYaw) * Matrix4f::RotationX(ThePlayer.EyePitch) *
- Matrix4f::RotationZ(ThePlayer.EyeRoll);
- Vector3f up = rollPitchYaw.Transform(UpVector);
- Vector3f forward = rollPitchYaw.Transform(ForwardVector);
+ View = CalculateViewFromPose(eyeRenderPose);
+ RenderEyeView(eye);
+ ovrHmd_EndEyeRender(Hmd, eye, eyeRenderPose, &EyeTexture[eye]);
+ }
+ }
+ pRender->SetRenderTarget(0);
+ pRender->FinishScene();
+ }
- // Minimal head modeling; should be moved as an option to SensorFusion.
- float headBaseToEyeHeight = 0.15f; // Vertical height of eye from base of head
- float headBaseToEyeProtrusion = 0.09f; // Distance forward of eye from base of head
+ Profiler.RecordSample(RenderProfiler::Sample_AfterEyeRender);
- Vector3f eyeCenterInHeadFrame(0.0f, headBaseToEyeHeight, -headBaseToEyeProtrusion);
- Vector3f shiftedEyePos = ThePlayer.EyePos + rollPitchYaw.Transform(eyeCenterInHeadFrame);
- shiftedEyePos.y -= eyeCenterInHeadFrame.y; // Bring the head back down to original height
- View = Matrix4f::LookAtRH(shiftedEyePos, shiftedEyePos + forward, up);
+ // TODO: These happen inside ovrHmd_EndFrame; need to hook into it.
+ //Profiler.RecordSample(RenderProfiler::Sample_BeforeDistortion);
+ ovrHmd_EndFrame(Hmd);
+ Profiler.RecordSample(RenderProfiler::Sample_AfterPresent);
+}
- // Transformation without head modeling.
- // View = Matrix4f::LookAtRH(EyePos, EyePos + forward, up);
- // This is an alternative to LookAtRH:
- // Here we transpose the rotation matrix to get its inverse.
- // View = (Matrix4f::RotationY(EyeYaw) * Matrix4f::RotationX(EyePitch) *
- // Matrix4f::RotationZ(EyeRoll)).Transposed() *
- // Matrix4f::Translation(-EyePos);
+// Determine whether this frame needs rendering based on time-warp timing and flags.
+bool OculusWorldDemoApp::FrameNeedsRendering(double curtime)
+{
+ static double lastUpdate = 0.0;
+ double renderInterval = TimewarpRenderIntervalInSeconds;
+ double timeSinceLast = curtime - lastUpdate;
+ bool updateRenderedView = true;
- switch(SConfig.GetStereoMode())
+ if (TimewarpEnabled)
{
- case Stereo_None:
- Render(SConfig.GetEyeRenderParams(StereoEye_Center));
- break;
+ if (FreezeEyeUpdate)
+ {
+ // Draw one frame after (FreezeEyeUpdate = true) to update message text.
+ if (FreezeEyeOneFrameRendered)
+ updateRenderedView = false;
+ else
+ FreezeEyeOneFrameRendered = true;
+ }
+ else
+ {
+ FreezeEyeOneFrameRendered = false;
- case Stereo_LeftRight_Multipass:
- //case Stereo_LeftDouble_Multipass:
- Render(SConfig.GetEyeRenderParams(StereoEye_Left));
- Render(SConfig.GetEyeRenderParams(StereoEye_Right));
- break;
+ if ( (timeSinceLast < 0.0) || ((float)timeSinceLast > renderInterval) )
+ {
+ // This allows us to do "fractional" speeds, e.g. 45fps rendering on a 60fps display.
+ lastUpdate += renderInterval;
+ if ( timeSinceLast > 5.0 )
+ {
+ // renderInterval is probably tiny (i.e. "as fast as possible")
+ lastUpdate = curtime;
+ }
+ updateRenderedView = true;
+ }
+ else
+ {
+ updateRenderedView = false;
+ }
+ }
}
-
- pRender->Present();
- // Force GPU to flush the scene, resulting in the lowest possible latency.
- pRender->ForceFlushGPU();
+
+ return updateRenderedView;
}
-static const char* HelpText =
- "F1 \t100 NoStereo\n"
- "F2 \t100 Stereo \t420 Z \t520 Drift Correction\n"
- "F3 \t100 StereoHMD \t420 F6 \t520 Yaw Drift Info\n"
- "F4 \t100 MSAA \t420 R \t520 Reset SensorFusion\n"
- "F9 \t100 FullScreen \t420\n"
- "F11 \t100 Fast FullScreen \t500 - + \t660 Adj EyeHeight\n"
- "C \t100 Chromatic Ab \t500 [ ] \t660 Adj FOV\n"
- "P \t100 Motion Pred \t500 Shift \t660 Adj Faster\n"
- "N/M \t180 Adj Motion Pred\n"
- "( / ) \t180 Adj EyeDistance"
- ;
-
-
-enum DrawTextCenterType
-{
- DrawText_NoCenter= 0,
- DrawText_VCenter = 0x1,
- DrawText_HCenter = 0x2,
- DrawText_Center = DrawText_VCenter | DrawText_HCenter
-};
-
-static void DrawTextBox(RenderDevice* prender, float x, float y,
- float textSize, const char* text,
- DrawTextCenterType centerType = DrawText_NoCenter)
+void OculusWorldDemoApp::ApplyDynamicResolutionScaling()
{
- float ssize[2] = {0.0f, 0.0f};
-
- prender->MeasureText(&DejaVu, text, textSize, ssize);
-
- // Treat 0 a VCenter.
- if (centerType & DrawText_HCenter)
+ if (!DynamicRezScalingEnabled)
{
- x = -ssize[0]/2;
+ // Restore viewport rectangle in case dynamic res scaling was enabled before.
+ EyeTexture[0].Header.RenderViewport = EyeRenderDesc[0].Desc.RenderViewport;
+ EyeTexture[1].Header.RenderViewport = EyeRenderDesc[1].Desc.RenderViewport;
+ return;
}
- if (centerType & DrawText_VCenter)
+
+ // Demonstrate dynamic-resolution rendering.
+ // This demo is too simple to actually have a framerate that varies that much, so we'll
+ // just pretend this is trying to cope with highly dynamic rendering load.
+ float dynamicRezScale = 1.0f;
+
{
- y = -ssize[1]/2;
+ // Hacky stuff to make up a scaling...
+ // This produces value oscillating as follows: 0 -> 1 -> 0.
+ static double dynamicRezStartTime = ovr_GetTimeInSeconds();
+ float dynamicRezPhase = float ( ovr_GetTimeInSeconds() - dynamicRezStartTime );
+ const float dynamicRezTimeScale = 4.0f;
+
+ dynamicRezPhase /= dynamicRezTimeScale;
+ if ( dynamicRezPhase < 1.0f )
+ {
+ dynamicRezScale = dynamicRezPhase;
+ }
+ else if ( dynamicRezPhase < 2.0f )
+ {
+ dynamicRezScale = 2.0f - dynamicRezPhase;
+ }
+ else
+ {
+ // Reset it to prevent creep.
+ dynamicRezStartTime = ovr_GetTimeInSeconds();
+ dynamicRezScale = 0.0f;
+ }
+
+ // Map oscillation: 0.5 -> 1.0 -> 0.5
+ dynamicRezScale = dynamicRezScale * 0.5f + 0.5f;
}
- prender->FillRect(x-0.02f, y-0.02f, x+ssize[0]+0.02f, y+ssize[1]+0.02f, Color(40,40,100,210));
- prender->RenderText(&DejaVu, text, x, y, textSize, Color(255,255,0,210));
+ Sizei sizeLeft = EyeRenderDesc[0].Desc.RenderViewport.Size;
+ Sizei sizeRight = EyeRenderDesc[1].Desc.RenderViewport.Size;
+
+ // This viewport is used for rendering and passed into ovrHmd_EndEyeRender.
+ EyeTexture[0].Header.RenderViewport.Size = Sizei(int(sizeLeft.w * dynamicRezScale),
+ int(sizeLeft.h * dynamicRezScale));
+ EyeTexture[1].Header.RenderViewport.Size = Sizei(int(sizeRight.w * dynamicRezScale),
+ int(sizeRight.h * dynamicRezScale));
}
-void OculusWorldDemoApp::Render(const StereoEyeParams& stereo)
+
+void OculusWorldDemoApp::UpdateFrameRateCounter(double curtime)
{
- pRender->BeginScene(PostProcess);
+ FrameCounter++;
+ float secondsSinceLastMeasurement = (float)( curtime - LastFpsUpdate );
+
+ if (secondsSinceLastMeasurement >= SecondsOfFpsMeasurement)
+ {
+ SecondsPerFrame = (float)( curtime - LastFpsUpdate ) / (float)FrameCounter;
+ FPS = 1.0f / SecondsPerFrame;
+ LastFpsUpdate = curtime;
+ FrameCounter = 0;
+ }
+}
- // *** 3D - Configures Viewport/Projection and Render
- pRender->ApplyStereoParams(stereo);
- pRender->Clear();
+void OculusWorldDemoApp::RenderEyeView(ovrEyeType eye)
+{
+ Recti renderViewport = EyeTexture[eye].Header.RenderViewport;
+ Matrix4f viewAdjust = Matrix4f::Translation(Vector3f(EyeRenderDesc[eye].ViewAdjust));
+
+
+ // *** 3D - Configures Viewport/Projection and Render
+
+ pRender->ApplyStereoParams(renderViewport, Projection[eye]);
pRender->SetDepthMode(true, true);
- if (SceneMode != Scene_Grid)
+
+ Matrix4f baseTranslate = Matrix4f::Translation(ThePlayer.BodyPos);
+ Matrix4f baseYaw = Matrix4f::RotationY(ThePlayer.BodyYaw.Get());
+
+
+ if (GridDisplayMode != GridDisplay_GridOnly)
{
- MainScene.Render(pRender, stereo.ViewAdjust * View);
- }
+ if (SceneMode != Scene_OculusCubes)
+ {
+ MainScene.Render(pRender, viewAdjust * View);
+ RenderAnimatedBlocks(eye, ovr_GetTimeInSeconds());
+ }
+
+ if (SceneMode == Scene_Cubes)
+ {
+ // Draw scene cubes overlay. Red if position tracked, blue otherwise.
+ Scene sceneCubes = (HmdStatus & ovrStatus_PositionTracked) ?
+ RedCubesScene : BlueCubesScene;
+ sceneCubes.Render(pRender, viewAdjust * View * baseTranslate * baseYaw);
+ }
- if (SceneMode == Scene_YawView)
+ else if (SceneMode == Scene_OculusCubes)
+ {
+ OculusCubesScene.Render(pRender, viewAdjust * View * baseTranslate * baseYaw);
+ }
+ }
+
+ if (GridDisplayMode != GridDisplay_None)
{
- Matrix4f trackerOnlyOrient = Matrix4f::RotationY(ThePlayer.LastSensorYaw)
- * Matrix4f::RotationX(ThePlayer.EyePitch)
- * Matrix4f::RotationZ(ThePlayer.EyeRoll);
- YawLinesScene.Render(pRender, stereo.ViewAdjust * trackerOnlyOrient.Inverted());
- //YawMarkRedScene.Render(pRender, stereo.ViewAdjust);
+ RenderGrid(eye);
}
- // *** 2D Text & Grid - Configure Orthographic rendering.
+
+ // *** 2D Text - Configure Orthographic rendering.
// Render UI in 2D orthographic coordinate system that maps [-1,1] range
// to a readable FOV area centered at your eye and properly adjusted.
- pRender->ApplyStereoParams2D(stereo);
+ pRender->ApplyStereoParams(renderViewport, OrthoProjection[eye]);
pRender->SetDepthMode(false, false);
- float unitPixel = SConfig.Get2DUnitPixel();
- float textHeight= unitPixel * 22;
-
- if ((SceneMode == Scene_Grid)||(SceneMode == Scene_Both))
- { // Draw grid two pixels thick.
- GridScene.Render(pRender, Matrix4f());
- GridScene.Render(pRender, Matrix4f::Translation(unitPixel,unitPixel,0));
- }
+ // We set this scale up in CreateOrthoSubProjection().
+ float textHeight = 22.0f;
// Display Loading screen-shot in frame 0.
if (LoadingState != LoadingState_Finished)
{
- LoadingScene.Render(pRender, Matrix4f());
+ const float scale = textHeight * 25.0f;
+ Matrix4f view ( scale, 0.0f, 0.0f, 0.0f, scale, 0.0f, 0.0f, 0.0f, scale );
+ LoadingScene.Render(pRender, view);
String loadMessage = String("Loading ") + MainFilePath;
- DrawTextBox(pRender, 0.0f, 0.0f, textHeight, loadMessage.ToCStr(), DrawText_HCenter);
+ DrawTextBox(pRender, 0.0f, -textHeight, textHeight, loadMessage.ToCStr(), DrawText_HCenter);
LoadingState = LoadingState_DoLoad;
}
- if(!AdjustMessage.IsEmpty() && AdjustMessageTimeout > pPlatform->GetAppTime())
- {
- DrawTextBox(pRender,0.0f,0.4f, textHeight, AdjustMessage.ToCStr(), DrawText_HCenter);
- }
+ // HUD overlay brought up by spacebar.
+ RenderTextInfoHud(textHeight);
+ // Menu brought up by
+ Menu.Render(pRender);
+}
+
+
+
+// NOTE - try to keep these in sync with the PDF docs!
+static const char* HelpText1 =
+ "Spacebar \t500 Toggle debug info overlay\n"
+ "W, S \t500 Move forward, back\n"
+ "A, D \t500 Strafe left, right\n"
+ "Mouse move \t500 Look left, right\n"
+ "Left gamepad stick \t500 Move\n"
+ "Right gamepad stick \t500 Turn\n"
+ "T \t500 Reset player position";
+
+static const char* HelpText2 =
+ "R \t250 Reset sensor orientation\n"
+ "G \t250 Cycle grid overlay mode\n"
+ "-, + \t250 Adjust eye height\n"
+ "Esc \t250 Cancel full-screen\n"
+ "F4 \t250 Multisampling toggle\n"
+ "F9 \t250 Hardware full-screen (low latency)\n"
+ "F11 \t250 Faked full-screen (easier debugging)\n"
+ "Ctrl+Q \t250 Quit";
+
+
+void FormatLatencyReading(char* buff, UPInt size, float val)
+{
+ if (val < 0.000001f)
+ OVR_strcpy(buff, size, "N/A ");
+ else
+ OVR_sprintf(buff, size, "%4.2fms", val * 1000.0f);
+}
+
+
+void OculusWorldDemoApp::RenderTextInfoHud(float textHeight)
+{
+ // View port & 2D ortho projection must be set before call.
+
+ float hmdYaw, hmdPitch, hmdRoll;
switch(TextScreen)
{
- case Text_Orientation:
+ case Text_Info:
{
- char buf[256], gpustat[256];
+ char buf[512], gpustat[256];
+
+ // Average FOVs.
+ FovPort leftFov = EyeRenderDesc[0].Desc.Fov;
+ FovPort rightFov = EyeRenderDesc[1].Desc.Fov;
+
+ // Rendered size changes based on selected options & dynamic rendering.
+ int pixelSizeWidth = EyeTexture[0].Header.RenderViewport.Size.w +
+ ((!ForceZeroIpd) ?
+ EyeTexture[1].Header.RenderViewport.Size.w : 0);
+ int pixelSizeHeight = ( EyeTexture[0].Header.RenderViewport.Size.h +
+ EyeTexture[1].Header.RenderViewport.Size.h ) / 2;
+
+ // No DK2, no message.
+ char latency2Text[128] = "";
+ {
+ //float latency2 = ovrHmd_GetMeasuredLatencyTest2(Hmd) * 1000.0f; // show it in ms
+ //if (latency2 > 0)
+ // OVR_sprintf(latency2Text, sizeof(latency2Text), "%.2fms", latency2);
+
+ float latencies[3] = { 0.0f, 0.0f, 0.0f };
+ if (ovrHmd_GetFloatArray(Hmd, "DK2Latency", latencies, 3) == 3)
+ {
+ char latencyText0[32], latencyText1[32], latencyText2[32];
+ FormatLatencyReading(latencyText0, sizeof(latencyText0), latencies[0]);
+ FormatLatencyReading(latencyText1, sizeof(latencyText1), latencies[1]);
+ FormatLatencyReading(latencyText2, sizeof(latencyText2), latencies[2]);
+
+ OVR_sprintf(latency2Text, sizeof(latency2Text),
+ " DK2 Latency Ren: %s TWrp: %s\n"
+ " PostPresent: %s ",
+ latencyText0, latencyText1, latencyText2);
+ }
+ }
+
+ ThePlayer.HeadPose.Orientation.GetEulerAngles<Axis_Y, Axis_X, Axis_Z>(&hmdYaw, &hmdPitch, &hmdRoll);
OVR_sprintf(buf, sizeof(buf),
- " Yaw:%4.0f Pitch:%4.0f Roll:%4.0f \n"
- " FPS: %d Frame: %d \n Pos: %3.2f, %3.2f, %3.2f \n"
- " EyeHeight: %3.2f",
- RadToDegree(ThePlayer.EyeYaw), RadToDegree(ThePlayer.EyePitch), RadToDegree(ThePlayer.EyeRoll),
- FPS, FrameCounter, ThePlayer.EyePos.x, ThePlayer.EyePos.y, ThePlayer.EyePos.z, ThePlayer.UserEyeHeight);
+ " HMD YPR:%4.0f %4.0f %4.0f Player Yaw: %4.0f\n"
+ " FPS: %.1f ms/frame: %.1f Frame: %d\n"
+ " Pos: %3.2f, %3.2f, %3.2f HMD: %s\n"
+ " EyeHeight: %3.2f, IPD: %3.1fmm\n" //", Lens: %s\n"
+ " FOV %3.1fx%3.1f, Resolution: %ix%i\n"
+ "%s",
+ RadToDegree(hmdYaw), RadToDegree(hmdPitch), RadToDegree(hmdRoll),
+ RadToDegree(ThePlayer.BodyYaw.Get()),
+ FPS, SecondsPerFrame * 1000.0f, FrameCounter,
+ ThePlayer.BodyPos.x, ThePlayer.BodyPos.y, ThePlayer.BodyPos.z,
+ //GetDebugNameHmdType ( TheHmdRenderInfo.HmdType ),
+ HmdDesc.ProductName,
+ ThePlayer.UserEyeHeight,
+ ovrHmd_GetFloat(Hmd, OVR_KEY_IPD, 0) * 1000.0f,
+ //( EyeOffsetFromNoseLeft + EyeOffsetFromNoseRight ) * 1000.0f,
+ //GetDebugNameEyeCupType ( TheHmdRenderInfo.EyeCups ), // Lens/EyeCup not exposed
+
+ (leftFov.GetHorizontalFovDegrees() + rightFov.GetHorizontalFovDegrees()) * 0.5f,
+ (leftFov.GetVerticalFovDegrees() + rightFov.GetVerticalFovDegrees()) * 0.5f,
+
+ pixelSizeWidth, pixelSizeHeight,
+
+ latency2Text
+ );
+
size_t texMemInMB = pRender->GetTotalTextureMemoryUsage() / 1058576;
if (texMemInMB)
{
- OVR_sprintf(gpustat, sizeof(gpustat), "\n GPU Tex: %u MB", texMemInMB);
+ OVR_sprintf(gpustat, sizeof(gpustat), " GPU Tex: %u MB", texMemInMB);
OVR_strcat(buf, sizeof(buf), gpustat);
}
- DrawTextBox(pRender, 0.0f, -0.15f, textHeight, buf, DrawText_HCenter);
+ DrawTextBox(pRender, 0.0f, 0.0f, textHeight, buf, DrawText_Center);
}
break;
-
- case Text_Config:
- {
- char textBuff[2048];
-
- OVR_sprintf(textBuff, sizeof(textBuff),
- "Fov\t300 %9.4f\n"
- "EyeDistance\t300 %9.4f\n"
- "DistortionK0\t300 %9.4f\n"
- "DistortionK1\t300 %9.4f\n"
- "DistortionK2\t300 %9.4f\n"
- "DistortionK3\t300 %9.4f\n"
- "TexScale\t300 %9.4f",
- SConfig.GetYFOVDegrees(),
- SConfig.GetIPD(),
- SConfig.GetDistortionK(0),
- SConfig.GetDistortionK(1),
- SConfig.GetDistortionK(2),
- SConfig.GetDistortionK(3),
- SConfig.GetDistortionScale());
-
- DrawTextBox(pRender, 0.0f, 0.0f, textHeight, textBuff, DrawText_Center);
- }
+
+ case Text_Timing:
+ Profiler.DrawOverlay(pRender);
break;
-
- case Text_Help:
- DrawTextBox(pRender, 0.0f, -0.1f, textHeight, HelpText, DrawText_Center);
-
- default:
+
+ case Text_Help1:
+ DrawTextBox(pRender, 0.0f, 0.0f, textHeight, HelpText1, DrawText_Center);
+ break;
+ case Text_Help2:
+ DrawTextBox(pRender, 0.0f, 0.0f, textHeight, HelpText2, DrawText_Center);
+ break;
+
+ case Text_None:
break;
- }
-
- // Display colored quad if we're doing a latency test.
- Color colorToDisplay;
- if (LatencyUtil.DisplayScreenColor(colorToDisplay))
- {
- pRender->FillRect(-0.4f, -0.4f, 0.4f, 0.4f, colorToDisplay);
+ default:
+ OVR_ASSERT ( !"Missing text screen" );
+ break;
}
-
- pRender->FinishScene();
}
-// Sets temporarily displayed message for adjustments
-void OculusWorldDemoApp::SetAdjustMessage(const char* format, ...)
-{
- Lock::Locker lock(pManager->GetHandlerLock());
- char textBuff[2048];
- va_list argList;
- va_start(argList, format);
- OVR_vsprintf(textBuff, sizeof(textBuff), format, argList);
- va_end(argList);
-
- // Message will time out in 4 seconds.
- AdjustMessage = textBuff;
- AdjustMessageTimeout = pPlatform->GetAppTime() + 4.0f;
-}
-
-void OculusWorldDemoApp::SetAdjustMessageTimeout(float timeout)
-{
- AdjustMessageTimeout = pPlatform->GetAppTime() + timeout;
-}
+//-----------------------------------------------------------------------------
+// ***** Callbacks For Menu changes
-// ***** View Control Adjustments
+// Non-trivial callback go here.
-void OculusWorldDemoApp::AdjustFov(float dt)
+void OculusWorldDemoApp::HmdSettingChangeFreeRTs(OptionVar*)
{
- float esd = SConfig.GetEyeToScreenDistance() + 0.01f * dt;
- SConfig.SetEyeToScreenDistance(esd);
- SetAdjustMessage("ESD:%6.3f FOV: %6.3f", esd, SConfig.GetYFOVDegrees());
+ HmdSettingsChanged = true;
+ // Cause the RTs to be recreated with the new mode.
+ for ( int rtNum = 0; rtNum < Rendertarget_LAST; rtNum++ )
+ RenderTargets[rtNum].pTex = NULL;
}
-void OculusWorldDemoApp::AdjustAspect(float dt)
+void OculusWorldDemoApp::MultisampleChange(OptionVar*)
{
- float rawAspect = SConfig.GetAspect() / SConfig.GetAspectMultiplier();
- float newAspect = SConfig.GetAspect() + 0.01f * dt;
- SConfig.SetAspectMultiplier(newAspect / rawAspect);
- SetAdjustMessage("Aspect: %6.3f", newAspect);
+ HmdSettingChangeFreeRTs();
}
-void OculusWorldDemoApp::AdjustDistortion(float dt, int kIndex, const char* label)
+void OculusWorldDemoApp::CenterPupilDepthChange(OptionVar*)
{
- SConfig.SetDistortionK(kIndex, SConfig.GetDistortionK(kIndex) + 0.03f * dt);
- SetAdjustMessage("%s: %6.4f", label, SConfig.GetDistortionK(kIndex));
+ ovrHmd_SetFloat(Hmd, "CenterPupilDepth", CenterPupilDepthMeters);
}
-void OculusWorldDemoApp::AdjustIPD(float dt)
+void OculusWorldDemoApp::DistortionClearColorChange(OptionVar*)
{
- SConfig.SetIPD(SConfig.GetIPD() + 0.025f * dt);
- SetAdjustMessage("EyeDistance: %6.4f", SConfig.GetIPD());
+ float clearColor[2][4] = { { 0.0f, 0.0f, 0.0f, 0.0f },
+ { 0.0f, 0.5f, 1.0f, 0.0f } };
+ ovrHmd_SetFloatArray(Hmd, "DistortionClearColor",
+ clearColor[(int)DistortionClearBlue], 4);
}
-void OculusWorldDemoApp::AdjustEyeHeight(float dt)
-{
- float dist = 0.5f * dt;
-
- ThePlayer.UserEyeHeight += dist;
- ThePlayer.EyePos.y += dist;
- SetAdjustMessage("UserEyeHeight: %4.2f", ThePlayer.UserEyeHeight);
-}
+//-----------------------------------------------------------------------------
-void OculusWorldDemoApp::AdjustMotionPrediction(float dt)
+void OculusWorldDemoApp::ProcessDeviceNotificationQueue()
{
- float motionPred = SFusion.GetPredictionDelta() + 0.01f * dt;
-
- if (motionPred < 0.0f)
- {
- motionPred = 0.0f;
- }
-
- SFusion.SetPrediction(motionPred);
-
- SetAdjustMessage("MotionPrediction: %6.3fs", motionPred);
+ // TBD: Process device plug & Unplug
}
-void OculusWorldDemoApp::AdjustDistortion(float val, int kIndex)
-{
- SConfig.SetDistortionK(kIndex, val);
- SetAdjustMessage("K%d: %6.4f", kIndex, SConfig.GetDistortionK(kIndex));
-}
-void OculusWorldDemoApp::AdjustEsd(float val)
+//-----------------------------------------------------------------------------
+void OculusWorldDemoApp::ChangeDisplay ( bool bBackToWindowed, bool bNextFullscreen,
+ bool bFullWindowDebugging )
{
- SConfig.SetEyeToScreenDistance(val);
- float esd = SConfig.GetEyeToScreenDistance();
- SetAdjustMessage("ESD:%6.3f FOV: %6.3f", esd, SConfig.GetYFOVDegrees());
-}
+ // Exactly one should be set...
+ OVR_ASSERT ( ( bBackToWindowed ? 1 : 0 ) + ( bNextFullscreen ? 1 : 0 ) +
+ ( bFullWindowDebugging ? 1 : 0 ) == 1 );
+ OVR_UNUSED ( bNextFullscreen );
-// Loads the scene data
-void OculusWorldDemoApp::PopulateScene(const char *fileName)
-{
- XmlHandler xmlHandler;
- if(!xmlHandler.ReadFile(fileName, pRender, &MainScene, &CollisionModels, &GroundCollisionModels))
+ if ( bFullWindowDebugging )
{
- SetAdjustMessage("---------------------------------\nFILE LOAD FAILED\n---------------------------------");
- SetAdjustMessageTimeout(10.0f);
- }
-
- MainScene.SetAmbient(Vector4f(1.0f, 1.0f, 1.0f, 1.0f));
-
- // Distortion debug grid (brought up by 'G' key).
- Ptr<Model> gridModel = *Model::CreateGrid(Vector3f(0,0,0), Vector3f(1.0f/10, 0,0), Vector3f(0,1.0f/10,0),
- 10, 10, 5,
- Color(0, 255, 0, 255), Color(255, 50, 50, 255) );
- GridScene.World.Add(gridModel);
-
- // Yaw angle marker and lines (brought up by ';' key).
- float shifty = -0.5f;
- Ptr<Model> yawMarkGreenModel = *Model::CreateBox(Color(0, 255, 0, 255), Vector3f(0.0f, shifty, -2.0f), Vector3f(0.05f, 0.05f, 0.05f));
- YawMarkGreenScene.World.Add(yawMarkGreenModel);
- Ptr<Model> yawMarkRedModel = *Model::CreateBox(Color(255, 0, 0, 255), Vector3f(0.0f, shifty, -2.0f), Vector3f(0.05f, 0.05f, 0.05f));
- YawMarkRedScene.World.Add(yawMarkRedModel);
-
- Ptr<Model> yawLinesModel = *new Model();
- Color c = Color(255, 200, 200, 255);
- float r = 1.5f;
- yawLinesModel->AddTriangle(yawLinesModel->AddVertex(Vector3f(-0.1f, 0, -r), c),
- yawLinesModel->AddVertex(Vector3f(0, 0, -r-0.2f), c),
- yawLinesModel->AddVertex(Vector3f(0.1f, 0, -r), c));
- yawLinesModel->AddTriangle(yawLinesModel->AddVertex(Vector3f(-r-0.1f, 0, -r), c),
- yawLinesModel->AddVertex(Vector3f(-r, 0, -r-0.2f), c),
- yawLinesModel->AddVertex(Vector3f(-r+0.1f, 0, -r), c));
- yawLinesModel->AddTriangle(yawLinesModel->AddVertex(Vector3f(r-0.1f, 0, -r), c),
- yawLinesModel->AddVertex(Vector3f(r, 0, -r-0.2f), c),
- yawLinesModel->AddVertex(Vector3f(r+0.1f, 0, -r), c));
- yawLinesModel->SetPosition(Vector3f(0.0f,-1.2f,0.0f));
- YawLinesScene.World.Add(yawLinesModel);
-}
-
-
-void OculusWorldDemoApp::PopulatePreloadScene()
-{
- // Load-screen screen shot image
- String fileName = MainFilePath;
- fileName.StripExtension();
-
- Ptr<File> imageFile = *new SysFile(fileName + "_LoadScreen.tga");
- Ptr<Texture> imageTex;
- if (imageFile->IsValid())
- imageTex = *LoadTextureTga(pRender, imageFile);
+ // Slightly hacky. Doesn't actually go fullscreen, just makes a screen-sized wndow.
+ // This has higher latency than fullscreen, and is not intended for actual use,
+ // but makes for much nicer debugging on some systems.
+ RenderParams = pRender->GetParams();
+ RenderParams.Display = DisplayId(HmdDesc.DisplayDeviceName, HmdDesc.DisplayId);
+ pRender->SetParams(RenderParams);
- // Image is rendered as a single quad.
- if (imageTex)
- {
- imageTex->SetSampleMode(Sample_Anisotropic|Sample_Repeat);
- Ptr<Model> m = *new Model(Prim_Triangles);
- m->AddVertex(-0.5f, 0.5f, 0.0f, Color(255,255,255,255), 0.0f, 0.0f);
- m->AddVertex( 0.5f, 0.5f, 0.0f, Color(255,255,255,255), 1.0f, 0.0f);
- m->AddVertex( 0.5f, -0.5f, 0.0f, Color(255,255,255,255), 1.0f, 1.0f);
- m->AddVertex(-0.5f, -0.5f, 0.0f, Color(255,255,255,255), 0.0f, 1.0f);
- m->AddTriangle(2,1,0);
- m->AddTriangle(0,3,2);
-
- Ptr<ShaderFill> fill = *new ShaderFill(*pRender->CreateShaderSet());
- fill->GetShaders()->SetShader(pRender->LoadBuiltinShader(Shader_Vertex, VShader_MVP));
- fill->GetShaders()->SetShader(pRender->LoadBuiltinShader(Shader_Fragment, FShader_Texture));
- fill->SetTexture(0, imageTex);
- m->Fill = fill;
-
- LoadingScene.World.Add(m);
+ pPlatform->SetMouseMode(Mouse_Normal);
+ pPlatform->SetFullscreen(RenderParams, pRender->IsFullscreen() ? Display_Window : Display_FakeFullscreen);
+ pPlatform->SetMouseMode(Mouse_Relative); // Avoid mode world rotation jump.
+
+ // If using an HMD, enable post-process (for distortion) and stereo.
+ if (RenderParams.IsDisplaySet() && pRender->IsFullscreen())
+ {
+ //SetPostProcessingMode ( PostProcess );
+ }
}
-}
-
-void OculusWorldDemoApp::ClearScene()
-{
- MainScene.Clear();
- GridScene.Clear();
- YawMarkGreenScene.Clear();
- YawMarkRedScene.Clear();
- YawLinesScene.Clear();
-}
-
-void OculusWorldDemoApp::PopulateLODFileNames()
-{
- //OVR::String mainFilePath = MainFilePath;
- LODFilePaths.PushBack(MainFilePath);
- int LODIndex = 1;
- SPInt pos = strcspn(MainFilePath.ToCStr(), ".");
- SPInt len = strlen(MainFilePath.ToCStr());
- SPInt diff = len - pos;
-
- if (diff == 0)
- return;
-
- while(true)
+ else
{
- char pathWithoutExt[250];
- char buffer[250];
- for(SPInt i = 0; i < pos; ++i)
+ int screenCount = pPlatform->GetDisplayCount();
+
+ int screenNumberToSwitchTo;
+ if ( bBackToWindowed )
{
- pathWithoutExt[i] = MainFilePath[(int)i];
+ screenNumberToSwitchTo = -1;
}
- pathWithoutExt[pos] = '\0';
- OVR_sprintf(buffer, sizeof(buffer), "%s%i.xml", pathWithoutExt, LODIndex);
- FILE* fp = 0;
-#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
- errno_t err = fopen_s(&fp, buffer, "rb");
- if(!fp || err)
+ else
{
-#else
- fp = fopen(buffer, "rb");
- if(!fp)
- {
-#endif
- break;
+ if (!pRender->IsFullscreen())
+ {
+ // Currently windowed.
+ // Try to find HMD Screen, making it the first screen in the full-screen cycle.
+ FirstScreenInCycle = 0;
+ if (!UsingDebugHmd)
+ {
+ DisplayId HMD (HmdDesc.DisplayDeviceName, HmdDesc.DisplayId);
+ for (int i = 0; i< screenCount; i++)
+ {
+ if (pPlatform->GetDisplay(i) == HMD)
+ {
+ FirstScreenInCycle = i;
+ break;
+ }
+ }
+ }
+ ScreenNumber = FirstScreenInCycle;
+ screenNumberToSwitchTo = ScreenNumber;
+ }
+ else
+ {
+ // Currently fullscreen, so cycle to the next screen.
+ ScreenNumber++;
+ if (ScreenNumber == screenCount)
+ {
+ ScreenNumber = 0;
+ }
+ screenNumberToSwitchTo = ScreenNumber;
+ if (ScreenNumber == FirstScreenInCycle)
+ {
+ // We have cycled through all the fullscreen displays, so go back to windowed mode.
+ screenNumberToSwitchTo = -1;
+ }
+ }
}
- fclose(fp);
- OVR::String result = buffer;
- LODFilePaths.PushBack(result);
- LODIndex++;
- }
-}
-
-void OculusWorldDemoApp::DropLOD()
-{
- if(CurrentLODFileIndex < (int)(LODFilePaths.GetSize() - 1))
- {
- ClearScene();
- CurrentLODFileIndex++;
- PopulateScene(LODFilePaths[CurrentLODFileIndex].ToCStr());
- }
-}
-void OculusWorldDemoApp::RaiseLOD()
-{
- if(CurrentLODFileIndex > 0)
- {
- ClearScene();
- CurrentLODFileIndex--;
- PopulateScene(LODFilePaths[CurrentLODFileIndex].ToCStr());
- }
-}
-
-//-----------------------------------------------------------------------------
-void OculusWorldDemoApp::CycleDisplay()
-{
- int screenCount = pPlatform->GetDisplayCount();
-
- // If Windowed, switch to the HMD screen first in Full-Screen Mode.
- // If already Full-Screen, cycle to next screen until we reach FirstScreenInCycle.
-
- if (pRender->IsFullscreen())
- {
- // Right now, we always need to restore window before going to next screen.
+ // Always restore windowed mode before going to next screen, even if we were already fullscreen.
pPlatform->SetFullscreen(RenderParams, Display_Window);
-
- Screen++;
- if (Screen == screenCount)
- Screen = 0;
-
- RenderParams.Display = pPlatform->GetDisplay(Screen);
-
- if (Screen != FirstScreenInCycle)
+ if ( screenNumberToSwitchTo >= 0 )
{
+ // Go fullscreen.
+ RenderParams.Display = pPlatform->GetDisplay(screenNumberToSwitchTo);
pRender->SetParams(RenderParams);
- pPlatform->SetFullscreen(RenderParams, Display_Fullscreen);
+ pPlatform->SetFullscreen(RenderParams, Display_Fullscreen);
}
}
- else
- {
- // Try to find HMD Screen, making it the first screen in full-screen Cycle.
- FirstScreenInCycle = 0;
-
- if (pHMD)
- {
- DisplayId HMD (SConfig.GetHMDInfo().DisplayDeviceName, SConfig.GetHMDInfo().DisplayId);
- for (int i = 0; i< screenCount; i++)
- {
- if (pPlatform->GetDisplay(i) == HMD)
- {
- FirstScreenInCycle = i;
- break;
- }
- }
- }
- // Switch full-screen on the HMD.
- Screen = FirstScreenInCycle;
- RenderParams.Display = pPlatform->GetDisplay(Screen);
- pRender->SetParams(RenderParams);
- pPlatform->SetFullscreen(RenderParams, Display_Fullscreen);
- }
+
+ // Updates render target pointers & sizes.
+ HmdSettingChangeFreeRTs();
}
void OculusWorldDemoApp::GamepadStateChanged(const GamepadState& pad)
@@ -1764,6 +1271,15 @@ void OculusWorldDemoApp::GamepadStateChanged(const GamepadState& pad)
0,
pad.LY * pad.LY * (pad.LY > 0 ? -1 : 1));
ThePlayer.GamepadRotate = Vector3f(2 * pad.RX, -2 * pad.RY, 0);
+
+ UInt32 gamepadDeltas = (pad.Buttons ^ LastGamepadState.Buttons) & pad.Buttons;
+
+ if (gamepadDeltas)
+ {
+ Menu.OnGamepad(gamepadDeltas);
+ }
+
+ LastGamepadState = pad;
}
diff --git a/Samples/OculusWorldDemo/OculusWorldDemo.h b/Samples/OculusWorldDemo/OculusWorldDemo.h
new file mode 100644
index 0000000..54f0e9d
--- /dev/null
+++ b/Samples/OculusWorldDemo/OculusWorldDemo.h
@@ -0,0 +1,339 @@
+/************************************************************************************
+
+Filename : OculusWorldDemo.h
+Content : First-person view test application for Oculus Rift - Header file
+Created : October 4, 2012
+Authors : Michael Antonov, Andrew Reisse, Steve LaValle, Dov Katz
+ Peter Hoff, Dan Goodman, Bryan Croteau
+
+Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+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 INC_OculusWorldDemo_h
+#define INC_OculusWorldDemo_h
+
+#include "OVR.h"
+
+#include "../CommonSrc/Platform/Platform_Default.h"
+#include "../CommonSrc/Render/Render_Device.h"
+#include "../CommonSrc/Render/Render_XmlSceneLoader.h"
+#include "../CommonSrc/Platform/Gamepad.h"
+
+#include "Util/Util_Render_Stereo.h"
+using namespace OVR::Util::Render;
+
+#include <Kernel/OVR_SysFile.h>
+#include <Kernel/OVR_Log.h>
+#include <Kernel/OVR_Timer.h>
+
+#include "Player.h"
+#include "OVR_DeviceConstants.h"
+
+#include "OptionMenu.h"
+#include "RenderProfiler.h"
+
+// Filename to be loaded by default, searching specified paths.
+#define WORLDDEMO_ASSET_FILE "Tuscany.xml"
+
+#define WORLDDEMO_ASSET_PATH1 "Assets/Tuscany/"
+#define WORLDDEMO_ASSET_PATH2 "../../../Assets/Tuscany/"
+// This path allows the shortcut to work.
+#define WORLDDEMO_ASSET_PATH3 "Samples/OculusWorldDemo/Assets/Tuscany/"
+
+using namespace OVR;
+using namespace OVR::Platform;
+using namespace OVR::Render;
+
+
+//-------------------------------------------------------------------------------------
+// ***** OculusWorldDemo Description
+
+// This app renders a loaded scene allowing the user to move along the
+// floor and look around with an HMD, mouse and keyboard. The following keys work:
+//
+// 'W', 'S', 'A', 'D' and Arrow Keys - Move forward, back; strafe left/right.
+//
+// Space - Bring up status and help display.
+// Tab - Bring up/hide menu with editable options.
+// F4 - Toggle MSAA.
+// F9 - Cycle through fullscreen and windowed modes.
+// Necessary for previewing content with Rift.
+//
+// Important Oculus-specific logic can be found at following locations:
+//
+// OculusWorldDemoApp::OnStartup - This function will initialize the SDK, creating the Hmd
+// and delegating to CalculateHmdValues to initialize it.
+//
+// OculusWorldDemoApp::OnIdle - Here we poll SensorFusion for orientation, apply it
+// to the scene and handle movement.
+// Stereo rendering is also done here, by delegating to
+// to the RenderEyeView() function for each eye.
+//
+
+//-------------------------------------------------------------------------------------
+// ***** OculusWorldDemo Application class
+
+// An instance of this class is created on application startup (main/WinMain).
+// It then works as follows:
+// - Graphics and HMD setup is done OculusWorldDemoApp::OnStartup(). Much of
+// HMD configuration here is moved to CalculateHmdValues.
+// OnStartup also creates the room model from Slab declarations.
+//
+// - Per-frame processing is done in OnIdle(). This function processes
+// sensor and movement input and then renders the frame.
+//
+// - Additional input processing is done in OnMouse, OnKey.
+
+class OculusWorldDemoApp : public Application
+{
+public:
+ OculusWorldDemoApp();
+ ~OculusWorldDemoApp();
+
+ virtual int OnStartup(int argc, const char** argv);
+ virtual void OnIdle();
+
+ virtual void OnMouseMove(int x, int y, int modifiers);
+ virtual void OnKey(OVR::KeyCode key, int chr, bool down, int modifiers);
+ virtual void OnResize(int width, int height);
+
+ bool SetupWindowAndRendering(int argc, const char** argv);
+
+ // Adds room model to scene.
+ void InitMainFilePath();
+ void PopulateScene(const char* fileName);
+ void PopulatePreloadScene();
+ void ClearScene();
+ void PopulateOptionMenu();
+
+
+ // Computes all of the Hmd values and configures render targets.
+ void CalculateHmdValues();
+ // Returns the actual size present.
+ Sizei EnsureRendertargetAtLeastThisBig (int rtNum, Sizei size);
+
+
+ // Renders full stereo scene for one eye.
+ void RenderEyeView(ovrEyeType eye);
+ // Renderes HUD overlay brough up by spacebar; 2D viewport must be set before call.
+ void RenderTextInfoHud(float textHeight);
+ void RenderAnimatedBlocks(ovrEyeType eye, double appTime);
+ void RenderGrid(ovrEyeType eye);
+
+ Matrix4f CalculateViewFromPose(const Posef& pose);
+
+ // Determine whether this frame needs rendering based on timewarp timing and flags.
+ bool FrameNeedsRendering(double curtime);
+ void ApplyDynamicResolutionScaling();
+ void UpdateFrameRateCounter(double curtime);
+
+
+ // Model creation and misc functions.
+ Model* CreateModel(Vector3f pos, struct SlabModel* sm);
+ Model* CreateBoundingModel(CollisionModel &cm);
+ void ChangeDisplay ( bool bBackToWindowed, bool bNextFullscreen, bool bFullWindowDebugging );
+ void GamepadStateChanged(const GamepadState& pad);
+
+ // Processes DeviceNotificationStatus queue to handles plug/unplug.
+ void ProcessDeviceNotificationQueue();
+
+
+ // ***** Callbacks for Menu option changes
+
+ // These contain extra actions to be taken in addition to switching the state.
+ void HmdSettingChange(OptionVar* = 0) { HmdSettingsChanged = true; }
+ void BlockShowChange(OptionVar* = 0) { BlocksCenter = ThePlayer.BodyPos; }
+ void EyeHeightChange(OptionVar* = 0) { ThePlayer.BodyPos.y = ThePlayer.UserEyeHeight; }
+
+ void HmdSettingChangeFreeRTs(OptionVar* = 0);
+ void MultisampleChange(OptionVar* = 0);
+ void CenterPupilDepthChange(OptionVar* = 0);
+ void DistortionClearColorChange(OptionVar* = 0);
+
+
+protected:
+ RenderDevice* pRender;
+ RendererParams RenderParams;
+ Sizei WindowSize;
+ int ScreenNumber;
+ int FirstScreenInCycle;
+
+ struct RenderTarget
+ {
+ Ptr<Texture> pTex;
+ ovrTexture Tex;
+ };
+ enum RendertargetsEnum
+ {
+ Rendertarget_Left,
+ Rendertarget_Right,
+ Rendertarget_BothEyes, // Used when both eyes are rendered to the same target.
+ Rendertarget_LAST
+ };
+ RenderTarget RenderTargets[Rendertarget_LAST];
+
+
+ // ***** Oculus HMD Variables
+
+ ovrHmd Hmd;
+ ovrHmdDesc HmdDesc;
+ ovrEyeRenderDesc EyeRenderDesc[2];
+ Matrix4f Projection[2]; // Projection matrix for eye.
+ Matrix4f OrthoProjection[2]; // Projection for 2D.
+ ovrTexture EyeTexture[2];
+ // Sensor caps applied.
+ unsigned StartSensorCaps;
+ bool UsingDebugHmd;
+
+ // Frame timing logic.
+ enum { SecondsOfFpsMeasurement = 1 };
+ int FrameCounter;
+ double NextFPSUpdate;
+ float SecondsPerFrame;
+ float FPS;
+ double LastFpsUpdate;
+
+ // Times a single frame.
+ double LastUpdate;
+
+ // Loaded data.
+ String MainFilePath;
+ Array<Ptr<CollisionModel> > CollisionModels;
+ Array<Ptr<CollisionModel> > GroundCollisionModels;
+
+ // Loading process displays screenshot in first frame
+ // and then proceeds to load until finished.
+ enum LoadingStateType
+ {
+ LoadingState_Frame0,
+ LoadingState_DoLoad,
+ LoadingState_Finished
+ } LoadingState;
+
+ // Set when vision tracking is detected.
+ bool HaveVisionTracking;
+
+ GamepadState LastGamepadState;
+
+ Player ThePlayer;
+ Matrix4f View;
+ Scene MainScene;
+ Scene LoadingScene;
+ Scene SmallGreenCube;
+
+ Scene OculusCubesScene;
+ Scene RedCubesScene;
+ Scene BlueCubesScene;
+
+ // Last frame asn sensor data reported by BeginFrame().
+ ovrFrameTiming HmdFrameTiming;
+ unsigned HmdStatus;
+
+
+ // ***** Modifiable Menu Options
+
+ // This flag is set when HMD settings change, causing HMD to be re-initialized.
+ bool HmdSettingsChanged;
+
+ // Render Target - affecting state.
+ bool RendertargetIsSharedByBothEyes;
+ bool DynamicRezScalingEnabled;
+ bool ForceZeroIpd;
+ float DesiredPixelDensity;
+ float FovSideTanMax;
+ float FovSideTanLimit; // Limit value for Fov.
+ // Time-warp.
+ bool TimewarpEnabled;
+ float TimewarpRenderIntervalInSeconds;
+ bool FreezeEyeUpdate;
+ bool FreezeEyeOneFrameRendered;
+
+ // Other global settings.
+ float CenterPupilDepthMeters;
+ // float IPD;
+ bool ForceZeroHeadMovement;
+ bool VsyncEnabled;
+ bool MultisampleEnabled;
+ // DK2 only
+ bool IsLowPersistence;
+ bool DynamicPrediction;
+ bool PositionTrackingEnabled;
+
+ // Support toggling background color for distortion so that we can see
+ // the effect on the periphery.
+ int DistortionClearBlue;
+
+ // Stereo settings adjustment state.
+ bool ShiftDown;
+ bool CtrlDown;
+
+
+ // ***** Scene Rendering Modes
+
+ enum SceneRenderMode
+ {
+ Scene_World,
+ Scene_Cubes,
+ Scene_OculusCubes
+ };
+ SceneRenderMode SceneMode;
+
+ enum GridDispayModeType
+ {
+ GridDisplay_None,
+ GridDisplay_GridOnly,
+ GridDisplay_GridAndScene
+ };
+ GridDispayModeType GridDisplayMode;
+
+ // What type of grid to display.
+ enum GridModeType
+ {
+ Grid_Rendertarget4,
+ Grid_Rendertarget16,
+ Grid_Lens,
+ Grid_Last
+ };
+ GridModeType GridMode;
+
+ // What help screen we display, brought up by 'Spacebar'.
+ enum TextScreen
+ {
+ Text_None,
+ Text_Info,
+ Text_Timing,
+ Text_Help1,
+ Text_Help2,
+ Text_Count
+ };
+ TextScreen TextScreen;
+
+ // Whether we are displaying animated blocks and what type.
+ int BlocksShowType;
+ Vector3f BlocksCenter;
+
+
+ // User configurable options, brought up by 'Tab' key.
+ // Also handles shortcuts and pop-up overlay messages.
+ OptionSelectionMenu Menu;
+
+ // Profiler for rendering - displays timing stats.
+ RenderProfiler Profiler;
+};
+
+
+
+#endif // INC_OculusWorldDemo_h
diff --git a/Samples/OculusWorldDemo/OculusWorldDemo_Msvc2010.vcxproj.filters b/Samples/OculusWorldDemo/OculusWorldDemo_Msvc2010.vcxproj.filters
deleted file mode 100644
index e96dc9e..0000000
--- a/Samples/OculusWorldDemo/OculusWorldDemo_Msvc2010.vcxproj.filters
+++ /dev/null
@@ -1,89 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="CommonSrc">
- <UniqueIdentifier>{ba6e9e50-0655-4f12-a136-6d2a06015925}</UniqueIdentifier>
- </Filter>
- <Filter Include="CommonSrc\Platform">
- <UniqueIdentifier>{16e20d8b-eff7-454c-be85-02037c399e97}</UniqueIdentifier>
- </Filter>
- <Filter Include="CommonSrc\Render">
- <UniqueIdentifier>{1b6d51ae-a405-4f3d-be93-41a50db4f328}</UniqueIdentifier>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="..\CommonSrc\Platform\Platform.cpp">
- <Filter>CommonSrc\Platform</Filter>
- </ClCompile>
- <ClCompile Include="..\CommonSrc\Platform\Win32_Platform.cpp">
- <Filter>CommonSrc\Platform</Filter>
- </ClCompile>
- <ClCompile Include="..\CommonSrc\Render\Render_Device.cpp">
- <Filter>CommonSrc\Render</Filter>
- </ClCompile>
- <ClCompile Include="..\CommonSrc\Render\Render_D3D1X_Device.cpp">
- <Filter>CommonSrc\Render</Filter>
- </ClCompile>
- <ClCompile Include="..\CommonSrc\Render\Render_D3D10_Device.cpp">
- <Filter>CommonSrc\Render</Filter>
- </ClCompile>
- <ClCompile Include="OculusWorldDemo.cpp" />
- <ClCompile Include="..\CommonSrc\Render\Render_D3D11_Device.cpp">
- <Filter>CommonSrc\Render</Filter>
- </ClCompile>
- <ClCompile Include="..\CommonSrc\Render\Render_LoadTextureTGA.cpp">
- <Filter>CommonSrc\Render</Filter>
- </ClCompile>
- <ClCompile Include="Player.cpp" />
- <ClCompile Include="..\..\3rdParty\TinyXml\tinyxml2.cpp" />
- <ClCompile Include="..\CommonSrc\Render\Render_LoadTextureDDS.cpp">
- <Filter>CommonSrc\Render</Filter>
- </ClCompile>
- <ClCompile Include="..\CommonSrc\Render\Render_XmlSceneLoader.cpp">
- <Filter>CommonSrc\Render</Filter>
- </ClCompile>
- <ClCompile Include="..\CommonSrc\Platform\Win32_Gamepad.cpp">
- <Filter>CommonSrc\Platform</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="..\CommonSrc\Platform\Win32_Platform.h">
- <Filter>CommonSrc\Platform</Filter>
- </ClInclude>
- <ClInclude Include="..\CommonSrc\Platform\Platform.h">
- <Filter>CommonSrc\Platform</Filter>
- </ClInclude>
- <ClInclude Include="..\CommonSrc\Platform\Platform_Default.h">
- <Filter>CommonSrc\Platform</Filter>
- </ClInclude>
- <ClInclude Include="..\CommonSrc\Render\Render_Font.h">
- <Filter>CommonSrc\Render</Filter>
- </ClInclude>
- <ClInclude Include="..\CommonSrc\Render\Render_Device.h">
- <Filter>CommonSrc\Render</Filter>
- </ClInclude>
- <ClInclude Include="..\CommonSrc\Render\Render_D3D1X_Device.h">
- <Filter>CommonSrc\Render</Filter>
- </ClInclude>
- <ClInclude Include="..\CommonSrc\Render\Render_D3D10_Device.h">
- <Filter>CommonSrc\Render</Filter>
- </ClInclude>
- <ClInclude Include="..\CommonSrc\Render\Render_D3D11_Device.h">
- <Filter>CommonSrc\Render</Filter>
- </ClInclude>
- <ClInclude Include="Player.h" />
- <ClInclude Include="..\..\3rdParty\TinyXml\tinyxml2.h" />
- <ClInclude Include="..\CommonSrc\Render\Render_XmlSceneLoader.h">
- <Filter>CommonSrc\Render</Filter>
- </ClInclude>
- <ClInclude Include="..\CommonSrc\Platform\Gamepad.h">
- <Filter>CommonSrc\Platform</Filter>
- </ClInclude>
- <ClInclude Include="..\CommonSrc\Platform\Win32_Gamepad.h">
- <Filter>CommonSrc\Platform</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="OculusWorldDemo.rc" />
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/Samples/OculusWorldDemo/OculusWorldDemo_Scene.cpp b/Samples/OculusWorldDemo/OculusWorldDemo_Scene.cpp
new file mode 100644
index 0000000..5dfe2d2
--- /dev/null
+++ b/Samples/OculusWorldDemo/OculusWorldDemo_Scene.cpp
@@ -0,0 +1,399 @@
+/************************************************************************************
+
+Filename : OculusWorldDemo_Scene.cpp
+Content : Logic for loading, and creating rendered scene components,
+ cube and grid overlays, etc.
+Created : October 4, 2012
+Authors : Michael Antonov, Andrew Reisse, Steve LaValle, Dov Katz
+ Peter Hoff, Dan Goodman, Bryan Croteau
+
+Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+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.
+
+*************************************************************************************/
+
+#include "OculusWorldDemo.h"
+
+
+//-------------------------------------------------------------------------------------
+// ***** Scene Creation / Loading
+
+void OculusWorldDemoApp::InitMainFilePath()
+{
+
+ MainFilePath = WORLDDEMO_ASSET_FILE;
+
+ // Try to modify path for correctness in case specified file is not found.
+ if (!SysFile(MainFilePath).IsValid())
+ {
+ String prefixPath1(pPlatform->GetContentDirectory() + "/" + WORLDDEMO_ASSET_PATH1),
+ prefixPath2(WORLDDEMO_ASSET_PATH2),
+ prefixPath3(WORLDDEMO_ASSET_PATH3);
+ if (SysFile(prefixPath1 + MainFilePath).IsValid())
+ MainFilePath = prefixPath1 + MainFilePath;
+ else if (SysFile(prefixPath2 + MainFilePath).IsValid())
+ MainFilePath = prefixPath2 + MainFilePath;
+ else if (SysFile(prefixPath3 + MainFilePath).IsValid())
+ MainFilePath = prefixPath3 + MainFilePath;
+ }
+}
+
+// Creates a grid of cubes.
+void PopulateCubeFieldScene(Scene* scene, Fill* fill,
+ int cubeCountX, int cubeCountY, int cubeCountZ, Vector3f offset,
+ float cubeSpacing = 0.5f, float cubeSize = 0.1f)
+{
+
+ Vector3f corner(-(((cubeCountX-1) * cubeSpacing) + cubeSize) * 0.5f,
+ -(((cubeCountY-1) * cubeSpacing) + cubeSize) * 0.5f,
+ -(((cubeCountZ-1) * cubeSpacing) + cubeSize) * 0.5f);
+ corner += offset;
+
+ Vector3f pos = corner;
+
+ for (int i = 0; i < cubeCountX; i++)
+ {
+ // Create a new model for each 'plane' of cubes so we don't exceed
+ // the vert size limit.
+ Ptr<Model> model = *new Model();
+ scene->World.Add(model);
+
+ if (fill)
+ model->Fill = fill;
+
+ for (int j = 0; j < cubeCountY; j++)
+ {
+ for (int k = 0; k < cubeCountZ; k++)
+ {
+ model->AddBox(0xFFFFFFFF, pos, Vector3f(cubeSize, cubeSize, cubeSize));
+ pos.z += cubeSpacing;
+ }
+
+ pos.z = corner.z;
+ pos.y += cubeSpacing;
+ }
+
+ pos.y = corner.y;
+ pos.x += cubeSpacing;
+ }
+}
+
+Fill* CreateTexureFill(RenderDevice* prender, const String& filename)
+{
+ Ptr<File> imageFile = *new SysFile(filename);
+ Ptr<Texture> imageTex;
+ if (imageFile->IsValid())
+ imageTex = *LoadTextureTga(prender, imageFile);
+
+ // Image is rendered as a single quad.
+ ShaderFill* fill = 0;
+ if (imageTex)
+ {
+ imageTex->SetSampleMode(Sample_Anisotropic|Sample_Repeat);
+ fill = new ShaderFill(*prender->CreateShaderSet());
+ fill->GetShaders()->SetShader(prender->LoadBuiltinShader(Shader_Vertex, VShader_MVP));
+ fill->GetShaders()->SetShader(prender->LoadBuiltinShader(Shader_Fragment, FShader_Texture));
+ fill->SetTexture(0, imageTex);
+ }
+
+ return fill;
+}
+
+
+// Loads the scene data
+void OculusWorldDemoApp::PopulateScene(const char *fileName)
+{
+ XmlHandler xmlHandler;
+ if(!xmlHandler.ReadFile(fileName, pRender, &MainScene, &CollisionModels, &GroundCollisionModels))
+ {
+ Menu.SetPopupMessage("FILE LOAD FAILED");
+ Menu.SetPopupTimeout(10.0f, true);
+ }
+
+ MainScene.SetAmbient(Color4f(1.0f, 1.0f, 1.0f, 1.0f));
+
+ // Handy cube.
+ Ptr<Model> smallGreenCubeModel = *Model::CreateBox(Color(0, 255, 0, 255), Vector3f(0.0f, 0.0f, 0.0f), Vector3f(0.004f, 0.004f, 0.004f));
+ SmallGreenCube.World.Add(smallGreenCubeModel);
+
+ String mainFilePathNoExtension = MainFilePath;
+ mainFilePathNoExtension.StripExtension();
+
+
+ // 10x10x10 cubes.
+ Ptr<Fill> fillR = *CreateTexureFill(pRender, mainFilePathNoExtension + "_redCube.tga");
+ PopulateCubeFieldScene(&RedCubesScene, fillR.GetPtr(), 10, 10, 10, Vector3f(0.0f, 0.0f, 0.0f), 0.4f);
+
+ // 10x10x10 cubes.
+ Ptr<Fill> fillB = *CreateTexureFill(pRender, mainFilePathNoExtension + "_blueCube.tga");
+ PopulateCubeFieldScene(&BlueCubesScene, fillB.GetPtr(), 10, 10, 10, Vector3f(0.0f, 0.0f, 0.0f), 0.4f);
+
+ // Anna: OculusWorldDemo/Assets/Tuscany/Tuscany_OculusCube.tga file needs to be added
+ Ptr<Fill> imageFill = *CreateTexureFill(pRender, mainFilePathNoExtension + "_OculusCube.tga");
+ PopulateCubeFieldScene(&OculusCubesScene, imageFill.GetPtr(), 11, 4, 35, Vector3f(0.0f, 0.0f, -6.0f), 0.5f);
+
+
+ float r = 0.01f;
+ Ptr<Model> purpleCubesModel = *new Model(Prim_Triangles);
+ for (int i = 0; i < 10; i++)
+ for (int j = 0; j < 10; j++)
+ for (int k = 0; k < 10; k++)
+ purpleCubesModel->AddSolidColorBox(i*0.25f-1.25f-r,j*0.25f-1.25f-r,k*0.25f-1.25f-r,
+ i*0.25f-1.25f+r,j*0.25f-1.25f+r,k*0.25f-1.25f+r,0xFF9F009F);
+}
+
+
+void OculusWorldDemoApp::PopulatePreloadScene()
+{
+ // Load-screen screen shot image
+ String fileName = MainFilePath;
+ fileName.StripExtension();
+
+ Ptr<File> imageFile = *new SysFile(fileName + "_LoadScreen.tga");
+ Ptr<Texture> imageTex;
+ if (imageFile->IsValid())
+ imageTex = *LoadTextureTga(pRender, imageFile);
+
+ // Image is rendered as a single quad.
+ if (imageTex)
+ {
+ imageTex->SetSampleMode(Sample_Anisotropic|Sample_Repeat);
+ Ptr<Model> m = *new Model(Prim_Triangles);
+ m->AddVertex(-0.5f, 0.5f, 0.0f, Color(255,255,255,255), 0.0f, 0.0f);
+ m->AddVertex( 0.5f, 0.5f, 0.0f, Color(255,255,255,255), 1.0f, 0.0f);
+ m->AddVertex( 0.5f, -0.5f, 0.0f, Color(255,255,255,255), 1.0f, 1.0f);
+ m->AddVertex(-0.5f, -0.5f, 0.0f, Color(255,255,255,255), 0.0f, 1.0f);
+ m->AddTriangle(2,1,0);
+ m->AddTriangle(0,3,2);
+
+ Ptr<ShaderFill> fill = *new ShaderFill(*pRender->CreateShaderSet());
+ fill->GetShaders()->SetShader(pRender->LoadBuiltinShader(Shader_Vertex, VShader_MVP));
+ fill->GetShaders()->SetShader(pRender->LoadBuiltinShader(Shader_Fragment, FShader_Texture));
+ fill->SetTexture(0, imageTex);
+ m->Fill = fill;
+
+ LoadingScene.World.Add(m);
+ }
+}
+
+void OculusWorldDemoApp::ClearScene()
+{
+ MainScene.Clear();
+ SmallGreenCube.Clear();
+}
+
+
+//-------------------------------------------------------------------------------------
+// ***** Rendering Content
+
+
+void OculusWorldDemoApp::RenderAnimatedBlocks(ovrEyeType eye, double appTime)
+{
+ Matrix4f viewAdjust = Matrix4f::Translation(Vector3f(EyeRenderDesc[eye].ViewAdjust));
+
+ switch ( BlocksShowType )
+ {
+ case 0:
+ // No blocks;
+ break;
+ case 1: {
+ // Horizontal circle around your head.
+ int const numBlocks = 10;
+ float const radius = 1.0f;
+ Matrix4f scaleUp = Matrix4f::Scaling ( 20.0f );
+ double scaledTime = appTime * 0.1;
+ float fracTime = (float)( scaledTime - floor ( scaledTime ) );
+
+ for ( int j = 0; j < 2; j++ )
+ {
+ for ( int i = 0; i < numBlocks; i++ )
+ {
+ float angle = ( ( (float)i / numBlocks ) + fracTime ) * ( Math<float>::Pi * 2.0f );
+ Vector3f pos;
+ pos.x = BlocksCenter.x + radius * cosf ( angle );
+ pos.y = BlocksCenter.y;
+ pos.z = BlocksCenter.z + radius * sinf ( angle );
+ if ( j == 0 )
+ {
+ pos.x = BlocksCenter.x - radius * cosf ( angle );
+ pos.y = BlocksCenter.y - 0.5f;
+ }
+ Matrix4f mat = Matrix4f::Translation ( pos );
+ SmallGreenCube.Render(pRender, viewAdjust * View * mat * scaleUp);
+ }
+ }
+ }break;
+
+ case 2: {
+ // Vertical circle around your head.
+ int const numBlocks = 10;
+ float const radius = 1.0f;
+ Matrix4f scaleUp = Matrix4f::Scaling ( 20.0f );
+ double scaledTime = appTime * 0.1;
+ float fracTime = (float)( scaledTime - floor ( scaledTime ) );
+
+ for ( int j = 0; j < 2; j++ )
+ {
+ for ( int i = 0; i < numBlocks; i++ )
+ {
+ float angle = ( ( (float)i / numBlocks ) + fracTime ) * ( Math<float>::Pi * 2.0f );
+ Vector3f pos;
+ pos.x = BlocksCenter.x;
+ pos.y = BlocksCenter.y + radius * cosf ( angle );
+ pos.z = BlocksCenter.z + radius * sinf ( angle );
+ if ( j == 0 )
+ {
+ pos.x = BlocksCenter.x - 0.5f;
+ pos.y = BlocksCenter.y - radius * cosf ( angle );
+ }
+ Matrix4f mat = Matrix4f::Translation ( pos );
+ SmallGreenCube.Render(pRender, viewAdjust * View * mat * scaleUp);
+ }
+ }
+ }break;
+
+ case 3:{
+ // Bouncing.
+ int const numBlocks = 10;
+ Matrix4f scaleUp = Matrix4f::Scaling ( 20.0f );
+
+ for ( int i = 0; i < numBlocks; i++ )
+ {
+ double scaledTime = 4.0f * appTime / (double)i;
+ float fracTime = (float)( scaledTime - floor ( scaledTime ) );
+
+ Vector3f pos = BlocksCenter;
+ pos.z += (float)i;
+ pos.y += -1.5f + 4.0f * ( 2.0f * fracTime * ( 1.0f - fracTime ) );
+ Matrix4f mat = Matrix4f::Translation ( pos );
+ SmallGreenCube.Render(pRender, viewAdjust * View * mat * scaleUp);
+ }
+ }break;
+
+ default:
+ BlocksShowType = 0;
+ break;
+ }
+}
+
+void OculusWorldDemoApp::RenderGrid(ovrEyeType eye)
+{
+ Recti renderViewport = EyeTexture[eye].Header.RenderViewport;
+
+ // Draw actual pixel grid on the RT.
+ // 1:1 mapping to screen pixels, origin in top-left.
+ Matrix4f ortho;
+ ortho.SetIdentity();
+ ortho.M[0][0] = 2.0f / (renderViewport.w); // X scale
+ ortho.M[0][3] = -1.0f; // X offset
+ ortho.M[1][1] = -2.0f / (renderViewport.h); // Y scale (for Y=down)
+ ortho.M[1][3] = 1.0f; // Y offset (Y=down)
+ ortho.M[2][2] = 0;
+ pRender->SetProjection(ortho);
+
+ pRender->SetDepthMode(false, false);
+ Color cNormal ( 255, 0, 0 );
+ Color cSpacer ( 255, 255, 0 );
+ Color cMid ( 0, 128, 255 );
+
+ int lineStep = 1;
+ int midX = 0;
+ int midY = 0;
+ int limitX = 0;
+ int limitY = 0;
+
+ switch ( GridMode )
+ {
+ case Grid_Rendertarget4:
+ lineStep = 4;
+ midX = renderViewport.w / 2;
+ midY = renderViewport.h / 2;
+ limitX = renderViewport.w / 2;
+ limitY = renderViewport.h / 2;
+ break;
+ case Grid_Rendertarget16:
+ lineStep = 16;
+ midX = renderViewport.w / 2;
+ midY = renderViewport.h / 2;
+ limitX = renderViewport.w / 2;
+ limitY = renderViewport.h / 2;
+ break;
+ case Grid_Lens:
+ {
+ lineStep = 48;
+ Vector2f rendertargetNDC = FovPort(EyeRenderDesc[eye].Desc.Fov).TanAngleToRendertargetNDC(Vector2f(0.0f));
+ midX = (int)( ( rendertargetNDC.x * 0.5f + 0.5f ) * (float)renderViewport.w + 0.5f );
+ midY = (int)( ( rendertargetNDC.y * 0.5f + 0.5f ) * (float)renderViewport.h + 0.5f );
+ limitX = Alg::Max ( renderViewport.w - midX, midX );
+ limitY = Alg::Max ( renderViewport.h - midY, midY );
+ }
+ break;
+ default: OVR_ASSERT ( false ); break;
+ }
+
+ int spacerMask = (lineStep<<2)-1;
+
+
+ for ( int xp = 0; xp < limitX; xp += lineStep )
+ {
+ float x[4];
+ float y[4];
+ x[0] = (float)( midX + xp );
+ y[0] = (float)0;
+ x[1] = (float)( midX + xp );
+ y[1] = (float)renderViewport.h;
+ x[2] = (float)( midX - xp );
+ y[2] = (float)0;
+ x[3] = (float)( midX - xp );
+ y[3] = (float)renderViewport.h;
+ if ( xp == 0 )
+ {
+ pRender->RenderLines ( 1, cMid, x, y );
+ }
+ else if ( ( xp & spacerMask ) == 0 )
+ {
+ pRender->RenderLines ( 2, cSpacer, x, y );
+ }
+ else
+ {
+ pRender->RenderLines ( 2, cNormal, x, y );
+ }
+ }
+ for ( int yp = 0; yp < limitY; yp += lineStep )
+ {
+ float x[4];
+ float y[4];
+ x[0] = (float)0;
+ y[0] = (float)( midY + yp );
+ x[1] = (float)renderViewport.w;
+ y[1] = (float)( midY + yp );
+ x[2] = (float)0;
+ y[2] = (float)( midY - yp );
+ x[3] = (float)renderViewport.w;
+ y[3] = (float)( midY - yp );
+ if ( yp == 0 )
+ {
+ pRender->RenderLines ( 1, cMid, x, y );
+ }
+ else if ( ( yp & spacerMask ) == 0 )
+ {
+ pRender->RenderLines ( 2, cSpacer, x, y );
+ }
+ else
+ {
+ pRender->RenderLines ( 2, cNormal, x, y );
+ }
+ }
+}
+
diff --git a/Samples/OculusWorldDemo/OptionMenu.cpp b/Samples/OculusWorldDemo/OptionMenu.cpp
new file mode 100644
index 0000000..283136d
--- /dev/null
+++ b/Samples/OculusWorldDemo/OptionMenu.cpp
@@ -0,0 +1,896 @@
+/************************************************************************************
+
+Filename : OptionMenu.h
+Content : Option selection and editing for OculusWorldDemo
+Created : March 7, 2014
+Authors : Michael Antonov, Caleb Leak
+
+Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+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.
+
+*************************************************************************************/
+
+#include "OptionMenu.h"
+
+// Embed the font.
+#include "../CommonSrc/Render/Render_FontEmbed_DejaVu48.h"
+
+
+//-------------------------------------------------------------------------------------
+bool OptionShortcut::MatchKey(KeyCode key, bool shift) const
+{
+ for (UInt32 i = 0; i < Keys.GetSize(); i++)
+ {
+ if (Keys[i].Key != key)
+ continue;
+
+ if (!shift && Keys[i].ShiftUsage == ShortcutKey::Shift_RequireOn)
+ continue;
+
+ if (shift && Keys[i].ShiftUsage == ShortcutKey::Shift_RequireOff)
+ continue;
+
+ if(Keys[i].ShiftUsage == ShortcutKey::Shift_Modify)
+ {
+ pNotify->CallNotify(&shift);
+ }
+ else
+ {
+ pNotify->CallNotify();
+ }
+ return true;
+ }
+ return false;
+}
+
+bool OptionShortcut::MatchGamepadButton(UInt32 gamepadButtonMask) const
+{
+ for (UInt32 i = 0; i < GamepadButtons.GetSize(); i++)
+ {
+ if (GamepadButtons[i] & gamepadButtonMask)
+ {
+ if (pNotify != NULL)
+ {
+ pNotify->CallNotify();
+ }
+ return true;
+ }
+ }
+ return false;
+}
+
+
+//-------------------------------------------------------------------------------------
+String OptionMenuItem::PopNamespaceFrom(OptionMenuItem* menuItem)
+{
+ String label = menuItem->Label;
+ for (UInt32 i = 0; i < label.GetLength(); i++)
+ {
+ if (label.GetCharAt(i) == '.')
+ {
+ String ns = label.Substring(0, i);
+ menuItem->Label = label.Substring(i + 1, label.GetLength());
+ return ns;
+ }
+ }
+ return "";
+}
+
+//-------------------------------------------------------------------------------------
+
+String OptionVar::FormatEnum(OptionVar* var)
+{
+ UInt32 index = var->GetEnumIndex();
+ if (index < var->EnumValues.GetSize())
+ return var->EnumValues[index].Name;
+ return String("<Bad enum index>");
+}
+
+String OptionVar::FormatInt(OptionVar* var)
+{
+ char buff[64];
+ OVR_sprintf(buff, sizeof(buff), var->FormatString, *var->AsInt());
+ return String(buff);
+}
+
+String OptionVar::FormatFloat(OptionVar* var)
+{
+ char buff[64];
+ OVR_sprintf(buff, sizeof(buff), var->FormatString, *var->AsFloat() * var->FormatScale);
+ return String(buff);
+}
+
+String OptionVar::FormatBool(OptionVar* var)
+{
+ return *var->AsBool() ? "On" : "Off";
+}
+
+
+OptionVar::OptionVar(const char* name, void* pvar, VarType type,
+ FormatFunction formatFunction,
+ UpdateFunction updateFunction)
+{
+ Label = name;
+ Type = type;
+ this->pVar = pvar;
+ fFormat = formatFunction;
+ fUpdate = updateFunction;
+ pNotify = 0;
+ FormatString= 0;
+
+ MaxFloat = Math<float>::MaxValue;
+ MinFloat = -Math<float>::MaxValue;
+ StepFloat = 1.0f;
+ FormatScale = 1.0f;
+
+ MaxInt = 0x7FFFFFFF;
+ MinInt = -(MaxInt) - 1;
+ StepInt = 1;
+
+ ShortcutUp.pNotify = new FunctionNotifyContext<OptionVar, bool>(this, &OptionVar::NextValue);
+ ShortcutDown.pNotify = new FunctionNotifyContext<OptionVar, bool>(this, &OptionVar::PrevValue);
+}
+
+OptionVar::OptionVar(const char* name, SInt32* pvar,
+ SInt32 min, SInt32 max, SInt32 stepSize,
+ const char* formatString,
+ FormatFunction formatFunction,
+ UpdateFunction updateFunction)
+{
+ Label = name;
+ Type = Type_Int;
+ this->pVar = pvar;
+ fFormat = formatFunction ? formatFunction : FormatInt;
+ fUpdate = updateFunction;
+ pNotify = 0;
+ FormatString= formatString;
+
+ MinInt = min;
+ MaxInt = max;
+ StepInt = stepSize;
+
+ ShortcutUp.pNotify = new FunctionNotifyContext<OptionVar, bool>(this, &OptionVar::NextValue);
+ ShortcutDown.pNotify = new FunctionNotifyContext<OptionVar, bool>(this, &OptionVar::PrevValue);
+}
+
+// Float with range and step size.
+OptionVar::OptionVar(const char* name, float* pvar,
+ float minf, float maxf, float stepSize,
+ const char* formatString, float formatScale,
+ FormatFunction formatFunction,
+ UpdateFunction updateFunction)
+{
+ Label = name;
+ Type = Type_Float;
+ this->pVar = pvar;
+ fFormat = formatFunction ? formatFunction : FormatFloat;
+ fUpdate = updateFunction;
+ pNotify = 0;
+ FormatString= formatString ? formatString : "%.3f";
+
+ MinFloat = minf;
+ MaxFloat = maxf;
+ StepFloat = stepSize;
+ FormatScale = formatScale;
+
+ ShortcutUp.pNotify = new FunctionNotifyContext<OptionVar, bool>(this, &OptionVar::NextValue);
+ ShortcutDown.pNotify = new FunctionNotifyContext<OptionVar, bool>(this, &OptionVar::PrevValue);
+}
+
+OptionVar::~OptionVar()
+{
+ if (pNotify)
+ delete pNotify;
+}
+
+void OptionVar::NextValue(bool* pFastStep)
+{
+ bool fastStep = (pFastStep != NULL && *pFastStep);
+ switch (Type)
+ {
+ case Type_Enum:
+ *AsInt() = ((GetEnumIndex() + 1) % EnumValues.GetSize());
+ break;
+
+ case Type_Int:
+ *AsInt() = Alg::Min<SInt32>(*AsInt() + StepInt * (fastStep ? 5 : 1), MaxInt);
+ break;
+
+ case Type_Float:
+ // TODO: Will behave strange with NaN values.
+ *AsFloat() = Alg::Min<float>(*AsFloat() + StepFloat * (fastStep ? 5.0f : 1.0f), MaxFloat);
+ break;
+
+ case Type_Bool:
+ *AsBool() = !*AsBool();
+ break;
+ }
+
+ SignalUpdate();
+}
+
+void OptionVar::PrevValue(bool* pFastStep)
+{
+ bool fastStep = (pFastStep != NULL && *pFastStep);
+ switch (Type)
+ {
+ case Type_Enum:
+ *AsInt() = ((GetEnumIndex() + (UInt32)EnumValues.GetSize() - 1) % EnumValues.GetSize());
+ break;
+
+ case Type_Int:
+ *AsInt() = Alg::Max<SInt32>(*AsInt() - StepInt * (fastStep ? 5 : 1), MinInt);
+ break;
+
+ case Type_Float:
+ // TODO: Will behave strange with NaN values.
+ *AsFloat() = Alg::Max<float>(*AsFloat() - StepFloat * (fastStep ? 5.0f : 1.0f), MinFloat);
+ break;
+
+ case Type_Bool:
+ *AsBool() = !*AsBool();
+ break;
+ }
+
+ SignalUpdate();
+}
+
+String OptionVar::HandleShortcutUpdate()
+{
+ SignalUpdate();
+ return Label + " - " + GetValue();
+}
+
+String OptionVar::ProcessShortcutKey(KeyCode key, bool shift)
+{
+ if (ShortcutUp.MatchKey(key, shift) || ShortcutDown.MatchKey(key, shift))
+ {
+ return HandleShortcutUpdate();
+ }
+
+ return String();
+}
+
+String OptionVar::ProcessShortcutButton(UInt32 buttonMask)
+{
+ if (ShortcutUp.MatchGamepadButton(buttonMask) || ShortcutDown.MatchGamepadButton(buttonMask))
+ {
+ return HandleShortcutUpdate();
+ }
+ return String();
+}
+
+
+OptionVar& OptionVar::AddEnumValue(const char* displayName, SInt32 value)
+{
+ EnumEntry entry;
+ entry.Name = displayName;
+ entry.Value = value;
+ EnumValues.PushBack(entry);
+ return *this;
+}
+
+String OptionVar::GetValue()
+{
+ return fFormat(this);
+}
+
+UInt32 OptionVar::GetEnumIndex()
+{
+ OVR_ASSERT(Type == Type_Enum);
+ OVR_ASSERT(EnumValues.GetSize() > 0);
+
+ // TODO: Change this from a linear search to binary or a hash.
+ for (UInt32 i = 0; i < EnumValues.GetSize(); i++)
+ {
+ if (EnumValues[i].Value == *AsInt())
+ return i;
+ }
+
+ // Enum values should always be found.
+ OVR_ASSERT(false);
+ return 0;
+}
+
+
+//-------------------------------------------------------------------------------------
+
+OptionSelectionMenu::OptionSelectionMenu(OptionSelectionMenu* parentMenu)
+{
+ DisplayState = Display_None;
+ SelectedIndex = 0;
+ SelectionActive = false;
+ ParentMenu = parentMenu;
+
+ PopupMessageTimeout = 0.0;
+ PopupMessageBorder = false;
+
+ // Setup handlers for menu navigation actions.
+ NavShortcuts[Nav_Up].pNotify = new FunctionNotifyContext<OptionSelectionMenu, bool>(this, &OptionSelectionMenu::HandleUp);
+ NavShortcuts[Nav_Down].pNotify = new FunctionNotifyContext<OptionSelectionMenu, bool>(this, &OptionSelectionMenu::HandleDown);
+ NavShortcuts[Nav_Left].pNotify = new FunctionNotifySimple<OptionSelectionMenu>(this, &OptionSelectionMenu::HandleLeft);
+ NavShortcuts[Nav_Right].pNotify = new FunctionNotifySimple<OptionSelectionMenu>(this, &OptionSelectionMenu::HandleRight);
+ NavShortcuts[Nav_Select].pNotify = new FunctionNotifySimple<OptionSelectionMenu>(this, &OptionSelectionMenu::HandleSelect);
+ NavShortcuts[Nav_Back].pNotify = new FunctionNotifySimple<OptionSelectionMenu>(this, &OptionSelectionMenu::HandleBack);
+ ToggleShortcut.pNotify = new FunctionNotifySimple<OptionSelectionMenu>(this, &OptionSelectionMenu::HandleMenuToggle);
+ ToggleSingleItemShortcut.pNotify = new FunctionNotifySimple<OptionSelectionMenu>(this, &OptionSelectionMenu::HandleSingleItemToggle);
+
+ // Bind keys and buttons to menu navigation actions.
+ NavShortcuts[Nav_Up].AddShortcut(ShortcutKey(Key_Up, ShortcutKey::Shift_Modify));
+ NavShortcuts[Nav_Up].AddShortcut(Gamepad_Up);
+
+ NavShortcuts[Nav_Down].AddShortcut(ShortcutKey(Key_Down, ShortcutKey::Shift_Modify));
+ NavShortcuts[Nav_Down].AddShortcut(Gamepad_Down);
+
+ NavShortcuts[Nav_Left].AddShortcut(ShortcutKey(Key_Left));
+ NavShortcuts[Nav_Left].AddShortcut(Gamepad_Left);
+
+ NavShortcuts[Nav_Right].AddShortcut(ShortcutKey(Key_Right));
+ NavShortcuts[Nav_Right].AddShortcut(Gamepad_Right);
+
+ NavShortcuts[Nav_Select].AddShortcut(ShortcutKey(Key_Return));
+ NavShortcuts[Nav_Select].AddShortcut(Gamepad_A);
+
+ NavShortcuts[Nav_Back].AddShortcut(ShortcutKey(Key_Escape));
+ NavShortcuts[Nav_Back].AddShortcut(Gamepad_B);
+
+ ToggleShortcut.AddShortcut(ShortcutKey(Key_Tab, ShortcutKey::Shift_Ignore));
+ ToggleShortcut.AddShortcut(Gamepad_Start);
+
+ ToggleSingleItemShortcut.AddShortcut(ShortcutKey(Key_Backspace, ShortcutKey::Shift_Ignore));
+}
+
+OptionSelectionMenu::~OptionSelectionMenu()
+{
+ for (UInt32 i = 0; i < Items.GetSize(); i++)
+ delete Items[i];
+}
+
+bool OptionSelectionMenu::OnKey(OVR::KeyCode key, int chr, bool down, int modifiers)
+{
+ bool shift = ((modifiers & Mod_Shift) != 0);
+
+ if (down)
+ {
+ String s = ProcessShortcutKey(key, shift);
+ if (!s.IsEmpty())
+ {
+ PopupMessage = s;
+ PopupMessageTimeout = ovr_GetTimeInSeconds() + 4.0f;
+ PopupMessageBorder = false;
+ return true;
+ }
+ }
+
+ if (GetSubmenu() != NULL)
+ {
+ return GetSubmenu()->OnKey(key, chr, down, modifiers);
+ }
+
+ if (down)
+ {
+ if (ToggleShortcut.MatchKey(key, shift))
+ return true;
+
+ if (ToggleSingleItemShortcut.MatchKey(key, shift))
+ return true;
+
+ if (DisplayState == Display_None)
+ return false;
+
+ for (int i = 0; i < Nav_LAST; i++)
+ {
+ if (NavShortcuts[i].MatchKey(key, shift))
+ return true;
+ }
+ }
+
+ // Let the caller process keystroke
+ return false;
+}
+
+bool OptionSelectionMenu::OnGamepad(UInt32 buttonMask)
+{
+ // Check global shortcuts first.
+ String s = ProcessShortcutButton(buttonMask);
+ if (!s.IsEmpty())
+ {
+ PopupMessage = s;
+ PopupMessageTimeout = ovr_GetTimeInSeconds() + 4.0f;
+ return true;
+ }
+
+ if (GetSubmenu() != NULL)
+ {
+ return GetSubmenu()->OnGamepad(buttonMask);
+ }
+
+ if (ToggleShortcut.MatchGamepadButton(buttonMask))
+ return true;
+
+ if (DisplayState == Display_None)
+ return false;
+
+ for (int i = 0; i < Nav_LAST; i++)
+ {
+ if (NavShortcuts[i].MatchGamepadButton(buttonMask))
+ return true;
+ }
+
+ // Let the caller process keystroke
+ return false;
+}
+
+String OptionSelectionMenu::ProcessShortcutKey(KeyCode key, bool shift)
+{
+ String s;
+
+ for (UPInt i = 0; (i < Items.GetSize()) && s.IsEmpty(); i++)
+ {
+ s = Items[i]->ProcessShortcutKey(key, shift);
+ }
+
+ return s;
+}
+
+String OptionSelectionMenu::ProcessShortcutButton(UInt32 buttonMask)
+{
+ String s;
+
+ for (UPInt i = 0; (i < Items.GetSize()) && s.IsEmpty(); i++)
+ {
+ s = Items[i]->ProcessShortcutButton(buttonMask);
+ }
+
+ return s;
+}
+
+// Fills in inclusive character range; returns false if line not found.
+bool FindLineCharRange(const char* text, int searchLine, UPInt charRange[2])
+{
+ UPInt i = 0;
+
+ for (int line = 0; line <= searchLine; line ++)
+ {
+ if (line == searchLine)
+ {
+ charRange[0] = i;
+ }
+
+ // Find end of line.
+ while (text[i] != '\n' && text[i] != 0)
+ {
+ i++;
+ }
+
+ if (line == searchLine)
+ {
+ charRange[1] = (charRange[0] == i) ? charRange[0] : i-1;
+ return true;
+ }
+
+ if (text[i] == 0)
+ break;
+ // Skip newline
+ i++;
+ }
+
+ return false;
+}
+
+
+void OptionSelectionMenu::Render(RenderDevice* prender, String title)
+{
+ // If we are invisible, render shortcut notifications.
+ // Both child and parent have visible == true even if only child is shown.
+ if (DisplayState == Display_None)
+ {
+ renderShortcutChangeMessage(prender);
+ return;
+ }
+
+ title += Label;
+
+ // Delegate to sub-menu if active.
+ if (GetSubmenu() != NULL)
+ {
+ if (title.GetSize() > 0)
+ title += " > ";
+
+ GetSubmenu()->Render(prender, title);
+ return;
+ }
+
+ Color focusColor(180, 80, 20, 210);
+ Color pickedColor(120, 55, 10, 140);
+ Color titleColor(0x18, 0x1A, 0x4D, 210);
+ Color titleOutlineColor(0x18, 0x18, 0x18, 240);
+
+ float labelsSize[2] = {0.0f, 0.0f};
+ float bufferSize[2] = {0.0f, 0.0f};
+ float valuesSize[2] = {0.0f, 0.0f};
+ float maxValueWidth = 0.0f;
+
+ UPInt selection[2] = { 0, 0 };
+ Vector2f labelSelectionRect[2];
+ Vector2f valueSelectionRect[2];
+ bool havelLabelSelection = false;
+ bool haveValueSelection = false;
+
+ float textSize = 22.0f;
+ prender->MeasureText(&DejaVu, " ", textSize, bufferSize);
+
+ String values;
+ String menuItems;
+
+ int highlightIndex = 0;
+ if (DisplayState == Display_Menu)
+ {
+ highlightIndex = SelectedIndex;
+ for (UInt32 i = 0; i < Items.GetSize(); i++)
+ {
+ if (i > 0)
+ values += "\n";
+ values += Items[i]->GetValue();
+ }
+
+ for (UInt32 i = 0; i < Items.GetSize(); i++)
+ {
+ if (i > 0)
+ menuItems += "\n";
+ menuItems += Items[i]->GetLabel();
+ }
+ }
+ else
+ {
+ values = Items[SelectedIndex]->GetValue();
+ menuItems = Items[SelectedIndex]->GetLabel();
+ }
+
+ // Measure labels
+ const char* menuItemsCStr = menuItems.ToCStr();
+ havelLabelSelection = FindLineCharRange(menuItemsCStr, highlightIndex, selection);
+ prender->MeasureText(&DejaVu, menuItemsCStr, textSize, labelsSize,
+ selection, labelSelectionRect);
+
+ // Measure label-to-value gap
+ const char* valuesCStr = values.ToCStr();
+ haveValueSelection = FindLineCharRange(valuesCStr, highlightIndex, selection);
+ prender->MeasureText(&DejaVu, valuesCStr, textSize, valuesSize, selection, valueSelectionRect);
+
+ // Measure max value size (absolute size varies, so just use a reasonable max)
+ maxValueWidth = prender->MeasureText(&DejaVu, "Max value width", textSize);
+ maxValueWidth = Alg::Max(maxValueWidth, valuesSize[0]);
+
+ Vector2f borderSize(4.0f, 4.0f);
+ Vector2f totalDimensions = borderSize * 2 + Vector2f(bufferSize[0], 0) + Vector2f(maxValueWidth, 0)
+ + Vector2f(labelsSize[0], labelsSize[1]);
+
+ Vector2f fudgeOffset= Vector2f(10.0f, 25.0f); // This offset looks better
+ Vector2f topLeft = (-totalDimensions / 2.0f) + fudgeOffset;
+ Vector2f bottomRight = topLeft + totalDimensions;
+
+ // If displaying a single item, shift it down.
+ if (DisplayState == Display_SingleItem)
+ {
+ topLeft.y += textSize * 7;
+ bottomRight.y += textSize * 7;
+ }
+
+ prender->FillRect(topLeft.x, topLeft.y, bottomRight.x, bottomRight.y, Color(40,40,100,210));
+
+ Vector2f labelsPos = topLeft + borderSize;
+ Vector2f valuesPos = labelsPos + Vector2f(labelsSize[0], 0) + Vector2f(bufferSize[0], 0);
+
+ // Highlight selected label
+ Vector2f selectionInset = Vector2f(0.3f, 2.0f);
+ if (DisplayState == Display_Menu)
+ {
+ Vector2f labelSelectionTopLeft = labelsPos + labelSelectionRect[0] - selectionInset;
+ Vector2f labelSelectionBottomRight = labelsPos + labelSelectionRect[1] + selectionInset;
+
+ prender->FillRect(labelSelectionTopLeft.x, labelSelectionTopLeft.y,
+ labelSelectionBottomRight.x, labelSelectionBottomRight.y,
+ SelectionActive ? pickedColor : focusColor);
+ }
+
+ // Highlight selected value if active
+ if (SelectionActive)
+ {
+ Vector2f valueSelectionTopLeft = valuesPos + valueSelectionRect[0] - selectionInset;
+ Vector2f valueSelectionBottomRight = valuesPos + valueSelectionRect[1] + selectionInset;
+ prender->FillRect(valueSelectionTopLeft.x, valueSelectionTopLeft.y,
+ valueSelectionBottomRight.x, valueSelectionBottomRight.y,
+ focusColor);
+ }
+
+ // Measure and draw title
+ if (DisplayState == Display_Menu && title.GetLength() > 0)
+ {
+ Vector2f titleDimensions;
+ prender->MeasureText(&DejaVu, title.ToCStr(), textSize, &titleDimensions.x);
+ Vector2f titleTopLeft = topLeft - Vector2f(0, borderSize.y) * 2 - Vector2f(0, titleDimensions.y);
+ titleDimensions.x = totalDimensions.x;
+
+ prender->FillRect(titleTopLeft.x, titleTopLeft.y,
+ titleTopLeft.x + totalDimensions.x,
+ titleTopLeft.y + titleDimensions.y + borderSize.y * 2,
+ titleOutlineColor);
+
+ prender->FillRect(titleTopLeft.x + borderSize.x / 2, titleTopLeft.y + borderSize.y / 2,
+ titleTopLeft.x + totalDimensions.x - borderSize.x / 2,
+ titleTopLeft.y + borderSize.y / 2 + titleDimensions.y,
+ titleColor);
+
+ prender->RenderText(&DejaVu, title.ToCStr(), titleTopLeft.x + borderSize.x,
+ titleTopLeft.y + borderSize.y, textSize, Color(255,255,0,210));
+ }
+
+ prender->RenderText(&DejaVu, menuItemsCStr, labelsPos.x, labelsPos.y, textSize, Color(255,255,0,210));
+
+ prender->RenderText(&DejaVu, valuesCStr, valuesPos.x, valuesPos.y, textSize, Color(255,255,0,210));
+}
+
+
+void OptionSelectionMenu::renderShortcutChangeMessage(RenderDevice* prender)
+{
+ if (ovr_GetTimeInSeconds() < PopupMessageTimeout)
+ {
+ DrawTextBox(prender, 0, 120, 22.0f, PopupMessage.ToCStr(),
+ DrawText_Center | (PopupMessageBorder ? DrawText_Border : 0));
+ }
+}
+
+
+void OptionSelectionMenu::SetPopupMessage(const char* format, ...)
+{
+ //Lock::Locker lock(pManager->GetHandlerLock());
+ char textBuff[2048];
+ va_list argList;
+ va_start(argList, format);
+ OVR_vsprintf(textBuff, sizeof(textBuff), format, argList);
+ va_end(argList);
+
+ // Message will time out in 4 seconds.
+ PopupMessage = textBuff;
+ PopupMessageTimeout = ovr_GetTimeInSeconds() + 4.0f;
+ PopupMessageBorder = false;
+}
+
+void OptionSelectionMenu::SetPopupTimeout(double timeoutSeconds, bool border)
+{
+ PopupMessageTimeout = ovr_GetTimeInSeconds() + timeoutSeconds;
+ PopupMessageBorder = border;
+}
+
+
+
+void OptionSelectionMenu::AddItem(OptionMenuItem* menuItem)
+{
+ String ns = PopNamespaceFrom(menuItem);
+
+ if (ns.GetLength() == 0)
+ {
+ Items.PushBack(menuItem);
+ }
+ else
+ {
+ // Item is part of a submenu, add it to that instead.
+ GetOrCreateSubmenu(ns)->AddItem(menuItem);
+ }
+}
+
+//virtual
+void OptionSelectionMenu::Select()
+{
+ SelectedIndex = 0;
+ SelectionActive = false;
+ DisplayState = Display_Menu;
+}
+
+
+OptionSelectionMenu* OptionSelectionMenu::GetSubmenu()
+{
+ if (!SelectionActive)
+ return NULL;
+
+ OptionSelectionMenu* submenu = dynamic_cast<OptionSelectionMenu*>(Items[SelectedIndex]);
+ return submenu;
+}
+
+
+OptionSelectionMenu* OptionSelectionMenu::GetOrCreateSubmenu(String submenuName)
+{
+ for (UInt32 i = 0; i < Items.GetSize(); i++)
+ {
+ OptionSelectionMenu* submenu = dynamic_cast<OptionSelectionMenu*>(Items[i]);
+
+ if (submenu != NULL && submenu->Label == submenuName)
+ {
+ return submenu;
+ }
+ }
+
+ // Submenu doesn't exist, create it.
+ OptionSelectionMenu* newSubmenu = new OptionSelectionMenu(this);
+ newSubmenu->Label = submenuName;
+ Items.PushBack(newSubmenu);
+ return newSubmenu;
+}
+
+void OptionSelectionMenu::HandleUp(bool* pFast)
+{
+ int numItems = (int)Items.GetSize();
+ if (SelectionActive)
+ Items[SelectedIndex]->NextValue(pFast);
+ else
+ SelectedIndex = ((SelectedIndex - 1 + numItems) % numItems);
+}
+
+void OptionSelectionMenu::HandleDown(bool* pFast)
+{
+ if (SelectionActive)
+ Items[SelectedIndex]->PrevValue(pFast);
+ else
+ SelectedIndex = ((SelectedIndex + 1) % Items.GetSize());
+}
+
+void OptionSelectionMenu::HandleLeft()
+{
+ if (DisplayState != Display_Menu)
+ return;
+
+ if (SelectionActive)
+ SelectionActive = false;
+ else if (ParentMenu)
+ {
+ // Escape to parent menu
+ ParentMenu->SelectionActive = false;
+ DisplayState = Display_Menu;
+ }
+}
+
+void OptionSelectionMenu::HandleRight()
+{
+ if (DisplayState != Display_Menu)
+ return;
+
+ if (!SelectionActive)
+ {
+ SelectionActive = true;
+ Items[SelectedIndex]->Select();
+ }
+}
+
+void OptionSelectionMenu::HandleSelect()
+{
+ if (!SelectionActive)
+ {
+ SelectionActive = true;
+ Items[SelectedIndex]->Select();
+ }
+ else
+ {
+ Items[SelectedIndex]->NextValue();
+ }
+}
+
+void OptionSelectionMenu::HandleBack()
+{
+ if (DisplayState != Display_Menu)
+ return;
+
+ if (!SelectionActive)
+ DisplayState = Display_None;
+ else
+ SelectionActive = false;
+}
+
+void OptionSelectionMenu::HandleMenuToggle()
+{
+ // Mark this & parent With correct visibility.
+ OptionSelectionMenu* menu = this;
+
+ if (DisplayState == Display_Menu)
+ DisplayState = Display_None;
+ else
+ DisplayState = Display_Menu;
+
+ while (menu)
+ {
+ menu->DisplayState = DisplayState;
+ menu = menu->ParentMenu;
+ }
+ // Hide message
+ PopupMessageTimeout = 0;
+}
+
+void OptionSelectionMenu::HandleSingleItemToggle()
+{
+ // Mark this & parent With correct visibility.
+ OptionSelectionMenu* menu = this;
+
+ if (DisplayState == Display_SingleItem)
+ DisplayState = Display_None;
+ else
+ {
+ DisplayState = Display_SingleItem;
+ SelectionActive = true;
+ }
+
+ while (menu)
+ {
+ menu->DisplayState = DisplayState;
+ menu = menu->ParentMenu;
+ }
+ // Hide message
+ PopupMessageTimeout = 0;
+}
+
+
+//-------------------------------------------------------------------------------------
+// **** Text Rendering / Management
+
+void DrawTextBox(RenderDevice* prender, float x, float y,
+ float textSize, const char* text, unsigned centerType)
+{
+ float ssize[2] = {0.0f, 0.0f};
+
+ prender->MeasureText(&DejaVu, text, textSize, ssize);
+
+ // Treat 0 a VCenter.
+ if (centerType & DrawText_HCenter)
+ {
+ x -= ssize[0]/2;
+ }
+ if (centerType & DrawText_VCenter)
+ {
+ y -= ssize[1]/2;
+ }
+
+ const float borderSize = 4.0f;
+ float linesHeight = 0.0f;
+
+ if (centerType & DrawText_Border)
+ linesHeight = 10.0f;
+
+ prender->FillRect(x-borderSize, y-borderSize - linesHeight,
+ x+ssize[0]+borderSize, y+ssize[1]+borderSize + linesHeight,
+ Color(40,40,100,210));
+
+ if (centerType & DrawText_Border)
+ {
+ // Add top & bottom lines
+ float topLineY = y-borderSize - linesHeight * 0.5f,
+ bottomLineY = y+ssize[1]+borderSize + linesHeight * 0.5f;
+
+ prender->FillRect(x-borderSize * 0.5f, topLineY,
+ x+ssize[0]+borderSize * 0.5f, topLineY + 2.0f,
+ Color(255,255,0,210));
+ prender->FillRect(x-borderSize * 0.5f, bottomLineY,
+ x+ssize[0]+borderSize * 0.5f, bottomLineY + 2.0f,
+ Color(255,255,0,210));
+ }
+
+ prender->RenderText(&DejaVu, text, x, y, textSize, Color(255,255,0,210));
+}
+
+void CleanupDrawTextFont()
+{
+ if (DejaVu.fill)
+ {
+ DejaVu.fill->Release();
+ DejaVu.fill = 0;
+ }
+}
diff --git a/Samples/OculusWorldDemo/OptionMenu.h b/Samples/OculusWorldDemo/OptionMenu.h
new file mode 100644
index 0000000..ba90b08
--- /dev/null
+++ b/Samples/OculusWorldDemo/OptionMenu.h
@@ -0,0 +1,442 @@
+/************************************************************************************
+
+Filename : OptionMenu.h
+Content : Option selection and editing for OculusWorldDemo
+Created : March 7, 2014
+Authors : Michael Antonov, Caleb Leak
+
+Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+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 INC_OptionMenu_h
+#define INC_OptionMenu_h
+
+#include "OVR.h"
+
+#include "../CommonSrc/Platform/Platform_Default.h"
+#include "../CommonSrc/Render/Render_Device.h"
+#include "../CommonSrc/Platform/Gamepad.h"
+
+#include "Util/Util_Render_Stereo.h"
+using namespace OVR::Util::Render;
+
+#include <Kernel/OVR_SysFile.h>
+#include <Kernel/OVR_Log.h>
+#include <Kernel/OVR_Timer.h>
+
+#include "Player.h"
+#include "OVR_DeviceConstants.h"
+
+
+using namespace OVR;
+using namespace OVR::Platform;
+using namespace OVR::Render;
+
+
+//-------------------------------------------------------------------------------------
+struct FunctionNotifyBase : public NewOverrideBase
+{
+ virtual void CallNotify(void*) { }
+ virtual void CallNotify() { }
+};
+
+// Simple member pointer wrapper to support calling class members
+template<class C, class X>
+struct FunctionNotifyContext : public FunctionNotifyBase
+{
+ typedef void (C::*FnPtr)(X*);
+
+ FunctionNotifyContext(C* p, FnPtr fn) : pClass(p), pFn(fn), pContext(NULL) { }
+ FunctionNotifyContext(C* p, FnPtr fn, X* pContext) : pClass(p), pFn(fn), pContext(pContext) { }
+ virtual void CallNotify(void* var) { (void)(pClass->*pFn)(static_cast<X*>(var)); }
+ virtual void CallNotify() { (void)(pClass->*pFn)(pContext); }
+private:
+
+ X* pContext;
+ C* pClass;
+ FnPtr pFn;
+};
+
+template<class C>
+struct FunctionNotifySimple : public FunctionNotifyBase
+{
+ typedef void (C::*FnPtr)(void);
+
+ FunctionNotifySimple(C* p, FnPtr fn) : pClass(p), pFn(fn) { }
+ virtual void CallNotify(void*) { CallNotify(); }
+ virtual void CallNotify() { (void)(pClass->*pFn)(); }
+private:
+
+ C* pClass;
+ FnPtr pFn;
+};
+
+
+//-------------------------------------------------------------------------------------
+// Describes a shortcut key
+struct ShortcutKey
+{
+ enum ShiftUsageType
+ {
+ Shift_Ignore,
+ Shift_Modify,
+ Shift_RequireOn,
+ Shift_RequireOff
+ };
+
+ ShortcutKey(KeyCode key = Key_None, ShiftUsageType shiftUsage = Shift_RequireOff)
+ : Key(key), ShiftUsage(shiftUsage) { }
+
+ KeyCode Key;
+ ShiftUsageType ShiftUsage;
+};
+
+
+//-------------------------------------------------------------------------------------
+struct OptionShortcut
+{
+ Array<ShortcutKey> Keys;
+ Array<UInt32> GamepadButtons;
+ FunctionNotifyBase* pNotify;
+
+ OptionShortcut() : pNotify(NULL) {}
+ OptionShortcut(FunctionNotifyBase* pNotify) : pNotify(pNotify) {}
+ ~OptionShortcut() { if (pNotify) delete pNotify; }
+
+ void AddShortcut(ShortcutKey key) { Keys.PushBack(key); }
+ void AddShortcut(UInt32 gamepadButton) { GamepadButtons.PushBack(gamepadButton); }
+
+ bool MatchKey(KeyCode key, bool shift) const;
+ bool MatchGamepadButton(UInt32 gamepadButtonMask) const;
+};
+
+
+//-------------------------------------------------------------------------------------
+
+// Base class for a menu item. Internally, this can also be OptionSelectionMenu itself
+// to support nested menus. Users shouldn't need to use this class.
+class OptionMenuItem : public NewOverrideBase
+{
+public:
+ virtual ~OptionMenuItem() { }
+
+ virtual void Select() { }
+
+ virtual void NextValue(bool* pFastStep = NULL) { OVR_UNUSED1(pFastStep); }
+ virtual void PrevValue(bool* pFastStep = NULL) { OVR_UNUSED1(pFastStep); }
+
+ virtual String GetLabel() { return Label; }
+ virtual String GetValue() { return ""; }
+
+ // Returns empty string if shortcut not handled
+ virtual String ProcessShortcutKey(KeyCode key, bool shift) = 0;
+ virtual String ProcessShortcutButton(UInt32 buttonMask) = 0;
+
+protected:
+ String Label;
+ String PopNamespaceFrom(OptionMenuItem* menuItem);
+};
+
+
+//-------------------------------------------------------------------------------------
+
+// OptionVar implements a basic menu item, which binds to an external variable,
+// displaying and editing its state.
+class OptionVar : public OptionMenuItem
+{
+public:
+
+ enum VarType
+ {
+ Type_Enum,
+ Type_Int,
+ Type_Float,
+ Type_Bool
+ };
+
+ typedef String (*FormatFunction)(OptionVar*);
+ typedef void (*UpdateFunction)(OptionVar*);
+
+ static String FormatEnum(OptionVar* var);
+ static String FormatInt(OptionVar* var);
+ static String FormatFloat(OptionVar* var);
+ static String FormatTan(OptionVar* var);
+ static String FormatBool(OptionVar* var);
+
+ OptionVar(const char* name, void* pVar, VarType type,
+ FormatFunction formatFunction,
+ UpdateFunction updateFunction = NULL);
+
+ // Integer with range and step size.
+ OptionVar(const char* name, SInt32* pVar,
+ SInt32 min, SInt32 max, SInt32 stepSize=1,
+ const char* formatString = "%d",
+ FormatFunction formatFunction = 0, // Default int formatting.
+ UpdateFunction updateFunction = NULL);
+
+ // Float with range and step size.
+ OptionVar(const char* name, float* pvar,
+ float minf, float maxf, float stepSize = 1.0f,
+ const char* formatString = "%.3f", float formatScale = 1.0f,
+ FormatFunction formatFunction = 0, // Default float formatting.
+ UpdateFunction updateFunction = 0 );
+
+ virtual ~OptionVar();
+
+ SInt32* AsInt() { return reinterpret_cast<SInt32*>(pVar); }
+ bool* AsBool() { return reinterpret_cast<bool*>(pVar); }
+ float* AsFloat() { return reinterpret_cast<float*>(pVar); }
+ VarType GetType() { return Type; }
+
+ // Step through values (wrap for enums).
+ virtual void NextValue(bool* pFastStep);
+ virtual void PrevValue(bool* pFastStep);
+
+ // Executes shortcut message and returns notification string.
+ // Returns empty string for no action.
+ String HandleShortcutUpdate();
+ virtual String ProcessShortcutKey(KeyCode key, bool shift);
+ virtual String ProcessShortcutButton(UInt32 buttonMask);
+
+ OptionVar& AddEnumValue(const char* displayName, SInt32 value);
+
+ template<class C>
+ OptionVar& SetNotify(C* p, void (C::*fn)(OptionVar*))
+ {
+ OVR_ASSERT(pNotify == 0); // Can't set notifier twice.
+ pNotify = new FunctionNotifyContext<C, OptionVar>(p, fn, this);
+ return *this;
+ }
+
+
+ //String Format();
+ virtual String GetValue();
+
+ OptionVar& AddShortcutUpKey(const ShortcutKey& shortcut)
+ { ShortcutUp.AddShortcut(shortcut); return *this; }
+ OptionVar& AddShortcutUpKey(KeyCode key,
+ ShortcutKey::ShiftUsageType shiftUsage = ShortcutKey::Shift_Modify)
+ { ShortcutUp.AddShortcut(ShortcutKey(key, shiftUsage)); return *this; }
+ OptionVar& AddShortcutUpButton(UInt32 gamepadButton)
+ { ShortcutUp.AddShortcut(gamepadButton); return *this; }
+
+ OptionVar& AddShortcutDownKey(const ShortcutKey& shortcut)
+ { ShortcutDown.AddShortcut(shortcut); return *this; }
+ OptionVar& AddShortcutDownKey(KeyCode key,
+ ShortcutKey::ShiftUsageType shiftUsage = ShortcutKey::Shift_Modify)
+ { ShortcutDown.AddShortcut(ShortcutKey(key, shiftUsage)); return *this; }
+ OptionVar& AddShortcutDownButton(UInt32 gamepadButton)
+ { ShortcutDown.AddShortcut(gamepadButton); return *this; }
+
+ OptionVar& AddShortcutKey(const ShortcutKey& shortcut)
+ { return AddShortcutUpKey(shortcut); }
+ OptionVar& AddShortcutKey(KeyCode key,
+ ShortcutKey::ShiftUsageType shiftUsage = ShortcutKey::Shift_RequireOff)
+ { return AddShortcutUpKey(key, shiftUsage); }
+ OptionVar& AddShortcutButton(UInt32 gamepadButton)
+ { return AddShortcutUpButton(gamepadButton); }
+
+private:
+
+ void SignalUpdate()
+ {
+ if (fUpdate) fUpdate(this);
+ if (pNotify) pNotify->CallNotify(this);
+ }
+
+ struct EnumEntry
+ {
+ // Human readable name for enum.
+ String Name;
+ SInt32 Value;
+ };
+
+ // Array of possible enum values.
+ Array<EnumEntry> EnumValues;
+ // Gets the index of the current enum value.
+ UInt32 GetEnumIndex();
+
+ FormatFunction fFormat;
+ UpdateFunction fUpdate;
+ FunctionNotifyBase* pNotify;
+
+ VarType Type;
+ void* pVar;
+ const char* FormatString;
+
+ OptionShortcut ShortcutUp;
+ OptionShortcut ShortcutDown;
+
+ float MinFloat;
+ float MaxFloat;
+ float StepFloat;
+ float FormatScale; // Multiply float by this before rendering
+
+ SInt32 MinInt;
+ SInt32 MaxInt;
+ SInt32 StepInt;
+};
+
+
+//-------------------------------------------------------------------------------------
+// ***** OptionSelectionMenu
+
+// Implements an overlay option menu, brought up by the 'Tab' key.
+// Items are added to the menu with AddBool, AddEnum, AddFloat on startup,
+// and are editable by using arrow keys (underlying variable is modified).
+//
+// Call Render() to render the menu every frame.
+//
+// Menu also support displaying popup messages with a timeout, displayed
+// when menu body isn't up.
+
+class OptionSelectionMenu : public OptionMenuItem
+{
+public:
+ OptionSelectionMenu(OptionSelectionMenu* parentMenu = NULL);
+ ~OptionSelectionMenu();
+
+
+ bool OnKey(OVR::KeyCode key, int chr, bool down, int modifiers);
+ bool OnGamepad(UInt32 buttonMask);
+
+ void Render(RenderDevice* prender, String title = "");
+
+ void AddItem(OptionMenuItem* menuItem);
+
+ // Adds a boolean toggle. Returns added item to allow customization.
+ OptionVar& AddBool(const char* name, bool* pvar,
+ OptionVar::UpdateFunction updateFunction = 0,
+ OptionVar::FormatFunction formatFunction = OptionVar::FormatBool)
+ {
+ OptionVar* p = new OptionVar(name, pvar, OptionVar::Type_Bool,
+ formatFunction, updateFunction);
+ AddItem(p);
+ return *p;
+ }
+
+ // Adds a boolean toggle. Returns added item to allow customization.
+ OptionVar& AddEnum(const char* name, void* pvar,
+ OptionVar::UpdateFunction updateFunction = 0)
+ {
+ OptionVar* p = new OptionVar(name, pvar, OptionVar::Type_Enum,
+ OptionVar::FormatEnum, updateFunction);
+ AddItem(p);
+ return *p;
+ }
+
+
+ // Adds a Float variable. Returns added item to allow customization.
+ OptionVar& AddFloat( const char* name, float* pvar,
+ float minf, float maxf, float stepSize = 1.0f,
+ const char* formatString = "%.3f", float formatScale = 1.0f,
+ OptionVar::FormatFunction formatFunction = 0, // Default float formatting.
+ OptionVar::UpdateFunction updateFunction = 0 )
+ {
+ OptionVar* p = new OptionVar(name, pvar, minf, maxf, stepSize,
+ formatString, formatScale,
+ formatFunction, updateFunction);
+ AddItem(p);
+ return *p;
+ }
+
+ virtual void Select();
+ virtual String GetLabel() { return Label + " >"; }
+
+ virtual String ProcessShortcutKey(KeyCode key, bool shift);
+ virtual String ProcessShortcutButton(UInt32 buttonMask);
+
+ // Sets a message to display with a time-out. Default time-out is 4 seconds.
+ // This uses the same overlay approach as used for shortcut notifications.
+ void SetPopupMessage(const char* format, ...);
+ // Overrides current timeout, in seconds (not the future default value);
+ // intended to be called right after SetPopupMessage.
+ void SetPopupTimeout(double timeoutSeconds, bool border = false);
+
+protected:
+
+ void renderShortcutChangeMessage(RenderDevice* prender);
+
+public:
+ OptionSelectionMenu* GetSubmenu();
+ OptionSelectionMenu* GetOrCreateSubmenu(String submenuName);
+
+ enum DisplayStateType
+ {
+ Display_None,
+ Display_Menu,
+ Display_SingleItem
+ };
+
+ DisplayStateType DisplayState;
+ OptionSelectionMenu* ParentMenu;
+
+ ArrayPOD<OptionMenuItem*> Items;
+ int SelectedIndex;
+ bool SelectionActive;
+
+ String PopupMessage;
+ double PopupMessageTimeout;
+ bool PopupMessageBorder;
+
+ // Possible menu navigation actions.
+ enum NavigationActions
+ {
+ Nav_Up,
+ Nav_Down,
+ Nav_Left,
+ Nav_Right,
+ Nav_Select,
+ Nav_Back,
+ Nav_LAST
+ };
+
+ // Handlers for navigation actions.
+ void HandleUp(bool* pFast);
+ void HandleDown(bool* pFast);
+ void HandleLeft();
+ void HandleRight();
+ void HandleSelect();
+ void HandleBack();
+
+ void HandleMenuToggle();
+ void HandleSingleItemToggle();
+
+ OptionShortcut NavShortcuts[Nav_LAST];
+ OptionShortcut ToggleShortcut;
+ OptionShortcut ToggleSingleItemShortcut;
+};
+
+
+//-------------------------------------------------------------------------------------
+// Text Rendering Utility
+enum DrawTextCenterType
+{
+ DrawText_NoCenter= 0,
+ DrawText_VCenter = 0x01,
+ DrawText_HCenter = 0x02,
+ DrawText_Center = DrawText_VCenter | DrawText_HCenter,
+ DrawText_Border = 0x10,
+};
+
+void DrawTextBox(RenderDevice* prender, float x, float y,
+ float textSize, const char* text,
+ unsigned centerType = DrawText_NoCenter);
+
+void CleanupDrawTextFont();
+
+
+#endif // INC_OptionMenu_h
diff --git a/Samples/OculusWorldDemo/Player.cpp b/Samples/OculusWorldDemo/Player.cpp
index b910307..b2bf00e 100644
--- a/Samples/OculusWorldDemo/Player.cpp
+++ b/Samples/OculusWorldDemo/Player.cpp
@@ -23,135 +23,138 @@ limitations under the License.
#include "Player.h"
#include <Kernel/OVR_Alg.h>
-Player::Player(void)
- : UserEyeHeight(1.8f),
- EyePos(7.7f, 1.8f, -1.0f),
- EyeYaw(YawInitial), EyePitch(0), EyeRoll(0),
- LastSensorYaw(0)
+Player::Player()
+ : UserEyeHeight(1.76f - 0.15f), // 1.76 meters height (ave US male, Wikipedia), less 15 centimeters (TomF's top-of-head-to-eye distance).
+ BodyPos(7.7f, 1.76f - 0.15f, -1.0f),
+ BodyYaw(YawInitial)
{
MoveForward = MoveBack = MoveLeft = MoveRight = 0;
GamepadMove = Vector3f(0);
GamepadRotate = Vector3f(0);
}
+Player::~Player()
+{
+}
+
+Vector3f Player::GetPosition()
+{
+ return BodyPos + Quatf(Vector3f(0,1,0), BodyYaw.Get()).Rotate(HeadPose.Position);
+}
+
+Quatf Player::GetOrientation(bool baseOnly)
+{
+ Quatf baseQ = Quatf(Vector3f(0,1,0), BodyYaw.Get());
+ return baseOnly ? baseQ : baseQ * HeadPose.Orientation;
+}
-Player::~Player(void)
+Posef Player::VirtualWorldPoseFromRealPose(const Posef &sensorHeadPose)
{
+ Quatf baseQ = Quatf(Vector3f(0,1,0), BodyYaw.Get());
+
+ return Posef(baseQ * sensorHeadPose.Orientation,
+ BodyPos + baseQ.Rotate(sensorHeadPose.Position));
}
-void Player::HandleCollision(double dt, Array<Ptr<CollisionModel> >* collisionModels,
- Array<Ptr<CollisionModel> >* groundCollisionModels, bool shiftDown)
+
+void Player::HandleMovement(double dt, Array<Ptr<CollisionModel> >* collisionModels,
+ Array<Ptr<CollisionModel> >* groundCollisionModels, bool shiftDown)
{
- if(MoveForward || MoveBack || MoveLeft || MoveRight || GamepadMove.LengthSq() > 0)
+ // Handle keyboard movement.
+ // This translates BasePos based on the orientation and keys pressed.
+ // Note that Pitch and Roll do not affect movement (they only affect view).
+ Vector3f controllerMove;
+ if(MoveForward || MoveBack || MoveLeft || MoveRight)
{
- Vector3f orientationVector;
- // Handle keyboard movement.
- // This translates EyePos based on Yaw vector direction and keys pressed.
- // Note that Pitch and Roll do not affect movement (they only affect view).
- if(MoveForward || MoveBack || MoveLeft || MoveRight)
+ if (MoveForward)
{
- Vector3f localMoveVector(0, 0, 0);
- Matrix4f yawRotate = Matrix4f::RotationY(EyeYaw);
-
- if (MoveForward)
- {
- localMoveVector = ForwardVector;
- }
- else if (MoveBack)
- {
- localMoveVector = -ForwardVector;
- }
-
- if (MoveRight)
- {
- localMoveVector += RightVector;
- }
- else if (MoveLeft)
- {
- localMoveVector -= RightVector;
- }
+ controllerMove += ForwardVector;
+ }
+ else if (MoveBack)
+ {
+ controllerMove -= ForwardVector;
+ }
- // Normalize vector so we don't move faster diagonally.
- localMoveVector.Normalize();
- orientationVector = yawRotate.Transform(localMoveVector);
+ if (MoveRight)
+ {
+ controllerMove += RightVector;
}
- else if (GamepadMove.LengthSq() > 0)
+ else if (MoveLeft)
{
- Matrix4f yawRotate = Matrix4f::RotationY(EyeYaw);
- GamepadMove.Normalize();
- orientationVector = yawRotate.Transform(GamepadMove);
+ controllerMove -= RightVector;
}
+ }
+ else if (GamepadMove.LengthSq() > 0)
+ {
+ controllerMove = GamepadMove;
+ }
+ controllerMove = GetOrientation(bMotionRelativeToBody).Rotate(controllerMove);
+ controllerMove.y = 0; // Project to the horizontal plane
+ if (controllerMove.LengthSq() > 0)
+ {
+ // Normalize vector so we don't move faster diagonally.
+ controllerMove.Normalize();
+ controllerMove *= OVR::Alg::Min<float>(MoveSpeed * (float)dt * (shiftDown ? 3.0f : 1.0f), 1.0f);
+ }
- float moveLength = OVR::Alg::Min<float>(MoveSpeed * (float)dt * (shiftDown ? 3.0f : 1.0f), 1.0f);
+ // Compute total move direction vector and move length
+ Vector3f orientationVector = controllerMove;
+ float moveLength = orientationVector.Length();
+ if (moveLength > 0)
+ orientationVector.Normalize();
+
+ float checkLengthForward = moveLength;
+ Planef collisionPlaneForward;
+ bool gotCollision = false;
+
+ for(unsigned int i = 0; i < collisionModels->GetSize(); ++i)
+ {
+ // Checks for collisions at model base level, which should prevent us from
+ // slipping under walls
+ if (collisionModels->At(i)->TestRay(BodyPos, orientationVector, checkLengthForward,
+ &collisionPlaneForward))
+ {
+ gotCollision = true;
+ break;
+ }
+ }
- float checkLengthForward = moveLength;
- Planef collisionPlaneForward;
- float checkLengthLeft = moveLength;
- Planef collisionPlaneLeft;
- float checkLengthRight = moveLength;
- Planef collisionPlaneRight;
- bool gotCollision = false;
- bool gotCollisionLeft = false;
- bool gotCollisionRight = false;
+ if (gotCollision)
+ {
+ // Project orientationVector onto the plane
+ Vector3f slideVector = orientationVector - collisionPlaneForward.N
+ * (orientationVector.Dot(collisionPlaneForward.N));
- for(unsigned int i = 0; i < collisionModels->GetSize(); ++i)
+ // Make sure we aren't in a corner
+ for(unsigned int j = 0; j < collisionModels->GetSize(); ++j)
{
- // Checks for collisions at eye level, which should prevent us from
- // slipping under walls
- if (collisionModels->At(i)->TestRay(EyePos, orientationVector, checkLengthForward,
- &collisionPlaneForward))
- {
- gotCollision = true;
- }
-
- Matrix4f leftRotation = Matrix4f::RotationY(45 * (Math<float>::Pi / 180.0f));
- Vector3f leftVector = leftRotation.Transform(orientationVector);
- if (collisionModels->At(i)->TestRay(EyePos, leftVector, checkLengthLeft,
- &collisionPlaneLeft))
- {
- gotCollisionLeft = true;
- }
- Matrix4f rightRotation = Matrix4f::RotationY(-45 * (Math<float>::Pi / 180.0f));
- Vector3f rightVector = rightRotation.Transform(orientationVector);
- if (collisionModels->At(i)->TestRay(EyePos, rightVector, checkLengthRight,
- &collisionPlaneRight))
+ if (collisionModels->At(j)->TestPoint(BodyPos - Vector3f(0.0f, RailHeight, 0.0f) +
+ (slideVector * (moveLength))) )
{
- gotCollisionRight = true;
+ moveLength = 0;
+ break;
}
}
-
- if (gotCollision)
+ if (moveLength != 0)
{
- // Project orientationVector onto the plane
- Vector3f slideVector = orientationVector - collisionPlaneForward.N
- * (orientationVector.Dot(collisionPlaneForward.N));
-
- // Make sure we aren't in a corner
- for(unsigned int j = 0; j < collisionModels->GetSize(); ++j)
- {
- if (collisionModels->At(j)->TestPoint(EyePos - Vector3f(0.0f, RailHeight, 0.0f) +
- (slideVector * (moveLength))) )
- {
- moveLength = 0;
- }
- }
- if (moveLength != 0)
- {
- orientationVector = slideVector;
- }
+ orientationVector = slideVector;
}
- // Checks for collisions at foot level, which allows us to follow terrain
- orientationVector *= moveLength;
- EyePos += orientationVector;
+ }
+ // Checks for collisions at foot level, which allows us to follow terrain
+ orientationVector *= moveLength;
+ BodyPos += orientationVector;
- Planef collisionPlaneDown;
- float finalDistanceDown = 10;
+ Planef collisionPlaneDown;
+ float finalDistanceDown = 10;
+ // Only apply down if there is collision model (otherwise we get jitter).
+ if (groundCollisionModels->GetSize())
+ {
for(unsigned int i = 0; i < groundCollisionModels->GetSize(); ++i)
{
float checkLengthDown = 10;
- if (groundCollisionModels->At(i)->TestRay(EyePos, Vector3f(0.0f, -1.0f, 0.0f),
- checkLengthDown, &collisionPlaneDown))
+ if (groundCollisionModels->At(i)->TestRay(BodyPos, Vector3f(0.0f, -1.0f, 0.0f),
+ checkLengthDown, &collisionPlaneDown))
{
finalDistanceDown = Alg::Min(finalDistanceDown, checkLengthDown);
}
@@ -160,7 +163,32 @@ void Player::HandleCollision(double dt, Array<Ptr<CollisionModel> >* collisionMo
// Maintain the minimum camera height
if (UserEyeHeight - finalDistanceDown < 1.0f)
{
- EyePos.y += UserEyeHeight - finalDistanceDown;
+ BodyPos.y += UserEyeHeight - finalDistanceDown;
}
}
+
+}
+
+
+
+// Handle directional movement. Returns 'true' if movement was processed.
+bool Player::HandleMoveKey(OVR::KeyCode key, bool down)
+{
+ switch(key)
+ {
+ // Handle player movement keys.
+ // We just update movement state here, while the actual translation is done in OnIdle()
+ // based on time.
+ case OVR::Key_W: MoveForward = down ? (MoveForward | 1) : (MoveForward & ~1); return true;
+ case OVR::Key_S: MoveBack = down ? (MoveBack | 1) : (MoveBack & ~1); return true;
+ case OVR::Key_A: MoveLeft = down ? (MoveLeft | 1) : (MoveLeft & ~1); return true;
+ case OVR::Key_D: MoveRight = down ? (MoveRight | 1) : (MoveRight & ~1); return true;
+ case OVR::Key_Up: MoveForward = down ? (MoveForward | 2) : (MoveForward & ~2); return true;
+ case OVR::Key_Down: MoveBack = down ? (MoveBack | 2) : (MoveBack & ~2); return true;
+ case OVR::Key_Left: MoveLeft = down ? (MoveLeft | 2) : (MoveLeft & ~2); return true;
+ case OVR::Key_Right: MoveRight = down ? (MoveRight | 2) : (MoveRight & ~2); return true;
+ }
+ return false;
}
+
+
diff --git a/Samples/OculusWorldDemo/Player.h b/Samples/OculusWorldDemo/Player.h
index e57e67c..f8d29d5 100644
--- a/Samples/OculusWorldDemo/Player.h
+++ b/Samples/OculusWorldDemo/Player.h
@@ -1,7 +1,7 @@
/************************************************************************************
Filename : Player.h
-Content : Player location and hit-testing logic
+Content : Avatar movement and collision detection
Created : October 4, 2012
Copyright : Copyright 2012 Oculus, Inc. All Rights reserved.
@@ -25,23 +25,20 @@ limitations under the License.
#define OVR_WorldDemo_Player_h
#include "OVR.h"
+#include "Kernel/OVR_KeyCodes.h"
#include "../CommonSrc/Render/Render_Device.h"
using namespace OVR;
using namespace OVR::Render;
//-------------------------------------------------------------------------------------
-// The RHS coordinate system is defines as follows (as seen in perspective view):
-// Y - Up
-// Z - Back
-// X - Right
-const Vector3f UpVector(0.0f, 1.0f, 0.0f);
-const Vector3f ForwardVector(0.0f, 0.0f, -1.0f);
+// The RHS coordinate system is assumed.
const Vector3f RightVector(1.0f, 0.0f, 0.0f);
+const Vector3f UpVector(0.0f, 1.0f, 0.0f);
+const Vector3f ForwardVector(0.0f, 0.0f, -1.0f); // -1 because HMD looks along -Z at identity orientation
-// We start out looking in the positive Z (180 degree rotation).
-const float YawInitial = 3.141592f;
-const float Sensitivity = 1.0f;
+const float YawInitial = 0.0f;
+const float Sensitivity = 0.3f; // low sensitivity to ease people into it gently.
const float MoveSpeed = 3.0f; // m/s
// These are used for collision detection
@@ -58,24 +55,37 @@ public:
float UserEyeHeight;
- // Position and look. The following apply:
- Vector3f EyePos;
- float EyeYaw; // Rotation around Y, CCW positive when looking at RHS (X,Z) plane.
- float EyePitch; // Pitch. If sensor is plugged in, only read from sensor.
- float EyeRoll; // Roll, only accessible from Sensor.
- float LastSensorYaw; // Stores previous Yaw value from to support computing delta.
+ // Where the avatar coordinate system (and body) is positioned and oriented in the virtual world
+ // Modified by gamepad/mouse input
+ Vector3f BodyPos;
+ Anglef BodyYaw;
+
+ // Where the player head is positioned and oriented in the real world
+ Posef HeadPose;
+
+ // Where the avatar head is positioned and oriented in the virtual world
+ Vector3f GetPosition();
+ Quatf GetOrientation(bool baseOnly = false);
+
+ // Returns virtual world position based on a real world head pose.
+ // Allows predicting eyes separately based on scanout time.
+ Posef VirtualWorldPoseFromRealPose(const Posef &sensorHeadPose);
+
+ // Handle directional movement. Returns 'true' if movement was processed.
+ bool HandleMoveKey(OVR::KeyCode key, bool down);
- // Movement state; different bits may be set based on the state of keys.
+ // Movement state; different bits may be set based on the state of keys.
UByte MoveForward;
UByte MoveBack;
UByte MoveLeft;
UByte MoveRight;
Vector3f GamepadMove, GamepadRotate;
+ bool bMotionRelativeToBody;
Player();
~Player();
- void HandleCollision(double dt, Array<Ptr<CollisionModel> >* collisionModels,
- Array<Ptr<CollisionModel> >* groundCollisionModels, bool shiftDown);
+ void HandleMovement(double dt, Array<Ptr<CollisionModel> >* collisionModels,
+ Array<Ptr<CollisionModel> >* groundCollisionModels, bool shiftDown);
};
#endif
diff --git a/Samples/OculusWorldDemo/Projects/Win/VS2010/OculusWorldDemo.vcxproj b/Samples/OculusWorldDemo/Projects/Win/VS2010/OculusWorldDemo.vcxproj
new file mode 100644
index 0000000..2167237
--- /dev/null
+++ b/Samples/OculusWorldDemo/Projects/Win/VS2010/OculusWorldDemo.vcxproj
@@ -0,0 +1,227 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{456DA1F5-7D65-4B77-8336-277F3921639B}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>OculusWorldDemo</RootNamespace>
+ <ProjectName>OculusWorldDemo</ProjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(ProjectDir)../../../Obj/Win/VS2010/$(Configuration)/$(PlatformName)/</IntDir>
+ <OutDir>$(ProjectDir)../../../Bin/Win/VS2010/$(Configuration)/$(PlatformName)/</OutDir>
+ <TargetName>OculusWorldDemo</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(ProjectDir)../../../Obj/Win/VS2010/$(Configuration)/$(PlatformName)/</IntDir>
+ <OutDir>$(ProjectDir)../../../Bin/Win/VS2010/$(Configuration)/$(PlatformName)/</OutDir>
+ <TargetName>OculusWorldDemo</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(ProjectDir)../../../Obj/Win/VS2010/$(Configuration)/$(PlatformName)/</IntDir>
+ <OutDir>$(ProjectDir)../../../Bin/Win/VS2010/$(Configuration)/$(PlatformName)/</OutDir>
+ <TargetName>OculusWorldDemo</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(ProjectDir)../../../Obj/Win/VS2010/$(Configuration)/$(PlatformName)/</IntDir>
+ <OutDir>$(ProjectDir)../../../Bin/Win/VS2010/$(Configuration)/$(PlatformName)/</OutDir>
+ <TargetName>OculusWorldDemo</TargetName>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level4</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>OVR_BUILD_DEBUG;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>../../../../../LibOVR/Include;../../../../../3rdParty/glext;../../../../../LibOVR/Src;$(DXSDK_DIR)/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <DebugInformationFormat>OldStyle</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ <MinimalRebuild>false</MinimalRebuild>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalLibraryDirectories>../../../../../LibOVR/Lib/$(Platform)/VS2010/;$(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>opengl32.lib;libovrd.lib;dxgi.lib;d3d10_1.lib;d3d11.lib;d3dcompiler.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level4</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>OVR_BUILD_DEBUG;_WIN64;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>../../../../../LibOVR/Include;../../../../../3rdParty/glext;../../../../../LibOVR/Src;$(DXSDK_DIR)/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <DebugInformationFormat>OldStyle</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ <MinimalRebuild>false</MinimalRebuild>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalLibraryDirectories>../../../../../LibOVR/Lib/$(Platform)/VS2010/;$(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>opengl32.lib;libovr64d.lib;dxgi.lib;d3d10_1.lib;d3d11.lib;d3dcompiler.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level4</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>../../../../../LibOVR/Include;../../../../../3rdParty/glext;../../../../../LibOVR/Src;$(DXSDK_DIR)/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ <DebugInformationFormat>OldStyle</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalLibraryDirectories>../../../../../LibOVR/Lib/$(Platform)/VS2010/;$(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>opengl32.lib;libovr.lib;dxgi.lib;d3d10_1.lib;d3d11.lib;d3dcompiler.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level4</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>_WIN64;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>../../../../../LibOVR/Include;../../../../../3rdParty/glext;../../../../../LibOVR/Src;$(DXSDK_DIR)/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ <DebugInformationFormat>OldStyle</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalLibraryDirectories>../../../../../LibOVR/Lib/$(Platform)/VS2010/;$(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>opengl32.lib;libovr64.lib;dxgi.lib;d3d10_1.lib;d3d11.lib;d3dcompiler.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\..\..\CommonSrc\Platform\Platform.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Platform\Win32_Gamepad.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Platform\Win32_Platform.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_GL_Device.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_GL_Win32_Device.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_LoadTextureDDS.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_LoadTextureTGA.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_Device.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_D3D10_Device.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_D3D11_Device.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_D3D1X_Device.cpp">
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\..\3rdParty\TinyXml\tinyxml2.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_XmlSceneLoader.cpp" />
+ <ClCompile Include="..\..\..\OculusWorldDemo.cpp" />
+ <ClCompile Include="..\..\..\OculusWorldDemo_Scene.cpp" />
+ <ClCompile Include="..\..\..\OptionMenu.cpp" />
+ <ClCompile Include="..\..\..\Player.cpp" />
+ <ClCompile Include="..\..\..\RenderProfiler.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Gamepad.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Platform.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Platform_Default.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Win32_Gamepad.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Win32_Platform.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_Font.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_Device.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_D3D10_Device.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_D3D11_Device.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_D3D1X_Device.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_GL_Device.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_GL_Win32_Device.h" />
+ <ClInclude Include="..\..\..\OptionMenu.h" />
+ <ClInclude Include="..\..\3rdParty\TinyXml\tinyxml2.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_XmlSceneLoader.h" />
+ <ClInclude Include="..\..\..\OculusWorldDemo.h" />
+ <ClInclude Include="..\..\..\Player.h" />
+ <ClInclude Include="..\..\..\RenderProfiler.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="..\..\..\OculusWorldDemo.rc" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Samples/OculusWorldDemo/Projects/Win/VS2010/OculusWorldDemo.vcxproj.filters b/Samples/OculusWorldDemo/Projects/Win/VS2010/OculusWorldDemo.vcxproj.filters
new file mode 100644
index 0000000..67678ea
--- /dev/null
+++ b/Samples/OculusWorldDemo/Projects/Win/VS2010/OculusWorldDemo.vcxproj.filters
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="CommonSrc">
+ <UniqueIdentifier>{ba6e9e50-0655-4f12-a136-6d2a06015925}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="CommonSrc\Platform">
+ <UniqueIdentifier>{16e20d8b-eff7-454c-be85-02037c399e97}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="CommonSrc\Render">
+ <UniqueIdentifier>{1b6d51ae-a405-4f3d-be93-41a50db4f328}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\..\..\CommonSrc\Platform\Platform.cpp">
+ <Filter>CommonSrc\Platform</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Platform\Win32_Platform.cpp">
+ <Filter>CommonSrc\Platform</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_Device.cpp">
+ <Filter>CommonSrc\Render</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_D3D1X_Device.cpp">
+ <Filter>CommonSrc\Render</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_D3D10_Device.cpp">
+ <Filter>CommonSrc\Render</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\OculusWorldDemo.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_D3D11_Device.cpp">
+ <Filter>CommonSrc\Render</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_LoadTextureTGA.cpp">
+ <Filter>CommonSrc\Render</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\Player.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_LoadTextureDDS.cpp">
+ <Filter>CommonSrc\Render</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_XmlSceneLoader.cpp">
+ <Filter>CommonSrc\Render</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Platform\Win32_Gamepad.cpp">
+ <Filter>CommonSrc\Platform</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\OculusWorldDemo_Scene.cpp" />
+ <ClCompile Include="..\..\..\OptionMenu.cpp" />
+ <ClCompile Include="..\..\..\RenderProfiler.cpp" />
+ <ClCompile Include="..\..\..\..\..\3rdParty\TinyXml\tinyxml2.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_GL_Device.cpp">
+ <Filter>CommonSrc\Render</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_GL_Win32_Device.cpp">
+ <Filter>CommonSrc\Render</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Win32_Platform.h">
+ <Filter>CommonSrc\Platform</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Platform.h">
+ <Filter>CommonSrc\Platform</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Platform_Default.h">
+ <Filter>CommonSrc\Platform</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_Font.h">
+ <Filter>CommonSrc\Render</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_Device.h">
+ <Filter>CommonSrc\Render</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_D3D1X_Device.h">
+ <Filter>CommonSrc\Render</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_D3D10_Device.h">
+ <Filter>CommonSrc\Render</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_D3D11_Device.h">
+ <Filter>CommonSrc\Render</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\3rdParty\TinyXml\tinyxml2.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_XmlSceneLoader.h">
+ <Filter>CommonSrc\Render</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Gamepad.h">
+ <Filter>CommonSrc\Platform</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Win32_Gamepad.h">
+ <Filter>CommonSrc\Platform</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\OculusWorldDemo.h" />
+ <ClInclude Include="..\..\..\RenderProfiler.h" />
+ <ClInclude Include="..\..\..\Player.h" />
+ <ClInclude Include="..\..\..\OptionMenu.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_GL_Device.h">
+ <Filter>CommonSrc\Render</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_GL_Win32_Device.h">
+ <Filter>CommonSrc\Render</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="..\..\..\OculusWorldDemo.rc" />
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/Samples/OculusWorldDemo/Projects/Win/VS2012/OculusWorldDemo.vcxproj b/Samples/OculusWorldDemo/Projects/Win/VS2012/OculusWorldDemo.vcxproj
new file mode 100644
index 0000000..1dae2b3
--- /dev/null
+++ b/Samples/OculusWorldDemo/Projects/Win/VS2012/OculusWorldDemo.vcxproj
@@ -0,0 +1,232 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{4F8C2B89-7CF1-4763-8EEF-E969FB760E32}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>OculusWorldDemo</RootNamespace>
+ <ProjectName>OculusWorldDemo</ProjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(ProjectDir)../../../Obj/Win/VS2012/$(Configuration)/$(PlatformName)/</IntDir>
+ <OutDir>$(ProjectDir)../../../Bin/Win/VS2012/$(Configuration)/$(PlatformName)/</OutDir>
+ <TargetName>OculusWorldDemo</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(ProjectDir)../../../Obj/Win/VS2012/$(Configuration)/$(PlatformName)/</IntDir>
+ <OutDir>$(ProjectDir)../../../Bin/Win/VS2012/$(Configuration)/$(PlatformName)/</OutDir>
+ <TargetName>OculusWorldDemo</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(ProjectDir)../../../Obj/Win/VS2012/$(Configuration)/$(PlatformName)/</IntDir>
+ <OutDir>$(ProjectDir)../../../Bin/Win/VS2012/$(Configuration)/$(PlatformName)/</OutDir>
+ <TargetName>OculusWorldDemo</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(ProjectDir)../../../Obj/Win/VS2012/$(Configuration)/$(PlatformName)/</IntDir>
+ <OutDir>$(ProjectDir)../../../Bin/Win/VS2012/$(Configuration)/$(PlatformName)/</OutDir>
+ <TargetName>OculusWorldDemo</TargetName>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level4</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>OVR_BUILD_DEBUG;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>../../../../../LibOVR/Include;../../../../../LibOVR/Src;../../../../../3rdParty/glext;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <DebugInformationFormat>OldStyle</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ <MinimalRebuild>false</MinimalRebuild>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalLibraryDirectories>../../../../../LibOVR/Lib/$(Platform)/VS2012/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>opengl32.lib;libovrd.lib;dxgi.lib;d3d10_1.lib;d3d11.lib;d3dcompiler.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level4</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>OVR_BUILD_DEBUG;_WIN64;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>../../../../../LibOVR/Include;../../../../../LibOVR/Src;../../../../../3rdParty/glext;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <DebugInformationFormat>OldStyle</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ <MinimalRebuild>false</MinimalRebuild>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalLibraryDirectories>../../../../../LibOVR/Lib/$(Platform)/VS2012/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>opengl32.lib;libovr64d.lib;dxgi.lib;d3d10_1.lib;d3d11.lib;d3dcompiler.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level4</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>../../../../../LibOVR/Include;../../../../../LibOVR/Src;../../../../../3rdParty/glext;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ <DebugInformationFormat>OldStyle</DebugInformationFormat>
+ <AdditionalOptions>/d2Zi+ %(AdditionalOptions)</AdditionalOptions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalLibraryDirectories>../../../../../LibOVR/Lib/$(Platform)/VS2012/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>opengl32.lib;libovr.lib;dxgi.lib;d3d10_1.lib;d3d11.lib;d3dcompiler.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level4</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>_WIN64;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>../../../../../LibOVR/Include;../../../../../LibOVR/Src;../../../../../3rdParty/glext;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ <DebugInformationFormat>OldStyle</DebugInformationFormat>
+ <AdditionalOptions>/d2Zi+ %(AdditionalOptions)</AdditionalOptions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalLibraryDirectories>../../../../../LibOVR/Lib/$(Platform)/VS2012/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>opengl32.lib;libovr64.lib;dxgi.lib;d3d10_1.lib;d3d11.lib;d3dcompiler.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\..\..\CommonSrc\Platform\Platform.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Platform\Win32_Gamepad.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Platform\Win32_Platform.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_GL_Device.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_GL_Win32_Device.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_LoadTextureDDS.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_LoadTextureTGA.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_Device.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_D3D10_Device.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_D3D11_Device.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_D3D1X_Device.cpp">
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\..\3rdParty\TinyXml\tinyxml2.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_XmlSceneLoader.cpp" />
+ <ClCompile Include="..\..\..\OculusWorldDemo.cpp" />
+ <ClCompile Include="..\..\..\OculusWorldDemo_Scene.cpp" />
+ <ClCompile Include="..\..\..\OptionMenu.cpp" />
+ <ClCompile Include="..\..\..\Player.cpp" />
+ <ClCompile Include="..\..\..\RenderProfiler.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Gamepad.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Platform.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Platform_Default.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Win32_Gamepad.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Win32_Platform.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_Font.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_Device.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_D3D10_Device.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_D3D11_Device.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_D3D1X_Device.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_GL_Device.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_GL_Win32_Device.h" />
+ <ClInclude Include="..\..\3rdParty\TinyXml\tinyxml2.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_XmlSceneLoader.h" />
+ <ClInclude Include="..\..\..\OculusWorldDemo.h" />
+ <ClInclude Include="..\..\..\Player.h" />
+ <ClInclude Include="..\..\..\RenderProfiler.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="..\..\..\OculusWorldDemo.rc" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Samples/OculusWorldDemo/Projects/Win/VS2012/OculusWorldDemo.vcxproj.filters b/Samples/OculusWorldDemo/Projects/Win/VS2012/OculusWorldDemo.vcxproj.filters
new file mode 100644
index 0000000..7246205
--- /dev/null
+++ b/Samples/OculusWorldDemo/Projects/Win/VS2012/OculusWorldDemo.vcxproj.filters
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="CommonSrc">
+ <UniqueIdentifier>{ba6e9e50-0655-4f12-a136-6d2a06015925}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="CommonSrc\Platform">
+ <UniqueIdentifier>{16e20d8b-eff7-454c-be85-02037c399e97}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="CommonSrc\Render">
+ <UniqueIdentifier>{1b6d51ae-a405-4f3d-be93-41a50db4f328}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\..\..\CommonSrc\Platform\Platform.cpp">
+ <Filter>CommonSrc\Platform</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Platform\Win32_Platform.cpp">
+ <Filter>CommonSrc\Platform</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_Device.cpp">
+ <Filter>CommonSrc\Render</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_D3D1X_Device.cpp">
+ <Filter>CommonSrc\Render</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_D3D10_Device.cpp">
+ <Filter>CommonSrc\Render</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\OculusWorldDemo.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_D3D11_Device.cpp">
+ <Filter>CommonSrc\Render</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_LoadTextureTGA.cpp">
+ <Filter>CommonSrc\Render</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\Player.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_LoadTextureDDS.cpp">
+ <Filter>CommonSrc\Render</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_XmlSceneLoader.cpp">
+ <Filter>CommonSrc\Render</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Platform\Win32_Gamepad.cpp">
+ <Filter>CommonSrc\Platform</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\OculusWorldDemo_Scene.cpp" />
+ <ClCompile Include="..\..\..\OptionMenu.cpp" />
+ <ClCompile Include="..\..\..\RenderProfiler.cpp" />
+ <ClCompile Include="..\..\..\..\..\3rdParty\TinyXml\tinyxml2.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_GL_Win32_Device.cpp">
+ <Filter>CommonSrc\Render</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_GL_Device.cpp">
+ <Filter>CommonSrc\Render</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Win32_Platform.h">
+ <Filter>CommonSrc\Platform</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Platform.h">
+ <Filter>CommonSrc\Platform</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Platform_Default.h">
+ <Filter>CommonSrc\Platform</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_Font.h">
+ <Filter>CommonSrc\Render</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_Device.h">
+ <Filter>CommonSrc\Render</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_D3D1X_Device.h">
+ <Filter>CommonSrc\Render</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_D3D10_Device.h">
+ <Filter>CommonSrc\Render</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_D3D11_Device.h">
+ <Filter>CommonSrc\Render</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\3rdParty\TinyXml\tinyxml2.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_XmlSceneLoader.h">
+ <Filter>CommonSrc\Render</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Gamepad.h">
+ <Filter>CommonSrc\Platform</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Win32_Gamepad.h">
+ <Filter>CommonSrc\Platform</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\OculusWorldDemo.h" />
+ <ClInclude Include="..\..\..\RenderProfiler.h" />
+ <ClInclude Include="..\..\..\Player.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_GL_Device.h">
+ <Filter>CommonSrc\Render</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_GL_Win32_Device.h">
+ <Filter>CommonSrc\Render</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="..\..\..\OculusWorldDemo.rc" />
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/Samples/OculusWorldDemo/Projects/Win/VS2013/OculusWorldDemo.vcxproj b/Samples/OculusWorldDemo/Projects/Win/VS2013/OculusWorldDemo.vcxproj
new file mode 100644
index 0000000..b894075
--- /dev/null
+++ b/Samples/OculusWorldDemo/Projects/Win/VS2013/OculusWorldDemo.vcxproj
@@ -0,0 +1,232 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{CA4E4127-1BAD-447C-BFF9-5AF940EEC376}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>OculusWorldDemo</RootNamespace>
+ <ProjectName>OculusWorldDemo</ProjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v120</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(ProjectDir)../../../Obj/Win/VS2013/$(Configuration)/$(PlatformName)/</IntDir>
+ <OutDir>$(ProjectDir)../../../Bin/Win/VS2013/$(Configuration)/$(PlatformName)/</OutDir>
+ <TargetName>OculusWorldDemo</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(ProjectDir)../../../Obj/Win/VS2013/$(Configuration)/$(PlatformName)/</IntDir>
+ <OutDir>$(ProjectDir)../../../Bin/Win/VS2013/$(Configuration)/$(PlatformName)/</OutDir>
+ <TargetName>OculusWorldDemo</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(ProjectDir)../../../Obj/Win/VS2013/$(Configuration)/$(PlatformName)/</IntDir>
+ <OutDir>$(ProjectDir)../../../Bin/Win/VS2013/$(Configuration)/$(PlatformName)/</OutDir>
+ <TargetName>OculusWorldDemo</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(ProjectDir)../../../Obj/Win/VS2013/$(Configuration)/$(PlatformName)/</IntDir>
+ <OutDir>$(ProjectDir)../../../Bin/Win/VS2013/$(Configuration)/$(PlatformName)/</OutDir>
+ <TargetName>OculusWorldDemo</TargetName>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level4</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>OVR_BUILD_DEBUG;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>../../../../../LibOVR/Include;../../../../../LibOVR/Src;../../../../../3rdParty/glext;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <DebugInformationFormat>OldStyle</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ <MinimalRebuild>false</MinimalRebuild>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalLibraryDirectories>../../../../../LibOVR/Lib/$(Platform)/VS2013/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>opengl32.lib;libovrd.lib;dxgi.lib;d3d10_1.lib;d3d11.lib;d3dcompiler.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level4</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>OVR_BUILD_DEBUG;_WIN64;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>../../../../../LibOVR/Include;../../../../../LibOVR/Src;../../../../../3rdParty/glext;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <DebugInformationFormat>OldStyle</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ <MinimalRebuild>false</MinimalRebuild>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalLibraryDirectories>../../../../../LibOVR/Lib/$(Platform)/VS2013/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>opengl32.lib;libovr64d.lib;dxgi.lib;d3d10_1.lib;d3d11.lib;d3dcompiler.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level4</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>../../../../../LibOVR/Include;../../../../../LibOVR/Src;../../../../../3rdParty/glext;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ <DebugInformationFormat>OldStyle</DebugInformationFormat>
+ <AdditionalOptions>/d2Zi+ %(AdditionalOptions)</AdditionalOptions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalLibraryDirectories>../../../../../LibOVR/Lib/$(Platform)/VS2013/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>opengl32.lib;libovr.lib;dxgi.lib;d3d10_1.lib;d3d11.lib;d3dcompiler.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level4</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>_WIN64;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>../../../../../LibOVR/Include;../../../../../LibOVR/Src;../../../../../3rdParty/glext;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ <DebugInformationFormat>OldStyle</DebugInformationFormat>
+ <AdditionalOptions>/d2Zi+ %(AdditionalOptions)</AdditionalOptions>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalLibraryDirectories>../../../../../LibOVR/Lib/$(Platform)/VS2013/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>opengl32.lib;libovr64.lib;dxgi.lib;d3d10_1.lib;d3d11.lib;d3dcompiler.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\..\..\CommonSrc\Platform\Platform.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Platform\Win32_Gamepad.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Platform\Win32_Platform.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_GL_Device.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_GL_Win32_Device.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_LoadTextureDDS.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_LoadTextureTGA.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_Device.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_D3D10_Device.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_D3D11_Device.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_D3D1X_Device.cpp">
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\..\3rdParty\TinyXml\tinyxml2.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_XmlSceneLoader.cpp" />
+ <ClCompile Include="..\..\..\OculusWorldDemo.cpp" />
+ <ClCompile Include="..\..\..\OculusWorldDemo_Scene.cpp" />
+ <ClCompile Include="..\..\..\OptionMenu.cpp" />
+ <ClCompile Include="..\..\..\Player.cpp" />
+ <ClCompile Include="..\..\..\RenderProfiler.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Gamepad.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Platform.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Platform_Default.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Win32_Gamepad.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Win32_Platform.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_Font.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_Device.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_D3D10_Device.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_D3D11_Device.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_D3D1X_Device.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_GL_Device.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_GL_Win32_Device.h" />
+ <ClInclude Include="..\..\3rdParty\TinyXml\tinyxml2.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_XmlSceneLoader.h" />
+ <ClInclude Include="..\..\..\OculusWorldDemo.h" />
+ <ClInclude Include="..\..\..\Player.h" />
+ <ClInclude Include="..\..\..\RenderProfiler.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="..\..\..\OculusWorldDemo.rc" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Samples/OculusWorldDemo/Projects/Win/VS2013/OculusWorldDemo.vcxproj.filters b/Samples/OculusWorldDemo/Projects/Win/VS2013/OculusWorldDemo.vcxproj.filters
new file mode 100644
index 0000000..93fff72
--- /dev/null
+++ b/Samples/OculusWorldDemo/Projects/Win/VS2013/OculusWorldDemo.vcxproj.filters
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="CommonSrc">
+ <UniqueIdentifier>{ba6e9e50-0655-4f12-a136-6d2a06015925}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="CommonSrc\Platform">
+ <UniqueIdentifier>{16e20d8b-eff7-454c-be85-02037c399e97}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="CommonSrc\Render">
+ <UniqueIdentifier>{1b6d51ae-a405-4f3d-be93-41a50db4f328}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\..\..\CommonSrc\Platform\Platform.cpp">
+ <Filter>CommonSrc\Platform</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Platform\Win32_Platform.cpp">
+ <Filter>CommonSrc\Platform</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_Device.cpp">
+ <Filter>CommonSrc\Render</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_D3D1X_Device.cpp">
+ <Filter>CommonSrc\Render</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_D3D10_Device.cpp">
+ <Filter>CommonSrc\Render</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\OculusWorldDemo.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_D3D11_Device.cpp">
+ <Filter>CommonSrc\Render</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_LoadTextureTGA.cpp">
+ <Filter>CommonSrc\Render</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\Player.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_LoadTextureDDS.cpp">
+ <Filter>CommonSrc\Render</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_XmlSceneLoader.cpp">
+ <Filter>CommonSrc\Render</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Platform\Win32_Gamepad.cpp">
+ <Filter>CommonSrc\Platform</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\OculusWorldDemo_Scene.cpp" />
+ <ClCompile Include="..\..\..\OptionMenu.cpp" />
+ <ClCompile Include="..\..\..\RenderProfiler.cpp" />
+ <ClCompile Include="..\..\..\..\..\3rdParty\TinyXml\tinyxml2.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_GL_Win32_Device.cpp">
+ <Filter>CommonSrc\Render</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Render\Render_GL_Device.cpp">
+ <Filter>CommonSrc\Render</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Win32_Platform.h">
+ <Filter>CommonSrc\Platform</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Platform.h">
+ <Filter>CommonSrc\Platform</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Platform_Default.h">
+ <Filter>CommonSrc\Platform</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_Font.h">
+ <Filter>CommonSrc\Render</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_Device.h">
+ <Filter>CommonSrc\Render</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_D3D1X_Device.h">
+ <Filter>CommonSrc\Render</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_D3D10_Device.h">
+ <Filter>CommonSrc\Render</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_D3D11_Device.h">
+ <Filter>CommonSrc\Render</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\3rdParty\TinyXml\tinyxml2.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_XmlSceneLoader.h">
+ <Filter>CommonSrc\Render</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Gamepad.h">
+ <Filter>CommonSrc\Platform</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Win32_Gamepad.h">
+ <Filter>CommonSrc\Platform</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\OculusWorldDemo.h" />
+ <ClInclude Include="..\..\..\RenderProfiler.h" />
+ <ClInclude Include="..\..\..\Player.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_GL_Win32_Device.h">
+ <Filter>CommonSrc\Render</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Render\Render_GL_Device.h">
+ <Filter>CommonSrc\Render</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="..\..\..\OculusWorldDemo.rc" />
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/Samples/OculusWorldDemo/Release/readme b/Samples/OculusWorldDemo/Release/readme
deleted file mode 100644
index c9d0bc0..0000000
--- a/Samples/OculusWorldDemo/Release/readme
+++ /dev/null
@@ -1,2 +0,0 @@
-This document exits to ensure that the required directory structure gets created correctly.
-
diff --git a/Samples/OculusWorldDemo/RenderProfiler.cpp b/Samples/OculusWorldDemo/RenderProfiler.cpp
new file mode 100644
index 0000000..00bbdd9
--- /dev/null
+++ b/Samples/OculusWorldDemo/RenderProfiler.cpp
@@ -0,0 +1,99 @@
+/************************************************************************************
+
+Filename : RenderProfiler.cpp
+Content : Profiling for render.
+Created : March 10, 2014
+Authors : Caleb Leak
+
+Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+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.
+
+*************************************************************************************/
+
+#include "RenderProfiler.h"
+
+using namespace OVR;
+
+RenderProfiler::RenderProfiler()
+{
+ memset(SampleHistory, 0, sizeof(SampleHistory));
+ memset(SampleAverage, 0, sizeof(SampleAverage));
+ SampleCurrentFrame = 0;
+}
+
+void RenderProfiler::RecordSample(SampleType sampleType)
+{
+ if (sampleType == Sample_FrameStart)
+ {
+ // Recompute averages and subtract off frame start time.
+ for (int sample = 1; sample < Sample_LAST; sample++)
+ {
+ SampleHistory[SampleCurrentFrame][sample] -= SampleHistory[SampleCurrentFrame][0];
+
+ // Recompute the average for the current sample type.
+ SampleAverage[sample] = 0.0;
+ for (int frame = 0; frame < NumFramesOfTimerHistory; frame++)
+ {
+ SampleAverage[sample] += SampleHistory[frame][sample];
+ }
+ SampleAverage[sample] /= NumFramesOfTimerHistory;
+ }
+
+ SampleCurrentFrame = ((SampleCurrentFrame + 1) % NumFramesOfTimerHistory);
+ }
+
+ SampleHistory[SampleCurrentFrame][sampleType] = ovr_GetTimeInSeconds();
+}
+
+const double* RenderProfiler::GetLastSampleSet() const
+{
+ return SampleHistory[(SampleCurrentFrame - 1 + NumFramesOfTimerHistory) % NumFramesOfTimerHistory];
+}
+
+void RenderProfiler::DrawOverlay(RenderDevice* prender)
+{
+ char buf[256 * Sample_LAST];
+ OVR_strcpy ( buf, sizeof(buf), "Timing stats" ); // No trailing \n is deliberate.
+
+ /*int timerLastFrame = TimerCurrentFrame - 1;
+ if ( timerLastFrame < 0 )
+ {
+ timerLastFrame = NumFramesOfTimerHistory - 1;
+ }*/
+ // Timer 0 is always the time at the start of the frame.
+
+ const double* averages = GetAverages();
+ const double* lastSampleSet = GetLastSampleSet();
+
+ for ( int timerNum = 1; timerNum < Sample_LAST; timerNum++ )
+ {
+ char const *pName = "";
+ switch ( timerNum )
+ {
+ case Sample_AfterGameProcessing: pName = "AfterGameProcessing"; break;
+ case Sample_AfterEyeRender : pName = "AfterEyeRender "; break;
+// case Sample_BeforeDistortion : pName = "BeforeDistortion "; break;
+// case Sample_AfterDistortion : pName = "AfterDistortion "; break;
+ case Sample_AfterPresent : pName = "AfterPresent "; break;
+// case Sample_AfterFlush : pName = "AfterFlush "; break;
+ default: OVR_ASSERT ( false );
+ }
+ char bufTemp[256];
+ OVR_sprintf ( bufTemp, sizeof(bufTemp), "\nRaw: %.2lfms\t400Ave: %.2lfms\t800%s",
+ lastSampleSet[timerNum] * 1000.0, averages[timerNum] * 1000.0, pName );
+ OVR_strcat ( buf, sizeof(buf), bufTemp );
+ }
+
+ DrawTextBox(prender, 0.0f, 0.0f, 22.0f, buf, DrawText_Center);
+} \ No newline at end of file
diff --git a/Samples/OculusWorldDemo/RenderProfiler.h b/Samples/OculusWorldDemo/RenderProfiler.h
new file mode 100644
index 0000000..96ec50a
--- /dev/null
+++ b/Samples/OculusWorldDemo/RenderProfiler.h
@@ -0,0 +1,71 @@
+/************************************************************************************
+
+Filename : RenderProfiler.h
+Content : Profiling for render.
+Created : March 10, 2014
+Authors : Caleb Leak
+
+Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+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 INC_RenderProfiler_h
+#define INC_RenderProfiler_h
+
+#include "OVR.h"
+
+// TODO: Refactor option menu so dependencies are in a separate file.
+#include "OptionMenu.h"
+
+//-------------------------------------------------------------------------------------
+// ***** RenderProfiler
+
+// Tracks reported timing sample in a frame and dislays them an overlay from DrawOverlay().
+class RenderProfiler
+{
+public:
+ enum { NumFramesOfTimerHistory = 10 };
+
+ enum SampleType
+ {
+ Sample_FrameStart ,
+ Sample_AfterGameProcessing ,
+ Sample_AfterEyeRender ,
+ // Sample_BeforeDistortion ,
+ // Sample_AfterDistortion ,
+ Sample_AfterPresent ,
+ // Sample_AfterFlush ,
+
+ Sample_LAST
+ };
+
+ RenderProfiler();
+
+ // Records the current time for the given sample type.
+ void RecordSample(SampleType sampleType);
+
+ const double* GetAverages() const { return SampleAverage; }
+ const double* GetLastSampleSet() const;
+
+ void DrawOverlay(RenderDevice* prender);
+
+private:
+
+ double SampleHistory[NumFramesOfTimerHistory][Sample_LAST];
+ double SampleAverage[Sample_LAST];
+ int SampleCurrentFrame;
+};
+
+#endif // INC_RenderProfiler_h
diff --git a/Samples/SensorBox/SensorBoxTest.cpp b/Samples/SensorBox/SensorBoxTest.cpp
deleted file mode 100644
index 7ca416f..0000000
--- a/Samples/SensorBox/SensorBoxTest.cpp
+++ /dev/null
@@ -1,506 +0,0 @@
-/************************************************************************************
-
-Filename : SensorBoxTest.h
-Content : Visual orientaion sensor test app; renders a rotating box over axes.
-Created : October 1, 2012
-Authors : Michael Antonov
-
-Copyright : Copyright 2012 Oculus, Inc. All Rights reserved.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-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.
-
-*************************************************************************************/
-
-#include "OVR.h"
-#include "Kernel/OVR_String.h"
-
-#include "../CommonSrc/Platform/Platform_Default.h"
-#include "../CommonSrc/Render/Render_Device.h"
-#include "../CommonSrc/Platform/Gamepad.h"
-
-using namespace OVR;
-using namespace OVR::Platform;
-using namespace OVR::Render;
-
-//-------------------------------------------------------------------------------------
-// ***** SensorBoxTest Description
-
-// This application renders an axes-colored box that rotates with sensor input. App allows
-// user to toggle views for debugging purposes by pressing F1, F2, F3 keys.
-// Application further allows running multiple sensors at once to compare sensor quality.
-//
-// The Right-handed coordinate system is defines as follows (as seen in perspective view):
-// Y - Up (colored red)
-// Z - Back (Out from screen, colored blue)
-// X - Right (green)
-// All cameras are looking at the origin.
-
-// Camera view types.
-enum ViewType
-{
- View_Perspective,
- View_XZ_UpY,
- View_XY_DownZ,
- View_Count
-};
-
-
-//-------------------------------------------------------------------------------------
-
-class InputTestApp : public Application
-{
- RenderDevice* pRender;
-
- Ptr<DeviceManager> pManager;
- Ptr<HMDDevice> pHMD;
- Ptr<SensorDevice> pSensor;
- Ptr<SensorDevice> pSensor2;
-
- SensorFusion SFusion;
- SensorFusion SFusion2;
-
- double LastUpdate;
- ViewType CurrentView;
-
- double LastTitleUpdate;
-
- Matrix4f Proj;
- Matrix4f View;
- Scene Sc;
- Ptr<Model> pAxes; // Model of the coordinate system
- Ptr<Container> pBox; // Rendered box
- Ptr<Container> pBox2; // Second model (right now just lines)
-
- // Applies specified projection/lookAt direction to the scene.
- void SetView(ViewType view);
-
-public:
-
- InputTestApp();
- ~InputTestApp();
-
- virtual int OnStartup(int argc, const char** argv);
- virtual void OnIdle();
-
- virtual void OnMouseMove(int x, int y, int modifiers);
- virtual void OnKey(KeyCode key, int chr, bool down, int modifiers);
-};
-
-InputTestApp::InputTestApp()
- : pRender(0), CurrentView(View_Perspective),
- LastUpdate(0), LastTitleUpdate(0), pAxes(0), pBox(0)
-{
-
-}
-
-
-/*
-void UseCase()
-{
- using namespace OVR;
-
- OVR::System::Init();
-
- Ptr<DeviceManager> pManager = 0;
- Ptr<HMDDevice> pHMD = 0;
- Ptr<SensorDevice> pSensor = 0;
- SensorFusion FusionResult;
-
-
- // *** Initialization - Create the first available HMD Device
- pManager = *DeviceManager::Create();
- pHMD = *pManager->EnumerateDevices<HMDDevice>().CreateDevice();
- if (!pHMD)
- return;
- pSensor = *pHMD->GetSensor();
-
- // Get DisplayDeviceName, ScreenWidth/Height, etc..
- HMDInfo hmdInfo;
- pHMD->GetDeviceInfo(&hmdInfo);
-
- if (pSensor)
- FusionResult.AttachToSensor(pSensor);
-
- // *** Per Frame
- // Get orientation quaternion to control view
- Quatf q = FusionResult.GetOrientation();
-
- // Create a matrix from quaternion,
- // where elements [0][0] through [3][3] contain rotation.
- Matrix4f bodyFrameMatrix(q);
-
- // Get Euler angles from quaternion, in specified axis rotation order.
- float yaw, pitch, roll;
- q.GetEulerAngles<Axis_Y, Axis_X, Axis_Z>(&yaw, &pitch, &roll);
-
- // *** Shutdown
- pSensor.Clear();
- pHMD.Clear();
- pManager.Clear();
-
- OVR::System::Destroy();
-}
-*/
-
-InputTestApp::~InputTestApp()
-{
- pSensor.Clear();
- pManager.Clear();
-
-}
-
-
-int InputTestApp::OnStartup(int argc, const char** argv)
-{
- if (!pPlatform->SetupWindow(1200,800))
- return 1;
-
-
- pManager = *DeviceManager::Create();
-
- // This initialization logic supports running two sensors at the same time.
-
- DeviceEnumerator<SensorDevice> isensor = pManager->EnumerateDevices<SensorDevice>();
- DeviceEnumerator<SensorDevice> oculusSensor;
- DeviceEnumerator<SensorDevice> oculusSensor2;
-
- while(isensor)
- {
- DeviceInfo di;
- if (isensor.GetDeviceInfo(&di))
- {
- if (strstr(di.ProductName, "Tracker"))
- {
- if (!oculusSensor)
- oculusSensor = isensor;
- else if (!oculusSensor2)
- oculusSensor2 = isensor;
- }
- }
-
- isensor.Next();
- }
-
- if (oculusSensor)
- {
- pSensor = *oculusSensor.CreateDevice();
-
- if (pSensor)
- pSensor->SetRange(SensorRange(4 * 9.81f, 8 * Math<float>::Pi, 1.0f), true);
-
- if (oculusSensor2)
- {
- // Second Oculus sensor, useful for comparing firmware behavior & settings.
- pSensor2 = *oculusSensor2.CreateDevice();
-
- if (pSensor2)
- pSensor2->SetRange(SensorRange(4 * 9.81f, 8 * Math<float>::Pi, 1.0f), true);
- }
- }
-
- oculusSensor.Clear();
- oculusSensor2.Clear();
-
-
- /*
- DeviceHandle hHMD = pManager->EnumerateDevices<HMDDevice>();
- HMDInfo hmdInfo;
- if (hHMD)
- {
- hHMD.GetDeviceInfo(&hmdInfo);
- }
- */
-
- if (pSensor)
- SFusion.AttachToSensor(pSensor);
- if (pSensor2)
- SFusion2.AttachToSensor(pSensor2);
-
- /*
- // Test rotation: This give rotations clockwise (CW) while looking from
- // origin in the direction of the axis.
-
- Vector3f xV(1,0,0);
- Vector3f zV(0,0,1);
-
- Vector3f rxV = Matrix4f::RotationZ(DegreeToRad(10.0f)).Transform(xV);
- Vector3f ryV = Matrix4f::RotationY(DegreeToRad(10.0f)).Transform(xV);
- Vector3f rzV = Matrix4f::RotationX(DegreeToRad(10.0f)).Transform(zV);
- */
-
- // Report relative mouse motion (not absolute position)
- // pPlatform->SetMouseMode(Mouse_Relative);
-
- const char* graphics = "d3d10";
- for (int i = 1; i < argc; i++)
- if (!strcmp(argv[i], "-r") && i < argc-1)
- graphics = argv[i+1];
-
- pRender = pPlatform->SetupGraphics(OVR_DEFAULT_RENDER_DEVICE_SET, graphics,
- RendererParams());
-
- //WireframeFill = pRender->CreateSimpleFill(Fill::F_Wireframe);
-
-
-
- // *** Rotating Box
-
- pBox = *new Container;
- pBox->Add(Ptr<Model>(
- *Model::CreateAxisFaceColorBox(-2.0f, 2.0f, Color(0, 0xAA, 0), // x = green
- -1.0f, 1.0f, Color(0xAA,0, 0), // y = red
- -1.0f, 1.0f, Color(0, 0, 0xAA)) )); // z = blue
- // Drop-down line from box, to make it easier to see differences in angle.
- Ptr<Model> downLine = *new Model(Prim_Lines);
- downLine->AddLine(Vertex(0.0f,-4.5f, 0.0f, 0xFFE0B0B0),
- Vertex(0.0f, 0.0f, 0.0f, 0xFFE0B0B0));
- pBox->Add(downLine);
- Sc.World.Add(pBox);
-
-
- // Secondary rotating coordinate object, if we have two values.
- if (pSensor2)
- {
- pBox2 = *new Container;
-
- // Drop-down line from box, to make it easier to see differences in angle.
- Ptr<Model> lines = *new Model(Prim_Lines);
- lines->AddLine(Vertex( 0.0f,-4.0f, 0.0f, 0xFFA07070), // -Y
- Vertex( 0.0f, 0.0f, 0.0f, 0xFFA07070));
- lines->AddLine(Vertex(-4.0f, 0.0f, 0.0f, 0xFF70A070), // -X
- Vertex( 0.0f, 0.0f, 0.0f, 0xFF70A070));
- lines->AddLine(Vertex( 0.0f, 0.0f,-4.0f, 0xFF7070A0), // -Z
- Vertex( 0.0f, 0.0f, 0.0f, 0xFF7070A0));
- pBox2->Add(lines);
- Sc.World.Add(pBox2);
- }
-
-
- // *** World axis X,Y,Z rendering.
-
- pAxes = *new Model(Prim_Lines);
- pAxes->AddLine(Vertex(-8.0f, 0.0f, 0.0f, 0xFF40FF40),
- Vertex( 8.0f, 0.0f, 0.0f, 0xFF40FF40)); // X
- pAxes->AddLine(Vertex( 7.6f, 0.4f, 0.4f, 0xFF40FF40),
- Vertex( 8.0f, 0.0f, 0.0f, 0xFF40FF40)); // X - arrow
- pAxes->AddLine(Vertex( 7.6f,-0.4f,-0.4f, 0xFF40FF40),
- Vertex( 8.0f, 0.0f, 0.0f, 0xFF40FF40)); // X - arrow
-
- pAxes->AddLine(Vertex( 0.0f,-8.0f, 0.0f, 0xFFFF4040),
- Vertex( 0.0f, 8.0f, 0.0f, 0xFFFF4040)); // Y
- pAxes->AddLine(Vertex( 0.4f, 7.6f, 0.0f, 0xFFFF4040),
- Vertex( 0.0f, 8.0f, 0.0f, 0xFFFF4040)); // Y - arrow
- pAxes->AddLine(Vertex(-0.4f, 7.6f, 0.0f, 0xFFFF4040),
- Vertex( 0.0f, 8.0f, 0.0f, 0xFFFF4040)); // Y
-
- pAxes->AddLine(Vertex( 0.0f, 0.0f,-8.0f, 0xFF4040FF),
- Vertex( 0.0f, 0.0f, 8.0f, 0xFF4040FF)); // Z
- pAxes->AddLine(Vertex( 0.4f, 0.0f, 7.6f, 0xFF4040FF),
- Vertex( 0.0f, 0.0f, 8.0f, 0xFF4040FF)); // Z - arrow
- pAxes->AddLine(Vertex(-0.4f, 0.0f, 7.6f, 0xFF4040FF),
- Vertex( 0.0f, 0.0f, 8.0f, 0xFF4040FF)); // Z - arrow
- Sc.World.Add(pAxes);
-
-
- SetView(CurrentView);
-
-
- LastUpdate = pPlatform->GetAppTime();
- return 0;
-}
-
-void InputTestApp::SetView(ViewType type)
-{
- switch(type)
- {
- case View_Perspective:
- View = Matrix4f::LookAtRH(Vector3f(5.0f, 4.0f, 10.0f), // eye
- Vector3f(0.0f, 1.5f, 0.0f), // at
- Vector3f(0.0f, 1.0f, 0.0f));
- break;
-
- case View_XY_DownZ: // F2
- View = Matrix4f::LookAtRH(Vector3f(0.0f, 0.0f, 10.0f), // eye
- Vector3f(0.0f, 0.0f, 0.0f), // at
- Vector3f(0.0f, 1.0f, 0.0f));
- break;
-
- case View_XZ_UpY:
- View = Matrix4f::LookAtRH(Vector3f(0.0f,-10.0f, 0.0f), // eye
- Vector3f(0.0f, 0.0f, 0.0f), // at
- Vector3f(0.0f, 0.0f, 1.0f));
-
- break;
- default:
- break;
- }
-
- Proj = Matrix4f::PerspectiveRH(DegreeToRad(70.0f), 1280 / (float)800,
- 0.3f, 1000.0f); // LH
-}
-
-
-void InputTestApp::OnMouseMove(int x, int y, int modifiers)
-{
- OVR_UNUSED3(x, y, modifiers);
-}
-
-
-static float CalcDownAngleDegrees(Quatf q)
-{
- Vector3f downVector(0.0f, -1.0f, 0.0f);
- Vector3f val= q.Rotate(downVector);
- return RadToDegree(downVector.Angle(val));
-}
-
-void InputTestApp::OnKey(KeyCode key, int chr, bool down, int modifiers)
-{
- OVR_UNUSED2(chr, modifiers);
-
- switch (key)
- {
- case Key_Q:
- if (!down)
- pPlatform->Exit(0);
- break;
-
- case Key_F1:
- CurrentView = View_Perspective;
- SetView(CurrentView);
- //UpdateWindowTitle();
- break;
- case Key_F2:
- CurrentView = View_XY_DownZ;
- SetView(CurrentView);
- break;
- case Key_F3:
- CurrentView = View_XZ_UpY;
- SetView(CurrentView);
- break;
-
- case Key_R:
- if (down)
- {
- SFusion.Reset();
- SFusion2.Reset();
- }
- break;
-
- case Key_H:
- if (down && pSensor)
- {
- SensorDevice::CoordinateFrame coord = pSensor->GetCoordinateFrame();
- pSensor->SetCoordinateFrame(
- (coord == SensorDevice::Coord_Sensor) ?
- SensorDevice::Coord_HMD : SensorDevice::Coord_Sensor);
- SFusion.Reset();
- SFusion2.Reset();
- }
- break;
-
- case Key_G:
- if (down)
- {
- SFusion.SetGravityEnabled(!SFusion.IsGravityEnabled());
- SFusion2.SetGravityEnabled(SFusion.IsGravityEnabled());
- }
- break;
-
- case Key_A:
-
- if (down)
- {
- if (!pSensor2)
- {
- LogText("Angle: %2.3f\n", CalcDownAngleDegrees(SFusion.GetOrientation()));
- }
- else
- {
- LogText("Angle: %2.3f Secondary Sensor Angle: %2.3f\n",
- CalcDownAngleDegrees(SFusion.GetOrientation()),
- CalcDownAngleDegrees(SFusion2.GetOrientation()));
- }
- }
- break;
-
- /*
- case Key_End:
- if (!down)
- {
- OriAdjust = OriSensor.Conj();
- Sc.ViewPoint.SetOrientation(Quatf());
- }
- break; */
- default:
- break;
- }
-}
-
-void InputTestApp::OnIdle()
-{
- double curtime = pPlatform->GetAppTime();
- // float dt = float(LastUpdate - curtime);
- LastUpdate = curtime;
-
- if (pBox)
- {
- Quatf q = SFusion.GetOrientation();
- pBox->SetOrientation(q);
-
- // Test Euler conversion, alternative to the above:
- // Vector3f euler;
- // SFusion.GetOrientation().GetEulerABC<Axis_Y, Axis_X, Axis_Z, Rotate_CCW, Handed_R>(&euler.y, &euler.x, &euler.z);
- // Matrix4f mat = Matrix4f::RotationY(euler.y) * Matrix4f::RotationX(euler.x) * Matrix4f::RotationZ(euler.z);
- // pBox->SetMatrix(mat);
-
- // Update titlebar every 20th of a second.
- if ((curtime - LastTitleUpdate) > 0.05f)
- {
- char titleBuffer[512];
- SensorDevice::CoordinateFrame coord = SensorDevice::Coord_Sensor;
- if (pSensor)
- coord = pSensor->GetCoordinateFrame();
-
- OVR_sprintf(titleBuffer, 512, "OVR SensorBox %s %s Ang: %0.3f",
- (SFusion.IsGravityEnabled() ? "" : "[Grav Off]"),
- (coord == SensorDevice::Coord_HMD) ? "[HMD Coord]" : "",
- CalcDownAngleDegrees(q));
- pPlatform->SetWindowTitle(titleBuffer);
- LastTitleUpdate = curtime;
- }
- }
-
- if (pBox2)
- {
- pBox2->SetOrientation(SFusion2.GetOrientation());
- }
-
- // Render
- int w, h;
- pPlatform->GetWindowSize(&w, &h);
-
- pRender->SetViewport(0, 0, w, h);
-
- pRender->Clear();
- pRender->BeginScene();
-
- pRender->SetProjection(Proj);
- pRender->SetDepthMode(1,1);
-
- Sc.Render(pRender, View);
-
- pRender->Present();
-
-}
-
-OVR_PLATFORM_APP(InputTestApp);
diff --git a/Samples/SensorBox/SensorBoxTest.rc b/Samples/SensorBox/SensorBoxTest.rc
deleted file mode 100644
index 49a6a5a..0000000
--- a/Samples/SensorBox/SensorBoxTest.rc
+++ /dev/null
Binary files differ
diff --git a/Samples/SensorBox/SensorBoxTest_Msvc2010.vcxproj b/Samples/SensorBox/SensorBoxTest_Msvc2010.vcxproj
deleted file mode 100644
index a0c06af..0000000
--- a/Samples/SensorBox/SensorBoxTest_Msvc2010.vcxproj
+++ /dev/null
@@ -1,126 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{8051B837-2982-4F64-8C3B-FAF88B6D83AB}</ProjectGuid>
- <Keyword>Win32Proj</Keyword>
- <RootNamespace>SensorBoxTest</RootNamespace>
- <ProjectName>SensorBoxTest</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <LinkIncremental>true</LinkIncremental>
- <IntDir>$(Configuration)\Obj\</IntDir>
- <OutDir>$(ProjectDir)$(Configuration)\</OutDir>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <LinkIncremental>false</LinkIncremental>
- <IntDir>$(Configuration)\Obj\</IntDir>
- <OutDir>$(ProjectDir)$(Configuration)\</OutDir>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <PrecompiledHeader>
- </PrecompiledHeader>
- <WarningLevel>Level4</WarningLevel>
- <Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>OVR_BUILD_DEBUG;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>../../LibOVR/Include;../../LibOVR/Src;../../3rdParty/glext;$(DXSDK_DIR)/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <DebugInformationFormat>OldStyle</DebugInformationFormat>
- <MultiProcessorCompilation>true</MultiProcessorCompilation>
- <StringPooling>
- </StringPooling>
- <MinimalRebuild>false</MinimalRebuild>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalDependencies>libovrd.lib;dxgi.lib;d3d10.lib;d3d11.lib;d3dcompiler.lib;opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>../../LibOVR/Lib/Win32;$(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <WarningLevel>Level4</WarningLevel>
- <PrecompiledHeader>
- </PrecompiledHeader>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>../../LibOVR/Include;../../LibOVR/Src;../../3rdParty/glext;$(DXSDK_DIR)/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- <MultiProcessorCompilation>true</MultiProcessorCompilation>
- <DebugInformationFormat>OldStyle</DebugInformationFormat>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <AdditionalLibraryDirectories>../../LibOVR/Lib/Win32;$(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <AdditionalDependencies>libovr.lib;dxgi.lib;d3d10.lib;d3d11.lib;d3dcompiler.lib;opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\CommonSrc\Platform\Platform.cpp" />
- <ClCompile Include="..\CommonSrc\Platform\Win32_Gamepad.cpp" />
- <ClCompile Include="..\CommonSrc\Platform\Win32_Platform.cpp" />
- <ClCompile Include="..\CommonSrc\Render\Render_Device.cpp" />
- <ClCompile Include="..\CommonSrc\Render\Render_D3D10_Device.cpp" />
- <ClCompile Include="..\CommonSrc\Render\Render_D3D11_Device.cpp" />
- <ClCompile Include="..\CommonSrc\Render\Render_D3D1X_Device.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="SensorBoxTest.cpp" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="..\CommonSrc\Platform\Gamepad.h" />
- <ClInclude Include="..\CommonSrc\Platform\Platform.h" />
- <ClInclude Include="..\CommonSrc\Platform\Platform_Default.h" />
- <ClInclude Include="..\CommonSrc\Platform\Win32_Gamepad.h" />
- <ClInclude Include="..\CommonSrc\Platform\Win32_Platform.h" />
- <ClInclude Include="..\CommonSrc\Render\Render_Font.h" />
- <ClInclude Include="..\CommonSrc\Render\Render.h" />
- <ClInclude Include="..\CommonSrc\Render\Render_D3D10_Device.h" />
- <ClInclude Include="..\CommonSrc\Render\Render_D3D11_Device.h" />
- <ClInclude Include="..\CommonSrc\Render\Render_D3D1X_Device.h" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="SensorBoxTest.rc" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/Samples/SensorBox/SensorBoxTest_Msvc2010.vcxproj.filters b/Samples/SensorBox/SensorBoxTest_Msvc2010.vcxproj.filters
deleted file mode 100644
index 5c2ee68..0000000
--- a/Samples/SensorBox/SensorBoxTest_Msvc2010.vcxproj.filters
+++ /dev/null
@@ -1,73 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="CommonSrc">
- <UniqueIdentifier>{ba673e50-0655-4f12-a166-6d3ab6015925}</UniqueIdentifier>
- </Filter>
- <Filter Include="CommonSrc\Platform">
- <UniqueIdentifier>{16e20aab-eff7-45ff-be85-0203ad399e97}</UniqueIdentifier>
- </Filter>
- <Filter Include="CommonSrc\Render">
- <UniqueIdentifier>{1b6db3ae-a405-4f65-be93-41a62db4fa21}</UniqueIdentifier>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="..\CommonSrc\Platform\Platform.cpp">
- <Filter>CommonSrc\Platform</Filter>
- </ClCompile>
- <ClCompile Include="..\CommonSrc\Platform\Win32_Platform.cpp">
- <Filter>CommonSrc\Platform</Filter>
- </ClCompile>
- <ClCompile Include="..\CommonSrc\Render\Render_Device.cpp">
- <Filter>CommonSrc\Render</Filter>
- </ClCompile>
- <ClCompile Include="..\CommonSrc\Render\Render_D3D1X_Device.cpp">
- <Filter>CommonSrc\Render</Filter>
- </ClCompile>
- <ClCompile Include="..\CommonSrc\Render\Render_D3D10_Device.cpp">
- <Filter>CommonSrc\Render</Filter>
- </ClCompile>
- <ClCompile Include="..\CommonSrc\Render\Render_D3D11_Device.cpp">
- <Filter>CommonSrc\Render</Filter>
- </ClCompile>
- <ClCompile Include="SensorBoxTest.cpp" />
- <ClCompile Include="..\CommonSrc\Platform\Win32_Gamepad.cpp">
- <Filter>CommonSrc\Platform</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="..\CommonSrc\Platform\Win32_Platform.h">
- <Filter>CommonSrc\Platform</Filter>
- </ClInclude>
- <ClInclude Include="..\CommonSrc\Platform\Platform.h">
- <Filter>CommonSrc\Platform</Filter>
- </ClInclude>
- <ClInclude Include="..\CommonSrc\Platform\Platform_Default.h">
- <Filter>CommonSrc\Platform</Filter>
- </ClInclude>
- <ClInclude Include="..\CommonSrc\Render\Render_Font.h">
- <Filter>CommonSrc\Render</Filter>
- </ClInclude>
- <ClInclude Include="..\CommonSrc\Render\Render.h">
- <Filter>CommonSrc\Render</Filter>
- </ClInclude>
- <ClInclude Include="..\CommonSrc\Render\Render_D3D1X_Device.h">
- <Filter>CommonSrc\Render</Filter>
- </ClInclude>
- <ClInclude Include="..\CommonSrc\Render\Render_D3D10_Device.h">
- <Filter>CommonSrc\Render</Filter>
- </ClInclude>
- <ClInclude Include="..\CommonSrc\Render\Render_D3D11_Device.h">
- <Filter>CommonSrc\Render</Filter>
- </ClInclude>
- <ClInclude Include="..\CommonSrc\Platform\Gamepad.h">
- <Filter>CommonSrc\Platform</Filter>
- </ClInclude>
- <ClInclude Include="..\CommonSrc\Platform\Win32_Gamepad.h">
- <Filter>CommonSrc\Platform</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="SensorBoxTest.rc" />
- </ItemGroup>
-</Project> \ No newline at end of file