aboutsummaryrefslogtreecommitdiffstats
path: root/Samples/OculusWorldDemo
diff options
context:
space:
mode:
authorBrad Davis <[email protected]>2014-05-23 01:49:32 -0700
committerBrad Davis <[email protected]>2014-05-23 01:49:32 -0700
commit46acc0e194ff3c1f120199eeca8324b4502118e9 (patch)
treeb1030198d3ee4698445d1fc5161cebe4158e45d1 /Samples/OculusWorldDemo
parent07d0f4d0bbf3477ac6a9584f726e8ec6ab285707 (diff)
Updating to 0.3.2 (windows version)
Diffstat (limited to 'Samples/OculusWorldDemo')
-rw-r--r--Samples/OculusWorldDemo/Assets/Tuscany/Tuscany.xml10
-rw-r--r--Samples/OculusWorldDemo/OculusWorldDemo.cpp178
-rw-r--r--Samples/OculusWorldDemo/OculusWorldDemo.h12
-rw-r--r--Samples/OculusWorldDemo/OculusWorldDemo_Scene.cpp2
-rw-r--r--Samples/OculusWorldDemo/OptionMenu.cpp896
-rw-r--r--Samples/OculusWorldDemo/OptionMenu.h442
-rw-r--r--Samples/OculusWorldDemo/Player.cpp12
-rw-r--r--Samples/OculusWorldDemo/Player.h4
-rw-r--r--Samples/OculusWorldDemo/Projects/Win/VS2010/OculusWorldDemo.vcxproj10
-rw-r--r--Samples/OculusWorldDemo/Projects/Win/VS2010/OculusWorldDemo.vcxproj.filters19
-rw-r--r--Samples/OculusWorldDemo/Projects/Win/VS2012/OculusWorldDemo.vcxproj7
-rw-r--r--Samples/OculusWorldDemo/Projects/Win/VS2012/OculusWorldDemo.vcxproj.filters18
-rw-r--r--Samples/OculusWorldDemo/Projects/Win/VS2013/OculusWorldDemo.vcxproj7
-rw-r--r--Samples/OculusWorldDemo/Projects/Win/VS2013/OculusWorldDemo.vcxproj.filters18
-rw-r--r--Samples/OculusWorldDemo/RenderProfiler.cpp99
-rw-r--r--Samples/OculusWorldDemo/RenderProfiler.h71
16 files changed, 174 insertions, 1631 deletions
diff --git a/Samples/OculusWorldDemo/Assets/Tuscany/Tuscany.xml b/Samples/OculusWorldDemo/Assets/Tuscany/Tuscany.xml
index f6be29b..3ce2edf 100644
--- a/Samples/OculusWorldDemo/Assets/Tuscany/Tuscany.xml
+++ b/Samples/OculusWorldDemo/Assets/Tuscany/Tuscany.xml
@@ -36,7 +36,7 @@
<texture fileName="tree_A02LightingMap.dds"/>
<texture fileName="tree_A03LightingMap.dds"/>
<texture fileName="Vase.dds"/>
- <texture fileName="vaseLightingMap.dds"/>
+ <texture fileName="VaseLightingMap.dds"/>
<texture fileName="Rocks.dds"/>
<texture fileName="Props_ExteriorLightingMap.dds"/>
<texture fileName="Bench.dds"/>
@@ -48,12 +48,12 @@
<texture fileName="Chair1.dds"/>
<texture fileName="Picture2.dds"/>
<texture fileName="Picture3.dds"/>
- <texture fileName="hutch.dds"/>
+ <texture fileName="Hutch.dds"/>
<texture fileName="Book.dds"/>
<texture fileName="Iron.dds"/>
<texture fileName="Table2.dds"/>
<texture fileName="Picture1.dds"/>
- <texture fileName="fireWood.dds"/>
+ <texture fileName="FireWood.dds"/>
<texture fileName="Floor.dds"/>
<texture fileName="House_InteriorLightingMap.dds"/>
<texture fileName="IntertiorFront.dds"/>
@@ -64,7 +64,7 @@
<texture fileName="ChimneyBrick.dds"/>
<texture fileName="Concrete1.dds"/>
<texture fileName="Concrete2.dds"/>
- <texture fileName="House_ExteriorLightingMap.dds"/>
+ <texture fileName="house_exteriorLightingMap.dds"/>
<texture fileName="HouseFront.dds"/>
<texture fileName="HouseLeft.dds"/>
<texture fileName="HouseRight.dds"/>
@@ -2291,4 +2291,4 @@
</groundCollisionModels>
<lights count="0">
</lights>
-</scene> \ No newline at end of file
+</scene>
diff --git a/Samples/OculusWorldDemo/OculusWorldDemo.cpp b/Samples/OculusWorldDemo/OculusWorldDemo.cpp
index e89403f..9c62d59 100644
--- a/Samples/OculusWorldDemo/OculusWorldDemo.cpp
+++ b/Samples/OculusWorldDemo/OculusWorldDemo.cpp
@@ -59,7 +59,7 @@ OculusWorldDemoApp::OculusWorldDemoApp()
CenterPupilDepthMeters(0.05f),
ForceZeroHeadMovement(false),
VsyncEnabled(true),
- MultisampleEnabled(true),
+ MultisampleEnabled(false),
IsLowPersistence(true),
DynamicPrediction(true),
PositionTrackingEnabled(true),
@@ -78,6 +78,8 @@ OculusWorldDemoApp::OculusWorldDemoApp()
FrameCounter = 0;
LastFpsUpdate = 0;
+ EyeRenderSize[0] = EyeRenderSize[1] = Sizei(0);
+
DistortionClearBlue = false;
}
@@ -138,7 +140,7 @@ int OculusWorldDemoApp::OnStartup(int argc, const char** argv)
FovSideTanLimit = FovPort::Max(HmdDesc.MaxEyeFov[0], HmdDesc.MaxEyeFov[1]).GetMaxSideTan();
FovSideTanMax = FovPort::Max(HmdDesc.DefaultEyeFov[0], HmdDesc.DefaultEyeFov[1]).GetMaxSideTan();
- PositionTrackingEnabled = (HmdDesc.Caps & ovrHmdCap_Position) ? true : false;
+ PositionTrackingEnabled = (HmdDesc.SensorCaps & ovrSensorCap_Position) ? true : false;
// *** Configure HMD Stereo settings.
@@ -189,7 +191,11 @@ bool OculusWorldDemoApp::SetupWindowAndRendering(int argc, const char** argv)
// *** Initialize Rendering
+#if defined(OVR_OS_WIN32)
const char* graphics = "d3d11";
+#else
+ const char* graphics = "GL";
+#endif
// Select renderer based on command line arguments.
for(int i = 1; i < argc; i++)
@@ -322,11 +328,11 @@ void OculusWorldDemoApp::PopulateOptionMenu()
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 (HmdDesc.SensorCaps & ovrSensorCap_Position)
{
- Menu.AddBool("Low Persistence 'P'", &IsLowPersistence).
+ Menu.AddBool("Low Persistence 'P'", &IsLowPersistence).
AddShortcutKey(Key_P).SetNotify(this, &OWD::HmdSettingChange);
- Menu.AddBool("Dynamic Prediction", &DynamicPrediction).
+ Menu.AddBool("Dynamic Prediction", &DynamicPrediction).
SetNotify(this, &OWD::HmdSettingChange);
Menu.AddBool("Positional Tracking 'X'", &PositionTrackingEnabled).
AddShortcutKey(Key_X).SetNotify(this, &OWD::HmdSettingChange);
@@ -338,16 +344,14 @@ 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];
+ ovrFovPort eyeFov[2];
+ eyeFov[0] = HmdDesc.DefaultEyeFov[0];
+ eyeFov[1] = 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));
+ eyeFov[0] = FovPort::Min(eyeFov[0], FovPort(FovSideTanMax));
+ eyeFov[1] = FovPort::Min(eyeFov[1], FovPort(FovSideTanMax));
if (ForceZeroIpd)
@@ -357,28 +361,30 @@ void OculusWorldDemoApp::CalculateHmdValues()
// 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;
+ eyeFov[0] = FovPort::Max(eyeFov[0], eyeFov[1]);
+ eyeFov[1] = eyeFov[0];
Sizei recommenedTexSize = ovrHmd_GetFovTextureSize(Hmd, ovrEye_Left,
- eyes[0].Fov, DesiredPixelDensity);
+ eyeFov[0], 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;
+ Sizei textureSize = EnsureRendertargetAtLeastThisBig(Rendertarget_Left, recommenedTexSize);
+
+ EyeRenderSize[0] = Sizei::Min(textureSize, recommenedTexSize);
+ EyeRenderSize[1] = EyeRenderSize[0];
// Store texture pointers that will be passed for rendering.
- EyeTexture[0] = RenderTargets[Rendertarget_Left].Tex;
- EyeTexture[1] = RenderTargets[Rendertarget_Left].Tex;
+ EyeTexture[0] = RenderTargets[Rendertarget_Left].Tex;
+ EyeTexture[0].Header.TextureSize = textureSize;
+ EyeTexture[0].Header.RenderViewport = Recti(EyeRenderSize[0]);
+ // Right eye is the same.
+ EyeTexture[1] = EyeTexture[0];
}
else
{
// 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);
+ Sizei recommenedTex0Size = ovrHmd_GetFovTextureSize(Hmd, ovrEye_Left, eyeFov[0], DesiredPixelDensity);
+ Sizei recommenedTex1Size = ovrHmd_GetFovTextureSize(Hmd, ovrEye_Right, eyeFov[1], DesiredPixelDensity);
if (RendertargetIsSharedByBothEyes)
{
@@ -390,46 +396,55 @@ void OculusWorldDemoApp::CalculateHmdValues()
// 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);
+ EyeRenderSize[0] = Sizei::Min(Sizei(rtSize.w/2, rtSize.h), recommenedTex0Size);
+ EyeRenderSize[1] = Sizei::Min(Sizei(rtSize.w/2, rtSize.h), recommenedTex1Size);
// 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;
+ EyeTexture[0] = RenderTargets[Rendertarget_BothEyes].Tex;
+ EyeTexture[0].Header.TextureSize = rtSize;
+ EyeTexture[0].Header.RenderViewport = Recti(Vector2i(0), EyeRenderSize[0]);
+ EyeTexture[1] = RenderTargets[Rendertarget_BothEyes].Tex;
+ EyeTexture[1].Header.TextureSize = rtSize;
+ EyeTexture[1].Header.RenderViewport = Recti(Vector2i((rtSize.w+1)/2, 0), EyeRenderSize[1]);
}
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;
+ Sizei tex0Size = EnsureRendertargetAtLeastThisBig(Rendertarget_Left, recommenedTex0Size);
+ Sizei tex1Size = EnsureRendertargetAtLeastThisBig(Rendertarget_Right, recommenedTex1Size);
+
+ EyeRenderSize[0] = Sizei::Min(tex0Size, recommenedTex0Size);
+ EyeRenderSize[1] = Sizei::Min(tex1Size, recommenedTex1Size);
+
+ // Store texture pointers and viewports that will be passed for rendering.
+ EyeTexture[0] = RenderTargets[Rendertarget_Left].Tex;
+ EyeTexture[0].Header.TextureSize = tex0Size;
+ EyeTexture[0].Header.RenderViewport = Recti(EyeRenderSize[0]);
+ EyeTexture[1] = RenderTargets[Rendertarget_Right].Tex;
+ EyeTexture[1].Header.TextureSize = tex1Size;
+ EyeTexture[1].Header.RenderViewport = Recti(EyeRenderSize[1]);
}
}
+ // Hmd caps.
+ unsigned hmdCaps = (VsyncEnabled ? 0 : ovrHmdCap_NoVSync) |
+ ovrHmdCap_LatencyTest;
+ if (IsLowPersistence)
+ hmdCaps |= ovrHmdCap_LowPersistence;
+ if (DynamicPrediction)
+ hmdCaps |= ovrHmdCap_DynamicPrediction;
- unsigned hmdCaps = ovrHmdCap_Orientation | (VsyncEnabled ? 0 : ovrHmdCap_NoVSync);
- unsigned distortionCaps = ovrDistortion_Chromatic;
+ ovrHmd_SetEnabledCaps(Hmd, hmdCaps);
- ovrRenderAPIConfig config = pRender->Get_ovrRenderAPIConfig();
+ ovrRenderAPIConfig config = pRender->Get_ovrRenderAPIConfig();
+ unsigned distortionCaps = ovrDistortionCap_Chromatic;
if (TimewarpEnabled)
- distortionCaps |= ovrDistortion_TimeWarp;
+ distortionCaps |= ovrDistortionCap_TimeWarp;
- if (!ovrHmd_ConfigureRendering( Hmd, &config, hmdCaps, distortionCaps,
- eyes, EyeRenderDesc ))
+ if (!ovrHmd_ConfigureRendering( Hmd, &config, distortionCaps,
+ eyeFov, EyeRenderDesc ))
{
// Fail exit? TBD
return;
@@ -443,14 +458,10 @@ void OculusWorldDemoApp::CalculateHmdValues()
}
// ovrHmdCap_LatencyTest - enables internal latency feedback
- unsigned sensorCaps = ovrHmdCap_Orientation|ovrHmdCap_YawCorrection|ovrHmdCap_LatencyTest;
+ unsigned sensorCaps = ovrSensorCap_Orientation|ovrSensorCap_YawCorrection;
if (PositionTrackingEnabled)
- sensorCaps |= ovrHmdCap_Position;
- if (IsLowPersistence)
- sensorCaps |= ovrHmdCap_LowPersistence;
- if (DynamicPrediction)
- sensorCaps |= ovrHmdCap_DynamicPrediction;
-
+ sensorCaps |= ovrSensorCap_Position;
+
if (StartSensorCaps != sensorCaps)
{
ovrHmd_StartSensor(Hmd, sensorCaps, 0);
@@ -458,8 +469,8 @@ void OculusWorldDemoApp::CalculateHmdValues()
}
// 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);
+ Projection[0] = ovrMatrix4f_Projection(EyeRenderDesc[0].Fov, 0.01f, 10000.0f, true);
+ Projection[1] = ovrMatrix4f_Projection(EyeRenderDesc[1].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);
@@ -530,7 +541,7 @@ Sizei OculusWorldDemoApp::EnsureRendertargetAtLeastThisBig(int rtNum, Sizei requ
void OculusWorldDemoApp::OnResize(int width, int height)
{
WindowSize = Sizei(width, height);
- // Re-calculate?
+ HmdSettingsChanged = true;
}
void OculusWorldDemoApp::OnMouseMove(int x, int y, int modifiers)
@@ -570,13 +581,9 @@ void OculusWorldDemoApp::OnKey(OVR::KeyCode key, int chr, bool down, int modifie
break;
case Key_F9:
-#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
// F11 is reserved on Mac, F10 doesn't work on Windows
@@ -652,13 +659,13 @@ void OculusWorldDemoApp::OnKey(OVR::KeyCode key, int chr, bool down, int modifie
//-----------------------------------------------------------------------------
-Matrix4f OculusWorldDemoApp::CalculateViewFromPose(const Posef& pose)
+Matrix4f OculusWorldDemoApp::CalculateViewFromPose(const Transformf& pose)
{
- Posef worldPose = ThePlayer.VirtualWorldPoseFromRealPose(pose);
+ Transformf worldPose = ThePlayer.VirtualWorldTransformfromRealPose(pose);
// Rotate and position View Camera
- Vector3f up = worldPose.Orientation.Rotate(UpVector);
- Vector3f forward = worldPose.Orientation.Rotate(ForwardVector);
+ Vector3f up = worldPose.Rotation.Rotate(UpVector);
+ Vector3f forward = worldPose.Rotation.Rotate(ForwardVector);
// 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.
@@ -667,7 +674,7 @@ Matrix4f OculusWorldDemoApp::CalculateViewFromPose(const Posef& pose)
// 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;
+ Vector3f viewPos = ForceZeroHeadMovement ? ThePlayer.BodyPos : worldPose.Translation;
Matrix4f view = Matrix4f::LookAtRH(viewPos, viewPos + forward, up);
return view;
@@ -726,14 +733,14 @@ void OculusWorldDemoApp::OnIdle()
// Update pose based on frame!
- ThePlayer.HeadPose = ss.Predicted.Transform;
+ ThePlayer.HeadPose = ss.Predicted.Pose;
// Movement/rotation with the gamepad.
ThePlayer.BodyYaw -= ThePlayer.GamepadRotate.x * dt;
ThePlayer.HandleMovement(dt, &CollisionModels, &GroundCollisionModels, ShiftDown);
// Record after processing time.
- Profiler.RecordSample(RenderProfiler::Sample_AfterGameProcessing);
+ Profiler.RecordSample(RenderProfiler::Sample_AfterGameProcessing);
// Determine if we are rendering this frame. Frame rendering may be
@@ -774,7 +781,7 @@ void OculusWorldDemoApp::OnIdle()
for (int eyeIndex = 0; eyeIndex < ovrEye_Count; eyeIndex++)
{
ovrEyeType eye = HmdDesc.EyeRenderOrder[eyeIndex];
- ovrPosef eyeRenderPose = ovrHmd_BeginEyeRender(Hmd, eye);
+ ovrPosef eyeRenderPose = ovrHmd_BeginEyeRender(Hmd, eye);
View = CalculateViewFromPose(eyeRenderPose);
RenderEyeView(eye);
@@ -800,9 +807,16 @@ void OculusWorldDemoApp::OnIdle()
}
}
- pRender->SetRenderTarget(0);
+ pRender->SetDefaultRenderTarget();
pRender->FinishScene();
}
+
+ /*
+ double t= ovr_GetTimeInSeconds();
+ while (ovr_GetTimeInSeconds() < (t + 0.017))
+ {
+
+ } */
Profiler.RecordSample(RenderProfiler::Sample_AfterEyeRender);
@@ -864,8 +878,8 @@ void OculusWorldDemoApp::ApplyDynamicResolutionScaling()
if (!DynamicRezScalingEnabled)
{
// 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;
+ EyeTexture[0].Header.RenderViewport.Size = EyeRenderSize[0];
+ EyeTexture[1].Header.RenderViewport.Size = EyeRenderSize[1];
return;
}
@@ -901,14 +915,14 @@ void OculusWorldDemoApp::ApplyDynamicResolutionScaling()
dynamicRezScale = dynamicRezScale * 0.5f + 0.5f;
}
- Sizei sizeLeft = EyeRenderDesc[0].Desc.RenderViewport.Size;
- Sizei sizeRight = EyeRenderDesc[1].Desc.RenderViewport.Size;
+ Sizei sizeLeft = EyeRenderSize[0];
+ Sizei sizeRight = EyeRenderSize[1];
// 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));
+ int(sizeLeft.h * dynamicRezScale));
EyeTexture[1].Header.RenderViewport.Size = Sizei(int(sizeRight.w * dynamicRezScale),
- int(sizeRight.h * dynamicRezScale));
+ int(sizeRight.h * dynamicRezScale));
}
@@ -1042,13 +1056,13 @@ void OculusWorldDemoApp::RenderTextInfoHud(float textHeight)
char buf[512], gpustat[256];
// Average FOVs.
- FovPort leftFov = EyeRenderDesc[0].Desc.Fov;
- FovPort rightFov = EyeRenderDesc[1].Desc.Fov;
+ FovPort leftFov = EyeRenderDesc[0].Fov;
+ FovPort rightFov = EyeRenderDesc[1].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);
+ EyeTexture[1].Header.RenderViewport.Size.w : 0);
int pixelSizeHeight = ( EyeTexture[0].Header.RenderViewport.Size.h +
EyeTexture[1].Header.RenderViewport.Size.h ) / 2;
@@ -1074,7 +1088,7 @@ void OculusWorldDemoApp::RenderTextInfoHud(float textHeight)
}
}
- ThePlayer.HeadPose.Orientation.GetEulerAngles<Axis_Y, Axis_X, Axis_Z>(&hmdYaw, &hmdPitch, &hmdRoll);
+ ThePlayer.HeadPose.Rotation.GetEulerAngles<Axis_Y, Axis_X, Axis_Z>(&hmdYaw, &hmdPitch, &hmdRoll);
OVR_sprintf(buf, sizeof(buf),
" HMD YPR:%4.0f %4.0f %4.0f Player Yaw: %4.0f\n"
" FPS: %.1f ms/frame: %.1f Frame: %d\n"
diff --git a/Samples/OculusWorldDemo/OculusWorldDemo.h b/Samples/OculusWorldDemo/OculusWorldDemo.h
index 54f0e9d..049ac94 100644
--- a/Samples/OculusWorldDemo/OculusWorldDemo.h
+++ b/Samples/OculusWorldDemo/OculusWorldDemo.h
@@ -31,6 +31,8 @@ limitations under the License.
#include "../CommonSrc/Render/Render_Device.h"
#include "../CommonSrc/Render/Render_XmlSceneLoader.h"
#include "../CommonSrc/Platform/Gamepad.h"
+#include "../CommonSrc/Util/OptionMenu.h"
+#include "../CommonSrc/Util/RenderProfiler.h"
#include "Util/Util_Render_Stereo.h"
using namespace OVR::Util::Render;
@@ -42,9 +44,6 @@ using namespace OVR::Util::Render;
#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"
@@ -133,7 +132,7 @@ public:
void RenderAnimatedBlocks(ovrEyeType eye, double appTime);
void RenderGrid(ovrEyeType eye);
- Matrix4f CalculateViewFromPose(const Posef& pose);
+ Matrix4f CalculateViewFromPose(const Transformf& pose);
// Determine whether this frame needs rendering based on timewarp timing and flags.
bool FrameNeedsRendering(double curtime);
@@ -191,9 +190,10 @@ protected:
ovrHmd Hmd;
ovrHmdDesc HmdDesc;
ovrEyeRenderDesc EyeRenderDesc[2];
- Matrix4f Projection[2]; // Projection matrix for eye.
- Matrix4f OrthoProjection[2]; // Projection for 2D.
+ Matrix4f Projection[2]; // Projection matrix for eye.
+ Matrix4f OrthoProjection[2]; // Projection for 2D.
ovrTexture EyeTexture[2];
+ Sizei EyeRenderSize[2]; // Saved render eye sizes; base for dynamic sizing.
// Sensor caps applied.
unsigned StartSensorCaps;
bool UsingDebugHmd;
diff --git a/Samples/OculusWorldDemo/OculusWorldDemo_Scene.cpp b/Samples/OculusWorldDemo/OculusWorldDemo_Scene.cpp
index 5dfe2d2..68cee1b 100644
--- a/Samples/OculusWorldDemo/OculusWorldDemo_Scene.cpp
+++ b/Samples/OculusWorldDemo/OculusWorldDemo_Scene.cpp
@@ -332,7 +332,7 @@ void OculusWorldDemoApp::RenderGrid(ovrEyeType eye)
case Grid_Lens:
{
lineStep = 48;
- Vector2f rendertargetNDC = FovPort(EyeRenderDesc[eye].Desc.Fov).TanAngleToRendertargetNDC(Vector2f(0.0f));
+ Vector2f rendertargetNDC = FovPort(EyeRenderDesc[eye].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 );
diff --git a/Samples/OculusWorldDemo/OptionMenu.cpp b/Samples/OculusWorldDemo/OptionMenu.cpp
deleted file mode 100644
index 283136d..0000000
--- a/Samples/OculusWorldDemo/OptionMenu.cpp
+++ /dev/null
@@ -1,896 +0,0 @@
-/************************************************************************************
-
-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
deleted file mode 100644
index ba90b08..0000000
--- a/Samples/OculusWorldDemo/OptionMenu.h
+++ /dev/null
@@ -1,442 +0,0 @@
-/************************************************************************************
-
-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 b2bf00e..c9f0997 100644
--- a/Samples/OculusWorldDemo/Player.cpp
+++ b/Samples/OculusWorldDemo/Player.cpp
@@ -39,21 +39,21 @@ Player::~Player()
Vector3f Player::GetPosition()
{
- return BodyPos + Quatf(Vector3f(0,1,0), BodyYaw.Get()).Rotate(HeadPose.Position);
+ return BodyPos + Quatf(Vector3f(0,1,0), BodyYaw.Get()).Rotate(HeadPose.Translation);
}
Quatf Player::GetOrientation(bool baseOnly)
{
Quatf baseQ = Quatf(Vector3f(0,1,0), BodyYaw.Get());
- return baseOnly ? baseQ : baseQ * HeadPose.Orientation;
+ return baseOnly ? baseQ : baseQ * HeadPose.Rotation;
}
-Posef Player::VirtualWorldPoseFromRealPose(const Posef &sensorHeadPose)
+Transformf Player::VirtualWorldTransformfromRealPose(const Transformf &sensorHeadPose)
{
Quatf baseQ = Quatf(Vector3f(0,1,0), BodyYaw.Get());
- return Posef(baseQ * sensorHeadPose.Orientation,
- BodyPos + baseQ.Rotate(sensorHeadPose.Position));
+ return Transformf(baseQ * sensorHeadPose.Rotation,
+ BodyPos + baseQ.Rotate(sensorHeadPose.Translation));
}
@@ -187,8 +187,8 @@ bool Player::HandleMoveKey(OVR::KeyCode key, bool down)
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;
+ default: return false;
}
- return false;
}
diff --git a/Samples/OculusWorldDemo/Player.h b/Samples/OculusWorldDemo/Player.h
index f8d29d5..7b45d7d 100644
--- a/Samples/OculusWorldDemo/Player.h
+++ b/Samples/OculusWorldDemo/Player.h
@@ -61,7 +61,7 @@ public:
Anglef BodyYaw;
// Where the player head is positioned and oriented in the real world
- Posef HeadPose;
+ Transformf HeadPose;
// Where the avatar head is positioned and oriented in the virtual world
Vector3f GetPosition();
@@ -69,7 +69,7 @@ public:
// Returns virtual world position based on a real world head pose.
// Allows predicting eyes separately based on scanout time.
- Posef VirtualWorldPoseFromRealPose(const Posef &sensorHeadPose);
+ Transformf VirtualWorldTransformfromRealPose(const Transformf &sensorHeadPose);
// Handle directional movement. Returns 'true' if movement was processed.
bool HandleMoveKey(OVR::KeyCode key, bool down);
diff --git a/Samples/OculusWorldDemo/Projects/Win/VS2010/OculusWorldDemo.vcxproj b/Samples/OculusWorldDemo/Projects/Win/VS2010/OculusWorldDemo.vcxproj
index 2167237..b113a51 100644
--- a/Samples/OculusWorldDemo/Projects/Win/VS2010/OculusWorldDemo.vcxproj
+++ b/Samples/OculusWorldDemo/Projects/Win/VS2010/OculusWorldDemo.vcxproj
@@ -19,7 +19,7 @@
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
- <ProjectGuid>{456DA1F5-7D65-4B77-8336-277F3921639B}</ProjectGuid>
+ <ProjectGuid>{8051B877-2992-4F64-8C3B-FAF88B6D83AA}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>OculusWorldDemo</RootNamespace>
<ProjectName>OculusWorldDemo</ProjectName>
@@ -192,11 +192,11 @@
</ClCompile>
<ClCompile Include="..\..\..\..\..\3rdParty\TinyXml\tinyxml2.cpp" />
<ClCompile Include="..\..\..\..\CommonSrc\Render\Render_XmlSceneLoader.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Util\OptionMenu.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Util\RenderProfiler.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" />
@@ -211,12 +211,12 @@
<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="..\..\..\..\CommonSrc\Util\OptionMenu.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Util\RenderProfiler.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" />
diff --git a/Samples/OculusWorldDemo/Projects/Win/VS2010/OculusWorldDemo.vcxproj.filters b/Samples/OculusWorldDemo/Projects/Win/VS2010/OculusWorldDemo.vcxproj.filters
index 67678ea..6e568ee 100644
--- a/Samples/OculusWorldDemo/Projects/Win/VS2010/OculusWorldDemo.vcxproj.filters
+++ b/Samples/OculusWorldDemo/Projects/Win/VS2010/OculusWorldDemo.vcxproj.filters
@@ -10,6 +10,9 @@
<Filter Include="CommonSrc\Render">
<UniqueIdentifier>{1b6d51ae-a405-4f3d-be93-41a50db4f328}</UniqueIdentifier>
</Filter>
+ <Filter Include="CommonSrc\Util">
+ <UniqueIdentifier>{604daee3-bd81-41a5-ac3f-181bbbe9416a}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\..\CommonSrc\Platform\Platform.cpp">
@@ -45,8 +48,6 @@
<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>
@@ -54,6 +55,12 @@
<ClCompile Include="..\..\..\..\CommonSrc\Render\Render_GL_Win32_Device.cpp">
<Filter>CommonSrc\Render</Filter>
</ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Util\OptionMenu.cpp">
+ <Filter>CommonSrc\Util</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Util\RenderProfiler.cpp">
+ <Filter>CommonSrc\Util</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\..\CommonSrc\Platform\Win32_Platform.h">
@@ -91,15 +98,19 @@
<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>
+ <ClInclude Include="..\..\..\..\CommonSrc\Util\OptionMenu.h">
+ <Filter>CommonSrc\Util</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Util\RenderProfiler.h">
+ <Filter>CommonSrc\Util</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\..\OculusWorldDemo.rc" />
diff --git a/Samples/OculusWorldDemo/Projects/Win/VS2012/OculusWorldDemo.vcxproj b/Samples/OculusWorldDemo/Projects/Win/VS2012/OculusWorldDemo.vcxproj
index 1dae2b3..4748329 100644
--- a/Samples/OculusWorldDemo/Projects/Win/VS2012/OculusWorldDemo.vcxproj
+++ b/Samples/OculusWorldDemo/Projects/Win/VS2012/OculusWorldDemo.vcxproj
@@ -198,11 +198,11 @@
</ClCompile>
<ClCompile Include="..\..\..\..\..\3rdParty\TinyXml\tinyxml2.cpp" />
<ClCompile Include="..\..\..\..\CommonSrc\Render\Render_XmlSceneLoader.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Util\OptionMenu.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Util\RenderProfiler.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" />
@@ -217,11 +217,12 @@
<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="..\..\..\..\CommonSrc\Util\OptionMenu.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Util\RenderProfiler.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" />
diff --git a/Samples/OculusWorldDemo/Projects/Win/VS2012/OculusWorldDemo.vcxproj.filters b/Samples/OculusWorldDemo/Projects/Win/VS2012/OculusWorldDemo.vcxproj.filters
index 7246205..29b9844 100644
--- a/Samples/OculusWorldDemo/Projects/Win/VS2012/OculusWorldDemo.vcxproj.filters
+++ b/Samples/OculusWorldDemo/Projects/Win/VS2012/OculusWorldDemo.vcxproj.filters
@@ -10,6 +10,9 @@
<Filter Include="CommonSrc\Render">
<UniqueIdentifier>{1b6d51ae-a405-4f3d-be93-41a50db4f328}</UniqueIdentifier>
</Filter>
+ <Filter Include="CommonSrc\Util">
+ <UniqueIdentifier>{57bdf278-35e5-4f2f-ad41-dc9614a112fa}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\..\CommonSrc\Platform\Platform.cpp">
@@ -45,8 +48,6 @@
<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>
@@ -54,6 +55,12 @@
<ClCompile Include="..\..\..\..\CommonSrc\Render\Render_GL_Device.cpp">
<Filter>CommonSrc\Render</Filter>
</ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Util\OptionMenu.cpp">
+ <Filter>CommonSrc\Util</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Util\RenderProfiler.cpp">
+ <Filter>CommonSrc\Util</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\..\CommonSrc\Platform\Win32_Platform.h">
@@ -91,7 +98,6 @@
<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>
@@ -99,6 +105,12 @@
<ClInclude Include="..\..\..\..\CommonSrc\Render\Render_GL_Win32_Device.h">
<Filter>CommonSrc\Render</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Util\OptionMenu.h">
+ <Filter>CommonSrc\Util</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Util\RenderProfiler.h">
+ <Filter>CommonSrc\Util</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\..\OculusWorldDemo.rc" />
diff --git a/Samples/OculusWorldDemo/Projects/Win/VS2013/OculusWorldDemo.vcxproj b/Samples/OculusWorldDemo/Projects/Win/VS2013/OculusWorldDemo.vcxproj
index b894075..660cb60 100644
--- a/Samples/OculusWorldDemo/Projects/Win/VS2013/OculusWorldDemo.vcxproj
+++ b/Samples/OculusWorldDemo/Projects/Win/VS2013/OculusWorldDemo.vcxproj
@@ -198,11 +198,11 @@
</ClCompile>
<ClCompile Include="..\..\..\..\..\3rdParty\TinyXml\tinyxml2.cpp" />
<ClCompile Include="..\..\..\..\CommonSrc\Render\Render_XmlSceneLoader.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Util\OptionMenu.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Util\RenderProfiler.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" />
@@ -217,11 +217,12 @@
<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="..\..\..\..\CommonSrc\Util\OptionMenu.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Util\RenderProfiler.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" />
diff --git a/Samples/OculusWorldDemo/Projects/Win/VS2013/OculusWorldDemo.vcxproj.filters b/Samples/OculusWorldDemo/Projects/Win/VS2013/OculusWorldDemo.vcxproj.filters
index 93fff72..bd553f1 100644
--- a/Samples/OculusWorldDemo/Projects/Win/VS2013/OculusWorldDemo.vcxproj.filters
+++ b/Samples/OculusWorldDemo/Projects/Win/VS2013/OculusWorldDemo.vcxproj.filters
@@ -10,6 +10,9 @@
<Filter Include="CommonSrc\Render">
<UniqueIdentifier>{1b6d51ae-a405-4f3d-be93-41a50db4f328}</UniqueIdentifier>
</Filter>
+ <Filter Include="CommonSrc\Util">
+ <UniqueIdentifier>{7fda3cf5-3371-45bc-b3b6-3b0424b46d93}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\..\CommonSrc\Platform\Platform.cpp">
@@ -45,8 +48,6 @@
<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>
@@ -54,6 +55,12 @@
<ClCompile Include="..\..\..\..\CommonSrc\Render\Render_GL_Device.cpp">
<Filter>CommonSrc\Render</Filter>
</ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Util\OptionMenu.cpp">
+ <Filter>CommonSrc\Util</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Util\RenderProfiler.cpp">
+ <Filter>CommonSrc\Util</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\..\CommonSrc\Platform\Win32_Platform.h">
@@ -91,7 +98,6 @@
<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>
@@ -99,6 +105,12 @@
<ClInclude Include="..\..\..\..\CommonSrc\Render\Render_GL_Device.h">
<Filter>CommonSrc\Render</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Util\RenderProfiler.h">
+ <Filter>CommonSrc\Util</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Util\OptionMenu.h">
+ <Filter>CommonSrc\Util</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\..\OculusWorldDemo.rc" />
diff --git a/Samples/OculusWorldDemo/RenderProfiler.cpp b/Samples/OculusWorldDemo/RenderProfiler.cpp
deleted file mode 100644
index 00bbdd9..0000000
--- a/Samples/OculusWorldDemo/RenderProfiler.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/************************************************************************************
-
-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
deleted file mode 100644
index 96ec50a..0000000
--- a/Samples/OculusWorldDemo/RenderProfiler.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/************************************************************************************
-
-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