aboutsummaryrefslogtreecommitdiffstats
path: root/Samples/OculusRoomTiny
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/OculusRoomTiny
parent07d0f4d0bbf3477ac6a9584f726e8ec6ab285707 (diff)
Updating to 0.3.2 (windows version)
Diffstat (limited to 'Samples/OculusRoomTiny')
-rw-r--r--Samples/OculusRoomTiny/OculusRoomModel.cpp47
-rw-r--r--Samples/OculusRoomTiny/Projects/Win/VS2010/OculusRoomTiny.vcxproj2
-rw-r--r--Samples/OculusRoomTiny/Projects/Win/VS2012/OculusRoomTiny.vcxproj8
-rw-r--r--Samples/OculusRoomTiny/Projects/Win/VS2013/OculusRoomTiny.vcxproj8
-rw-r--r--Samples/OculusRoomTiny/RenderTiny_D3D11_Device.h2
-rw-r--r--Samples/OculusRoomTiny/Win32_DistortionMesh.cpp25
-rw-r--r--Samples/OculusRoomTiny/Win32_OculusRoomTiny.cpp79
7 files changed, 112 insertions, 59 deletions
diff --git a/Samples/OculusRoomTiny/OculusRoomModel.cpp b/Samples/OculusRoomTiny/OculusRoomModel.cpp
index f425be0..a7776a0 100644
--- a/Samples/OculusRoomTiny/OculusRoomModel.cpp
+++ b/Samples/OculusRoomTiny/OculusRoomModel.cpp
@@ -60,6 +60,7 @@ Slab FloorSlabs[] =
SlabModel Floor = {sizeof(FloorSlabs)/sizeof(Slab), FloorSlabs, Tex_Checker};
+
Slab CeilingSlabs[] =
{
{ -10.0f, 4.0f, -20.0f, 10.0f, 4.1f, 20.1f, Color(128,128,128) }
@@ -254,3 +255,49 @@ void PopulateRoomScene(Scene* scene, RenderDevice* render)
scene->AddLight(Vector3f(-4,3,25), Vector4f(3,6,3,1));
}
+
+// Render a debug marker static in rift (special request for eye-tracking)
+void renderSphere(RenderDevice* render, Vector3f ViewAdjust, float metresLeft, float metresUp, float metresAway, float metresRadius,
+ unsigned char red,unsigned char green,unsigned char blue)
+{
+ //Get textures, if haven't already
+ static FillCollection * pfills;
+ static bool firstTime = true;
+ if (firstTime)
+ {
+ firstTime=false;
+ pfills = new FillCollection(render);
+ }
+
+ //Create object
+ Scene* scene = new Scene;
+ Slab CubeSlabs[] =
+ {
+ #if 0 //Simple cube
+ { metresLeft-metresRadius, metresUp-metresRadius, metresAway-metresRadius,
+ metresLeft+metresRadius, metresUp+metresRadius, metresAway+metresRadius, Color(red,green,blue) }
+ #else //Blob
+ { metresLeft-0.33f*metresRadius, metresUp-metresRadius, metresAway-0.33f*metresRadius,
+ metresLeft+0.33f*metresRadius, metresUp+metresRadius, metresAway+0.33f*metresRadius, Color(red,green,blue) },
+ { metresLeft-metresRadius, metresUp-0.33f*metresRadius, metresAway-0.33f*metresRadius,
+ metresLeft+metresRadius, metresUp+0.33f*metresRadius, metresAway+0.33f*metresRadius, Color(red,green,blue) },
+ { metresLeft-0.33f*metresRadius, metresUp-0.33f*metresRadius, metresAway-metresRadius,
+ metresLeft+0.33f*metresRadius, metresUp+0.33f*metresRadius, metresAway+metresRadius, Color(red,green,blue) },
+ { metresLeft-0.71f*metresRadius, metresUp-0.71f*metresRadius, metresAway-0.71f*metresRadius,
+ metresLeft+0.71f*metresRadius, metresUp+0.71f*metresRadius, metresAway+0.71f*metresRadius, Color(red,green,blue) },
+
+ #endif
+
+ };
+ SlabModel Cube = {sizeof(CubeSlabs)/sizeof(Slab), CubeSlabs, Tex_None};
+ scene->World.Add(Ptr<Model>(*CreateModel(Vector3f(0,0,0), &Cube, *pfills)));
+ scene->SetAmbient(Vector4f(1.0f,1.0f,1.0f,1));
+
+ //Render object
+ Matrix4f view = Matrix4f::LookAtRH(Vector3f(0,0,0), Vector3f(0,0,0) + Vector3f(0,0,1), Vector3f(0,1,0));
+ scene->Render(render, Matrix4f::Translation(ViewAdjust) * view);
+
+ //Delete object
+ delete scene;
+}
+
diff --git a/Samples/OculusRoomTiny/Projects/Win/VS2010/OculusRoomTiny.vcxproj b/Samples/OculusRoomTiny/Projects/Win/VS2010/OculusRoomTiny.vcxproj
index d6bb3e7..846c501 100644
--- a/Samples/OculusRoomTiny/Projects/Win/VS2010/OculusRoomTiny.vcxproj
+++ b/Samples/OculusRoomTiny/Projects/Win/VS2010/OculusRoomTiny.vcxproj
@@ -19,7 +19,7 @@
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
- <ProjectGuid>{6C6ECAC4-DB5C-4301-8371-9C7CC8C623C2}</ProjectGuid>
+ <ProjectGuid>{80523489-2881-4F64-8C3B-FAF88B60ABCD}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>OculusRoomTiny</RootNamespace>
<ProjectName>OculusRoomTiny</ProjectName>
diff --git a/Samples/OculusRoomTiny/Projects/Win/VS2012/OculusRoomTiny.vcxproj b/Samples/OculusRoomTiny/Projects/Win/VS2012/OculusRoomTiny.vcxproj
index b547f70..12413ba 100644
--- a/Samples/OculusRoomTiny/Projects/Win/VS2012/OculusRoomTiny.vcxproj
+++ b/Samples/OculusRoomTiny/Projects/Win/VS2012/OculusRoomTiny.vcxproj
@@ -107,7 +107,7 @@
<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>
+ <AdditionalDependencies>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>
@@ -127,7 +127,7 @@
<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>
+ <AdditionalDependencies>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>
@@ -153,7 +153,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<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>
+ <AdditionalDependencies>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'">
@@ -178,7 +178,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<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>
+ <AdditionalDependencies>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>
diff --git a/Samples/OculusRoomTiny/Projects/Win/VS2013/OculusRoomTiny.vcxproj b/Samples/OculusRoomTiny/Projects/Win/VS2013/OculusRoomTiny.vcxproj
index e09a883..7fb717c 100644
--- a/Samples/OculusRoomTiny/Projects/Win/VS2013/OculusRoomTiny.vcxproj
+++ b/Samples/OculusRoomTiny/Projects/Win/VS2013/OculusRoomTiny.vcxproj
@@ -115,7 +115,7 @@
<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>
+ <AdditionalDependencies>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>
@@ -135,7 +135,7 @@
<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>
+ <AdditionalDependencies>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>
@@ -161,7 +161,7 @@
<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>
+ <AdditionalDependencies>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'">
@@ -186,7 +186,7 @@
<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>
+ <AdditionalDependencies>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>
diff --git a/Samples/OculusRoomTiny/RenderTiny_D3D11_Device.h b/Samples/OculusRoomTiny/RenderTiny_D3D11_Device.h
index f4ec71a..e16aa73 100644
--- a/Samples/OculusRoomTiny/RenderTiny_D3D11_Device.h
+++ b/Samples/OculusRoomTiny/RenderTiny_D3D11_Device.h
@@ -777,7 +777,7 @@ public:
virtual void SetRenderTarget(Texture* color,
Texture* depth = NULL,
Texture* stencil = NULL);
-
+ void SetDefaultRenderTarget() { SetRenderTarget(NULL, NULL); }
virtual void SetDepthMode(bool enable, bool write, CompareFunc func = Compare_Less);
virtual void SetProjection(const Matrix4f& proj);
virtual void SetWorldUniforms(const Matrix4f& proj);
diff --git a/Samples/OculusRoomTiny/Win32_DistortionMesh.cpp b/Samples/OculusRoomTiny/Win32_DistortionMesh.cpp
index 3356467..cacfc04 100644
--- a/Samples/OculusRoomTiny/Win32_DistortionMesh.cpp
+++ b/Samples/OculusRoomTiny/Win32_DistortionMesh.cpp
@@ -61,16 +61,22 @@ static D3D11_INPUT_ELEMENT_DESC DistortionMeshVertexDesc[] =
void DistortionMeshInit(unsigned distortionCaps, ovrHmd HMD,
- ovrEyeRenderDesc eyeRenderDesc[2], RenderDevice* pRender)
+ ovrEyeRenderDesc eyeRenderDesc[2],
+ ovrSizei textureSize, ovrRecti viewports[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);
+ ovrHmd_CreateDistortionMesh(HMD,
+ eyeRenderDesc[eyeNum].Eye, eyeRenderDesc[eyeNum].Fov,
+ distortionCaps, &meshData);
+
+ ovrHmd_GetRenderScaleAndOffset(eyeRenderDesc[eyeNum].Fov,
+ textureSize, viewports[eyeNum],
+ (ovrVector2f*) DistortionData.UVScaleOffset[eyeNum]);
// Now parse the vertex data and create a render ready vertex buffer from it
DistortionVertex * pVBVerts = (DistortionVertex*)OVR_ALLOC(
@@ -119,7 +125,7 @@ void DistortionMeshInit(unsigned distortionCaps, ovrHmd HMD,
// Choose the vertex shader, according to if you have timewarp enabled
- if (distortionCaps & ovrDistortion_TimeWarp)
+ if (distortionCaps & ovrDistortionCap_TimeWarp)
{ // TIMEWARP
//--------------------------------------------------------------------------------------------
const char* vertexShader =
@@ -188,14 +194,14 @@ void DistortionMeshRender(unsigned distortionCaps, ovrHmd HMD,
double timwarpTimePoint, ovrPosef eyeRenderPoses[2],
RenderDevice* pRender, Texture* pRendertargetTexture)
{
- if (distortionCaps & ovrDistortion_TimeWarp)
+ if (distortionCaps & ovrDistortionCap_TimeWarp)
{ // TIMEWARP
// Wait till time-warp to reduce latency.
ovr_WaitTillTime(timwarpTimePoint);
}
// Clear screen
- pRender->SetRenderTarget(NULL);
+ pRender->SetDefaultRenderTarget();
pRender->SetFullViewport();
pRender->Clear(0.0f, 0.0f, 0.0f, 0.0f);
@@ -212,10 +218,11 @@ void DistortionMeshRender(unsigned distortionCaps, ovrHmd HMD,
DistortionData.Shaders->SetUniform2f("EyeToSourceUVOffset",
DistortionData.UVScaleOffset[eyeNum][1].x, DistortionData.UVScaleOffset[eyeNum][1].y);
- if (distortionCaps & ovrDistortion_TimeWarp)
+ if (distortionCaps & ovrDistortionCap_TimeWarp)
{ // TIMEWARP - Additional shader constants required
ovrMatrix4f timeWarpMatrices[2];
ovrHmd_GetEyeTimewarpMatrices(HMD, (ovrEyeType)eyeNum, eyeRenderPoses[eyeNum], timeWarpMatrices);
+ //WARNING!!! These matrices are transposed in SetUniform4x4f, before being used by the shader.
DistortionData.Shaders->SetUniform4x4f("EyeRotationStart", Matrix4f(timeWarpMatrices[0]));
DistortionData.Shaders->SetUniform4x4f("EyeRotationEnd", Matrix4f(timeWarpMatrices[1]));
}
@@ -224,7 +231,7 @@ void DistortionMeshRender(unsigned distortionCaps, ovrHmd HMD,
DistortionData.MeshVBs[eyeNum], DistortionData.MeshIBs[eyeNum]);
}
- pRender->SetRenderTarget(NULL);
+ pRender->SetDefaultRenderTarget();
}
diff --git a/Samples/OculusRoomTiny/Win32_OculusRoomTiny.cpp b/Samples/OculusRoomTiny/Win32_OculusRoomTiny.cpp
index 5300537..8caf3d5 100644
--- a/Samples/OculusRoomTiny/Win32_OculusRoomTiny.cpp
+++ b/Samples/OculusRoomTiny/Win32_OculusRoomTiny.cpp
@@ -33,9 +33,9 @@ limitations under the License.
// ***** Choices and settings
// Whether the SDK performs rendering/distortion, or the app.
-//#define SDK_RENDER 1
-
-const unsigned DistortionCaps = ovrDistortion_Chromatic | ovrDistortion_TimeWarp;
+#define SDK_RENDER 1
+
+const unsigned DistortionCaps = ovrDistortionCap_Chromatic | ovrDistortionCap_TimeWarp;
const bool VSyncEnabled = true;
const bool FullScreen = true;
@@ -52,9 +52,10 @@ void PopulateRoomScene (Scene* scene, RenderDevice* rend
ovrHmd HMD;
ovrHmdDesc HMDDesc;
ovrEyeRenderDesc EyeRenderDesc[2];
-RenderDevice* pRender;
-Texture* pRendertargetTexture;
-Scene* pRoomScene;
+ovrRecti EyeRenderViewport[2];
+RenderDevice* pRender = 0;
+Texture* pRendertargetTexture = 0;
+Scene* pRoomScene = 0;
// Specifics for whether the SDK or the app is doing the distortion.
#if SDK_RENDER
@@ -63,7 +64,9 @@ Scene* pRoomScene;
ovrD3D11Texture EyeTexture[2];
#else
void DistortionMeshInit (unsigned distortionCaps, ovrHmd HMD,
- ovrEyeRenderDesc eyeRenderDesc[2], RenderDevice * pRender);
+ ovrEyeRenderDesc eyeRenderDesc[2],
+ ovrSizei textureSize, ovrRecti viewports[2],
+ RenderDevice * pRender);
void DistortionMeshRender(unsigned distortionCaps, ovrHmd HMD,
double timwarpTimePoint, ovrPosef eyeRenderPoses[2],
RenderDevice * pRender, Texture* pRendertargetTexture);
@@ -110,30 +113,25 @@ int Init()
// 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;
+ ovrFovPort eyeFov[2] = { HMDDesc.DefaultEyeFov[0], HMDDesc.DefaultEyeFov[1] } ;
+
+ EyeRenderViewport[0].Pos = Vector2i(0,0);
+ EyeRenderViewport[0].Size = Sizei(RenderTargetSize.w / 2, RenderTargetSize.h);
+ EyeRenderViewport[1].Pos = Vector2i((RenderTargetSize.w + 1) / 2, 0);
+ EyeRenderViewport[1].Size = EyeRenderViewport[0].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.Header.RenderViewport = EyeRenderViewport[0];
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;
+ EyeTexture[1].D3D11.Header.RenderViewport = EyeRenderViewport[1];
// Configure d3d11.
RenderDevice* render = (RenderDevice*)pRender;
@@ -147,22 +145,24 @@ int Init()
d3d11cfg.D3D11.pSwapChain = render->SwapChain;
if (!ovrHmd_ConfigureRendering(HMD, &d3d11cfg.Config,
- (VSyncEnabled ? 0 : ovrHmdCap_NoVSync), DistortionCaps,
- eyes, EyeRenderDesc)) return(1);
+ DistortionCaps,
+ eyeFov, EyeRenderDesc)) return(1);
#else // !SDK_RENDER
- EyeRenderDesc[0] = ovrHmd_GetRenderDesc(HMD, eyes[0]);
- EyeRenderDesc[1] = ovrHmd_GetRenderDesc(HMD, eyes[1]);
+ EyeRenderDesc[0] = ovrHmd_GetRenderDesc(HMD, ovrEye_Left, eyeFov[0]);
+ EyeRenderDesc[1] = ovrHmd_GetRenderDesc(HMD, ovrEye_Right, eyeFov[1]);
// Create our own distortion mesh and shaders
- DistortionMeshInit(DistortionCaps, HMD, EyeRenderDesc, pRender);
+ DistortionMeshInit(DistortionCaps, HMD, EyeRenderDesc,
+ RenderTargetSize, EyeRenderViewport, pRender);
#endif
+ ovrHmd_SetEnabledCaps(HMD, ovrHmdCap_LowPersistence |
+ ovrHmdCap_LatencyTest);
+
// 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);
+ ovrHmd_StartSensor(HMD, ovrSensorCap_Orientation |
+ ovrSensorCap_YawCorrection |
+ ovrSensorCap_Position, 0);
// This creates lights and models.
pRoomScene = new Scene;
@@ -185,12 +185,12 @@ void ProcessAndRender()
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];
+ Transformf movePose = ovrHmd_GetSensorState(HMD, frameTiming.ScanoutMidpointSeconds).Predicted.Pose;
+ static ovrPosef eyeRenderPose[2];
EyePos.y = ovrHmd_GetFloat(HMD, OVR_KEY_EYE_HEIGHT, EyePos.y);
bool freezeEyeRender = Util_RespondToControls(EyeYaw, EyePos,
- frameTiming.DeltaSeconds, movePose.Orientation);
+ frameTiming.DeltaSeconds, movePose.Rotation);
pRender->BeginScene();
@@ -220,12 +220,9 @@ void ProcessAndRender()
Matrix4f view = Matrix4f::LookAtRH(shiftedEyePos,
shiftedEyePos + finalForward, finalUp);
- Matrix4f proj = ovrMatrix4f_Projection(EyeRenderDesc[eye].Desc.Fov, 0.01f, 10000.0f, true);
+ Matrix4f proj = ovrMatrix4f_Projection(EyeRenderDesc[eye].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->SetViewport(Recti(EyeRenderViewport[eye]));
pRender->SetProjection(proj);
pRender->SetDepthMode(true, true);
pRoomScene->Render(pRender, Matrix4f::Translation(EyeRenderDesc[eye].ViewAdjust) * view);
@@ -274,8 +271,10 @@ ovrHmd_EndFrame(hmd);
//-------------------------------------------------------------------------------------
void Release(void)
{
- pRendertargetTexture->Release();
- pRendertargetTexture = 0;
+ if (pRendertargetTexture) {
+ pRendertargetTexture->Release();
+ pRendertargetTexture = 0;
+ }
ovrHmd_Destroy(HMD);
Util_ReleaseWindowAndGraphics(pRender);
pRender = 0;