aboutsummaryrefslogtreecommitdiffstats
path: root/Samples
diff options
context:
space:
mode:
Diffstat (limited to 'Samples')
-rw-r--r--Samples/CommonSrc/Render/Render_D3D1X_Device.cpp98
-rw-r--r--Samples/CommonSrc/Render/Render_D3D1X_Device.h1
-rw-r--r--Samples/CommonSrc/Render/Render_Device.h1
-rw-r--r--Samples/CommonSrc/Render/Render_GL_Device.cpp193
-rw-r--r--Samples/CommonSrc/Render/Render_GL_Device.h48
-rw-r--r--Samples/CommonSrc/Render/Render_GL_Win32_Device.cpp2
-rw-r--r--Samples/CommonSrc/Render/Render_LoadTextureDDS.cpp4
-rw-r--r--Samples/CommonSrc/Render/Render_XmlSceneLoader.cpp4
-rw-r--r--Samples/CommonSrc/Render/Render_XmlSceneLoader.h4
-rw-r--r--Samples/LibOVR_With_Samples_VS2013.sln3
-rw-r--r--Samples/OculusRoomTiny/Projects/Win/VS2010/OculusRoomTiny.vcxproj2
-rw-r--r--Samples/OculusRoomTiny/Projects/Win/VS2010/OculusRoomTiny.vcxproj.filters9
-rw-r--r--Samples/OculusRoomTiny/Projects/Win/VS2012/OculusRoomTiny.vcxproj2
-rw-r--r--Samples/OculusRoomTiny/Projects/Win/VS2012/OculusRoomTiny.vcxproj.filters9
-rw-r--r--Samples/OculusRoomTiny/Projects/Win/VS2013/OculusRoomTiny.vcxproj2
-rw-r--r--Samples/OculusRoomTiny/Projects/Win/VS2013/OculusRoomTiny.vcxproj.filters9
-rw-r--r--Samples/OculusRoomTiny/Win32_OculusRoomTiny.cpp18
-rw-r--r--Samples/OculusRoomTiny/Win32_OculusRoomTiny_Util.cpp207
-rw-r--r--Samples/OculusWorldDemo/OculusWorldDemo.cpp76
-rw-r--r--Samples/OculusWorldDemo/OculusWorldDemo.h10
-rw-r--r--Samples/OculusWorldDemo/Projects/Win/VS2010/OculusWorldDemo.vcxproj1
-rw-r--r--Samples/OculusWorldDemo/Projects/Win/VS2010/OculusWorldDemo.vcxproj.filters1
-rw-r--r--Samples/OculusWorldDemo/Projects/Win/VS2012/OculusWorldDemo.vcxproj1
-rw-r--r--Samples/OculusWorldDemo/Projects/Win/VS2012/OculusWorldDemo.vcxproj.filters1
-rw-r--r--Samples/OculusWorldDemo/Projects/Win/VS2013/OculusWorldDemo.vcxproj1
-rw-r--r--Samples/OculusWorldDemo/Projects/Win/VS2013/OculusWorldDemo.vcxproj.filters1
26 files changed, 479 insertions, 229 deletions
diff --git a/Samples/CommonSrc/Render/Render_D3D1X_Device.cpp b/Samples/CommonSrc/Render/Render_D3D1X_Device.cpp
index 3f645ab..a904ee5 100644
--- a/Samples/CommonSrc/Render/Render_D3D1X_Device.cpp
+++ b/Samples/CommonSrc/Render/Render_D3D1X_Device.cpp
@@ -152,17 +152,12 @@ static const char* MultiTexturePixelShaderSrc =
"float4 color1;\n"
"float4 color2;\n"
" color1 = Texture[0].Sample(Linear, ov.TexCoord);\n"
- // go to linear space colors (assume gamma 2.0 for speed)
- " color1.rgb *= color1.rgb;\n"
" color2 = Texture[1].Sample(Linear, ov.TexCoord1);\n"
- // go to linear space colors (assume gamma 2.0 for speed)
- " color2.rgb *= color2.rgb;\n"
- " color2.rgb = color2.rgb * lerp(1.2, 1.9, saturate(length(color2.rgb)));\n"
+ " color2.rgb = color2.rgb * lerp(1.9, 1.2, saturate(length(color2.rgb)));\n"
" color2 = color1 * color2;\n"
" if (color2.a <= 0.4)\n"
" discard;\n"
- // go to back to gamma space space colors (assume gamma 2.0 for speed)
- " return float4(sqrt(color2.rgb) / color2.a, 1);\n"
+ " return float4(color2.rgb / color2.a, 1);\n"
"}\n";
#define LIGHTING_COMMON \
@@ -668,31 +663,37 @@ static const char* PostProcessHeightmapTimewarpPixelShaderSrc =
//----------------------------------------------------------------------------
-static const char* VShaderSrcs[VShader_Count] =
+struct ShaderSource
{
- DirectVertexShaderSrc,
- StdVertexShaderSrc,
- PostProcessVertexShaderSrc,
- PostProcessMeshVertexShaderSrc,
- PostProcessMeshTimewarpVertexShaderSrc,
- PostProcessMeshPositionalTimewarpVertexShaderSrc,
- PostProcessHeightmapTimewarpVertexShaderSrc
+ const char* ShaderModel;
+ const char* SourceStr;
};
-static const char* FShaderSrcs[FShader_Count] =
-{
- SolidPixelShaderSrc,
- GouraudPixelShaderSrc,
- TexturePixelShaderSrc,
- AlphaTexturePixelShaderSrc,
- AlphaBlendedTexturePixelShaderSrc,
- PostProcessPixelShaderWithChromAbSrc,
- LitSolidPixelShaderSrc,
- LitTexturePixelShaderSrc,
- MultiTexturePixelShaderSrc,
- PostProcessMeshPixelShaderSrc,
- PostProcessMeshTimewarpPixelShaderSrc,
- PostProcessMeshPositionalTimewarpPixelShaderSrc,
- PostProcessHeightmapTimewarpPixelShaderSrc
+
+static ShaderSource VShaderSrcs[VShader_Count] =
+{
+ {"vs_4_0", DirectVertexShaderSrc},
+ {"vs_4_0", StdVertexShaderSrc},
+ {"vs_4_0", PostProcessVertexShaderSrc},
+ {"vs_4_0", PostProcessMeshVertexShaderSrc},
+ {"vs_4_0", PostProcessMeshTimewarpVertexShaderSrc},
+ {"vs_4_1", PostProcessMeshPositionalTimewarpVertexShaderSrc},
+ {"vs_4_1", PostProcessHeightmapTimewarpVertexShaderSrc},
+};
+static ShaderSource FShaderSrcs[FShader_Count] =
+{
+ {"ps_4_0", SolidPixelShaderSrc},
+ {"ps_4_0", GouraudPixelShaderSrc},
+ {"ps_4_0", TexturePixelShaderSrc},
+ {"ps_4_0", AlphaTexturePixelShaderSrc},
+ {"ps_4_0", AlphaBlendedTexturePixelShaderSrc},
+ {"ps_4_0", PostProcessPixelShaderWithChromAbSrc},
+ {"ps_4_0", LitSolidPixelShaderSrc},
+ {"ps_4_0", LitTexturePixelShaderSrc},
+ {"ps_4_0", MultiTexturePixelShaderSrc},
+ {"ps_4_0", PostProcessMeshPixelShaderSrc},
+ {"ps_4_0", PostProcessMeshTimewarpPixelShaderSrc},
+ {"ps_4_0", PostProcessMeshPositionalTimewarpPixelShaderSrc},
+ {"ps_4_0", PostProcessHeightmapTimewarpPixelShaderSrc},
};
#ifdef OVR_BUILD_DEBUG
@@ -706,7 +707,7 @@ static void ReportCOMError(HRESULT hr, const char* file, int line)
if (sizeof(TCHAR) == sizeof(char))
{
- LogError("[D3D] Error in %s on line %d : %s", file, line, errMsg);
+ LogError("{ERR-017w} [D3D] Error in %s on line %d : %s", file, line, errMsg);
}
else
{
@@ -719,7 +720,7 @@ static void ReportCOMError(HRESULT hr, const char* file, int line)
len = count;
}
data[len] = '\0';
- LogError("[D3D] Error in %s on line %d : %s", file, line, data);
+ LogError("{ERR-018w} [D3D] Error in %s on line %d : %s", file, line, data);
delete[] data;
}
@@ -825,7 +826,7 @@ RenderDevice::RenderDevice(const RendererParams& p, HWND window)
if (FAILED(hr))
{
OVR_LOG_COM_ERROR(hr);
- LogError("[D3D1X] Unable to create device: %x", hr);
+ LogError("{ERR-019w} [D3D1X] Unable to create device: %x", hr);
OVR_ASSERT(false);
return;
}
@@ -843,12 +844,14 @@ RenderDevice::RenderDevice(const RendererParams& p, HWND window)
MaxTextureSet[i] = 0;
}
- ID3D10Blob* vsData = CompileShader("vs_4_1", DirectVertexShaderSrc);
+ ID3D10Blob* vsData = CompileShader(VShaderSrcs[0].ShaderModel, VShaderSrcs[0].SourceStr);
+
VertexShaders[VShader_MV] = *new VertexShader(this, vsData);
for(int i = 1; i < VShader_Count; i++)
{
- OVR_ASSERT ( VShaderSrcs[i] != NULL ); // You forgot a shader!
- ID3D10Blob *pShader = CompileShader("vs_4_1", VShaderSrcs[i]);
+ OVR_ASSERT ( VShaderSrcs[i].SourceStr != NULL ); // You forgot a shader!
+ ID3D10Blob *pShader = CompileShader(VShaderSrcs[i].ShaderModel, VShaderSrcs[i].SourceStr);
+
VertexShaders[i] = NULL;
if ( pShader != NULL )
{
@@ -858,8 +861,9 @@ RenderDevice::RenderDevice(const RendererParams& p, HWND window)
for(int i = 0; i < FShader_Count; i++)
{
- OVR_ASSERT ( FShaderSrcs[i] != NULL ); // You forgot a shader!
- ID3D10Blob *pShader = CompileShader("ps_4_1", FShaderSrcs[i]);
+ OVR_ASSERT ( FShaderSrcs[i].SourceStr != NULL ); // You forgot a shader!
+ ID3D10Blob *pShader = CompileShader(FShaderSrcs[i].ShaderModel, FShaderSrcs[i].SourceStr);
+
PixelShaders[i] = NULL;
if ( pShader != NULL )
{
@@ -2083,20 +2087,12 @@ Texture* RenderDevice::CreateTexture(int format, int width, int height, const vo
unsigned effectiveMipCount = mipcount;
unsigned textureSize = 0;
-#ifdef OVR_DEFINE_NEW
-#undef new
-#endif
-
D3D1x_(SUBRESOURCE_DATA)* subresData = (D3D1x_(SUBRESOURCE_DATA)*)
OVR_ALLOC(sizeof(D3D1x_(SUBRESOURCE_DATA)) * mipcount);
GenerateSubresourceData(width, height, convertedFormat, imageDimUpperLimit, data, subresData, largestMipWidth,
largestMipHeight, textureSize, effectiveMipCount);
TotalTextureMemoryUsage += textureSize;
-#ifdef OVR_DEFINE_NEW
-#define new OVR_DEFINE_NEW
-#endif
-
if (!Device || !subresData)
{
return NULL;
@@ -2520,6 +2516,9 @@ size_t RenderDevice::QueryGPUMemorySize()
{
OVR_LOG_COM_ERROR(hr);
}
+
+ pDXGIAdapter->Release();
+ pDXGIDevice->Release();
return adapterDesc.DedicatedVideoMemory;
}
@@ -2550,9 +2549,14 @@ void RenderDevice::Present ( bool withVsync )
}
}
+void RenderDevice::Flush()
+{
+ Context->Flush();
+}
+
void RenderDevice::WaitUntilGpuIdle()
{
-#if 1
+#if 0
// If enabling this option and using an NVIDIA GPU,
// then make sure your "max pre-rendered frames" is set to 1 under the NVIDIA GPU settings.
diff --git a/Samples/CommonSrc/Render/Render_D3D1X_Device.h b/Samples/CommonSrc/Render/Render_D3D1X_Device.h
index 4207d8a..cac104e 100644
--- a/Samples/CommonSrc/Render/Render_D3D1X_Device.h
+++ b/Samples/CommonSrc/Render/Render_D3D1X_Device.h
@@ -313,6 +313,7 @@ public:
virtual void Present ( bool withVsync );
virtual void WaitUntilGpuIdle();
+ virtual void Flush();
virtual bool SetFullscreen(DisplayMode fullscreen);
virtual size_t QueryGPUMemorySize();
diff --git a/Samples/CommonSrc/Render/Render_Device.h b/Samples/CommonSrc/Render/Render_Device.h
index d7e4917..1da49fe 100644
--- a/Samples/CommonSrc/Render/Render_Device.h
+++ b/Samples/CommonSrc/Render/Render_Device.h
@@ -877,6 +877,7 @@ public:
virtual void Present ( bool withVsync ) = 0;
// Waits for rendering to complete; important for reducing latency.
virtual void WaitUntilGpuIdle() { }
+ virtual void Flush() = 0;
// Resources
virtual Buffer* CreateBuffer() { return NULL; }
diff --git a/Samples/CommonSrc/Render/Render_GL_Device.cpp b/Samples/CommonSrc/Render/Render_GL_Device.cpp
index f6e13ef..54a2b9b 100644
--- a/Samples/CommonSrc/Render/Render_GL_Device.cpp
+++ b/Samples/CommonSrc/Render/Render_GL_Device.cpp
@@ -26,7 +26,8 @@ limitations under the License.
#include "OVR_CAPI_GL.h"
namespace OVR { namespace Render { namespace GL {
-
+
+
#if !defined(OVR_OS_MAC)
// GL Hooks for PC.
@@ -716,47 +717,10 @@ static const char* FShaderSrcs[FShader_Count] =
RenderDevice::RenderDevice(const RendererParams&)
{
- int GlMajorVersion = 0;
- int GlMinorVersion = 0;
- bool isES = false;
-
- const char* glVersionString = (const char*)glGetString(GL_VERSION);
+ GetGLVersionAndExtensions(GLVersionInfo);
-#ifdef OVR_CC_MSVC
- // Hack: This is using sscanf_s on MSVC to kill the security warning.
- // Normally the two functions are not interchangeable because the string format
- // is different for %s types, however we only use %d so it's fine.
-#define _OVR_SSCANF sscanf_s
-#else
-#define _OVR_SSCANF sscanf
-#endif
+ OVR_ASSERT(GLVersionInfo.MajorVersion >= 2);
- isES = strstr( glVersionString, "OpenGL ES-CM" ) != NULL;
- if( isES )
- {
- _OVR_SSCANF(glVersionString, "OpenGL ES-CM %d.%d", &GlMajorVersion, &GlMinorVersion);
- }
- else
- {
- isES = strstr( glVersionString, "OpenGL ES " ) != NULL;
- if ( isES )
- {
- _OVR_SSCANF(glVersionString, "OpenGL ES %d.%d", &GlMajorVersion, &GlMinorVersion);
- }
- else
- {
- _OVR_SSCANF(glVersionString, "%d.%d", &GlMajorVersion, &GlMinorVersion);
- }
- }
-
-#undef _OVR_SSCANF
-
- OVR_ASSERT( isES == false );
- OVR_ASSERT(GlMajorVersion >= 2);
-
- const char* extensions = (const char*)glGetString(GL_EXTENSIONS);
- SupportsVao = (GlMajorVersion >= 3) || (strstr("GL_ARB_vertex_array_object", extensions) != NULL);
-
for (int i = 0; i < VShader_Count; i++)
{
OVR_ASSERT ( VShaderSrcs[i] != NULL ); // You forgot a shader!
@@ -776,8 +740,10 @@ RenderDevice::RenderDevice(const RendererParams&)
glGenFramebuffers(1, &CurrentFbo);
- if (SupportsVao)
+ if (GLVersionInfo.SupportsVAO)
+ {
glGenVertexArrays(1, &Vao);
+ }
}
RenderDevice::~RenderDevice()
@@ -794,14 +760,20 @@ void RenderDevice::Shutdown()
glDeleteFramebuffers(1, &CurrentFbo);
- if (SupportsVao)
+ if (GLVersionInfo.SupportsVAO)
+ {
glDeleteVertexArrays(1, &Vao);
+ }
for (int i = 0; i < VShader_Count; ++i)
+ {
VertexShaders[i].Clear();
+ }
for (int i = 0; i < FShader_Count; ++i)
+ {
FragShaders[i].Clear();
+ }
DefaultFill.Clear();
DepthBuffers.Clear();
@@ -865,6 +837,11 @@ void RenderDevice::SetViewport(const Recti& vp)
glViewport(vp.x, wh - vp.y - vp.h, vp.w, vp.h);
}
+void RenderDevice::Flush()
+{
+ glFlush();
+}
+
void RenderDevice::WaitUntilGpuIdle()
{
glFlush();
@@ -943,8 +920,10 @@ Fill* RenderDevice::CreateSimpleFill(int flags)
void RenderDevice::Render(const Matrix4f& matrix, Model* model)
{
- if (SupportsVao)
+ if (GLVersionInfo.SupportsVAO)
+ {
glBindVertexArray(Vao);
+ }
// Store data in buffers if not already
if (!model->VertexBuffer)
@@ -953,6 +932,7 @@ void RenderDevice::Render(const Matrix4f& matrix, Model* model)
vb->Data(Buffer_Vertex | Buffer_ReadOnly, &model->Vertices[0], model->Vertices.GetSize() * sizeof(Vertex));
model->VertexBuffer = vb;
}
+
if (!model->IndexBuffer)
{
Ptr<Render::Buffer> ib = *CreateBuffer();
@@ -1454,4 +1434,129 @@ RBuffer::~RBuffer()
glDeleteRenderbuffers(1, &BufId);
}
-}}}
+
+//// GLVersion
+
+static void ParseGLVersion(GLVersionAndExtensions& versionInfo)
+{
+ const char* version = (const char*)glGetString(GL_VERSION);
+ int fields = 0, major = 0, minor = 0;
+ bool isGLES = false;
+
+ OVR_ASSERT(version);
+ if (version)
+ {
+ OVR_DEBUG_LOG(("GL_VERSION: %s", (const char*)version));
+
+#ifdef OVR_CC_MSVC
+ // Hack: This is using sscanf_s on MSVC to kill the security warning.
+ // Normally the two functions are not interchangeable because the string format
+ // is different for %s types, however we only use %d so it's fine.
+#define TEMP_OVR_SSCANF sscanf_s
+#else
+#define TEMP_OVR_SSCANF sscanf
+#endif
+
+ // Skip all leading non-digits before reading %d.
+ // Example GL_VERSION strings:
+ // "1.5 ATI-1.4.18"
+ // "OpenGL ES-CM 3.2"
+ fields = TEMP_OVR_SSCANF(version, isdigit(*version) ? "%d.%d" : "%*[^0-9]%d.%d", &major, &minor);
+ isGLES = (strstr(version, "OpenGL ES") != NULL);
+
+#undef TEMP_OVR_SSCANF
+ }
+ else
+ {
+ LogText("Warning: GL_VERSION was NULL\n");
+ }
+
+ // If two fields were not found,
+ if (fields != 2)
+ {
+ static_assert(sizeof(major) == sizeof(GLint), "type mis-match");
+
+ glGetIntegerv(GL_MAJOR_VERSION, &major);
+ glGetIntegerv(GL_MINOR_VERSION, &minor);
+ }
+
+ // Write version data
+ versionInfo.MajorVersion = major;
+ versionInfo.MinorVersion = minor;
+ versionInfo.IsGLES = isGLES;
+}
+
+static bool HasGLExtension(const char* extensions, const char* searchKey)
+{
+ const int searchKeyLen = (int)strlen(searchKey);
+ const char* p = extensions;
+
+ for (;;)
+ {
+ p = strstr(p, searchKey);
+
+ // If not found,
+ if (p == NULL)
+ {
+ break;
+ }
+
+ // Only match full string
+ if ((p == extensions || p[-1] == ' ') &&
+ (p[searchKeyLen] == '\0' || p[searchKeyLen] == ' '))
+ {
+ return true;
+ }
+
+ // Skip ahead
+ p += searchKeyLen;
+ }
+
+ return false;
+}
+
+static void ParseGLExtensions(GLVersionAndExtensions& versionInfo)
+{
+ const char* extensions = (const char*)glGetString(GL_EXTENSIONS);
+
+ OVR_ASSERT(extensions);
+ if (!extensions)
+ {
+ extensions = ""; // Note: glGetString() can return null
+ LogText("Warning: GL_EXTENSIONS was NULL\n");
+ }
+ else
+ {
+ // Cannot print this to debug log: It's too long!
+ //OVR_DEBUG_LOG(("GL_EXTENSIONS: %s", (const char*)extensions));
+ }
+
+ versionInfo.Extensions = extensions;
+
+ if (versionInfo.MajorVersion >= 3)
+ {
+ versionInfo.SupportsVAO = true;
+ }
+ else
+ {
+ versionInfo.SupportsVAO =
+ HasGLExtension(extensions, "GL_ARB_vertex_array_object") ||
+ HasGLExtension(extensions, "GL_APPLE_vertex_array_object");
+ }
+
+ versionInfo.SupportsDrawBuffers = HasGLExtension(extensions, "GL_EXT_draw_buffers2");
+
+ // Add more extension checks here...
+}
+
+void GetGLVersionAndExtensions(GLVersionAndExtensions& versionInfo)
+{
+ ParseGLVersion(versionInfo);
+
+ // GL Version must be parsed before parsing extensions:
+
+ ParseGLExtensions(versionInfo);
+}
+
+
+}}} // namespace OVR::Render::GL
diff --git a/Samples/CommonSrc/Render/Render_GL_Device.h b/Samples/CommonSrc/Render/Render_GL_Device.h
index 9b8ccef..0e24517 100644
--- a/Samples/CommonSrc/Render/Render_GL_Device.h
+++ b/Samples/CommonSrc/Render/Render_GL_Device.h
@@ -43,9 +43,9 @@ limitations under the License.
#include <GL/glx.h>
#endif
-
namespace OVR { namespace Render { namespace GL {
-
+
+
#if !defined(OVR_OS_MAC)
// GL extension Hooks for PC.
@@ -114,6 +114,44 @@ extern void InitGLExtensions();
#endif
+
+
+//// GLVersion
+
+/*
+ FIXME: CODE DUPLICATION WARNING
+
+ Right now we have this same code in CommonSrc and in CAPI::GL.
+ At some point we need to consolidate these, in Kernel or Util.
+ Be sure to update both locations for now!
+*/
+
+struct GLVersionAndExtensions
+{
+ // Version information
+ int MajorVersion; // Best guess at major version
+ int MinorVersion; // Best guess at minor version
+ bool IsGLES; // Open GL ES?
+
+ // Extension information
+ bool SupportsVAO; // Supports Vertex Array Objects?
+ bool SupportsDrawBuffers; // Supports Draw Buffers?
+ const char* Extensions; // Other extensions string (will not be null)
+
+ GLVersionAndExtensions()
+ {
+ IsGLES = false;
+ MajorVersion = 0;
+ MinorVersion = 0;
+ SupportsDrawBuffers = false;
+ SupportsVAO = false;
+ Extensions = "";
+ }
+};
+
+void GetGLVersionAndExtensions(GLVersionAndExtensions& versionInfo);
+
+
class RenderDevice;
class Buffer : public Render::Buffer
@@ -243,10 +281,10 @@ protected:
Ptr<Texture> CurRenderTarget;
Array<Ptr<Texture> > DepthBuffers;
GLuint CurrentFbo;
+ GLVersionAndExtensions GLVersionInfo;
const LightingParams* Lighting;
- bool SupportsVao;
-
+
public:
RenderDevice(const RendererParams& p);
virtual ~RenderDevice();
@@ -258,6 +296,7 @@ public:
virtual void SetViewport(const Recti& vp);
virtual void WaitUntilGpuIdle();
+ virtual void Flush();
virtual void Clear(float r = 0, float g = 0, float b = 0, float a = 1, float depth = 1,
bool clearColor = true, bool clearDepth = true);
@@ -292,6 +331,7 @@ public:
void SetTexture(Render::ShaderStage, int slot, const Texture* t);
};
+
}}}
#endif
diff --git a/Samples/CommonSrc/Render/Render_GL_Win32_Device.cpp b/Samples/CommonSrc/Render/Render_GL_Win32_Device.cpp
index 8b4ac73..b2e2e10 100644
--- a/Samples/CommonSrc/Render/Render_GL_Win32_Device.cpp
+++ b/Samples/CommonSrc/Render/Render_GL_Win32_Device.cpp
@@ -31,7 +31,7 @@ namespace OVR { namespace Render { namespace GL { namespace Win32 {
typedef HRESULT (WINAPI *PFNDWMENABLECOMPOSITIONPROC) (UINT);
#pragma warning(disable : 4995)
-PFNDWMENABLECOMPOSITIONPROC DwmEnableComposition;
+PFNDWMENABLECOMPOSITIONPROC DwmEnableComposition = NULL;
// ***** GL::Win32::RenderDevice
diff --git a/Samples/CommonSrc/Render/Render_LoadTextureDDS.cpp b/Samples/CommonSrc/Render/Render_LoadTextureDDS.cpp
index 3da1441..08dda43 100644
--- a/Samples/CommonSrc/Render/Render_LoadTextureDDS.cpp
+++ b/Samples/CommonSrc/Render/Render_LoadTextureDDS.cpp
@@ -22,10 +22,6 @@ limitations under the License.
************************************************************************************/
#include "Render_Device.h"
-#ifdef OVR_DEFINE_NEW
-#undef new
-#endif
-
namespace OVR { namespace Render {
static const size_t OVR_DDS_PF_FOURCC = 0x4;
diff --git a/Samples/CommonSrc/Render/Render_XmlSceneLoader.cpp b/Samples/CommonSrc/Render/Render_XmlSceneLoader.cpp
index 3d035e2..0eea8eb 100644
--- a/Samples/CommonSrc/Render/Render_XmlSceneLoader.cpp
+++ b/Samples/CommonSrc/Render/Render_XmlSceneLoader.cpp
@@ -24,10 +24,6 @@ limitations under the License.
#include "Render_XmlSceneLoader.h"
#include <Kernel/OVR_Log.h>
-#ifdef OVR_DEFINE_NEW
-#undef new
-#endif
-
namespace OVR { namespace Render {
XmlHandler::XmlHandler() : pXmlDocument(NULL)
diff --git a/Samples/CommonSrc/Render/Render_XmlSceneLoader.h b/Samples/CommonSrc/Render/Render_XmlSceneLoader.h
index 7dff174..22c9ccd 100644
--- a/Samples/CommonSrc/Render/Render_XmlSceneLoader.h
+++ b/Samples/CommonSrc/Render/Render_XmlSceneLoader.h
@@ -29,10 +29,6 @@ limitations under the License.
using namespace OVR;
using namespace OVR::Render;
-#ifdef OVR_DEFINE_NEW
-#undef new
-#endif
-
#include "../../../3rdParty/TinyXml/tinyxml2.h"
namespace OVR { namespace Render {
diff --git a/Samples/LibOVR_With_Samples_VS2013.sln b/Samples/LibOVR_With_Samples_VS2013.sln
index 1d2b8d7..48193c8 100644
--- a/Samples/LibOVR_With_Samples_VS2013.sln
+++ b/Samples/LibOVR_With_Samples_VS2013.sln
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
-VisualStudioVersion = 12.0.30110.0
+VisualStudioVersion = 12.0.30501.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibOVR", "..\LibOVR\Projects\Win32\VS2013\LibOVR.vcxproj", "{EA50E705-5113-49E5-B105-2512EDC8DDC6}"
EndProject
@@ -40,6 +40,7 @@ Global
{394FF596-A90B-4C95-888B-B743834ED15B}.Release|x64.Build.0 = Release|x64
{CA4E4127-1BAD-447C-BFF9-5AF940EEC376}.Debug|Win32.ActiveCfg = Debug|Win32
{CA4E4127-1BAD-447C-BFF9-5AF940EEC376}.Debug|Win32.Build.0 = Debug|Win32
+ {CA4E4127-1BAD-447C-BFF9-5AF940EEC376}.Debug|Win32.Deploy.0 = Debug|Win32
{CA4E4127-1BAD-447C-BFF9-5AF940EEC376}.Debug|x64.ActiveCfg = Debug|x64
{CA4E4127-1BAD-447C-BFF9-5AF940EEC376}.Debug|x64.Build.0 = Debug|x64
{CA4E4127-1BAD-447C-BFF9-5AF940EEC376}.Release|Win32.ActiveCfg = Release|Win32
diff --git a/Samples/OculusRoomTiny/Projects/Win/VS2010/OculusRoomTiny.vcxproj b/Samples/OculusRoomTiny/Projects/Win/VS2010/OculusRoomTiny.vcxproj
index 240c632..9e3c1b1 100644
--- a/Samples/OculusRoomTiny/Projects/Win/VS2010/OculusRoomTiny.vcxproj
+++ b/Samples/OculusRoomTiny/Projects/Win/VS2010/OculusRoomTiny.vcxproj
@@ -178,9 +178,11 @@
<ClCompile Include="../../../RenderTiny_D3D11_Device.cpp" />
<ClCompile Include="../../../Win32_OculusRoomTiny.cpp" />
<ClCompile Include="../../../Win32_OculusRoomTiny_Util.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Platform\Win32_Gamepad.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="../../../RenderTiny_D3D11_Device.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Win32_Gamepad.h" />
<ClInclude Include="..\..\..\HSWDisplay_Util.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
diff --git a/Samples/OculusRoomTiny/Projects/Win/VS2010/OculusRoomTiny.vcxproj.filters b/Samples/OculusRoomTiny/Projects/Win/VS2010/OculusRoomTiny.vcxproj.filters
index 919cd62..51fe5fe 100644
--- a/Samples/OculusRoomTiny/Projects/Win/VS2010/OculusRoomTiny.vcxproj.filters
+++ b/Samples/OculusRoomTiny/Projects/Win/VS2010/OculusRoomTiny.vcxproj.filters
@@ -11,6 +11,9 @@
<Filter>Util</Filter>
</ClCompile>
<ClCompile Include="../../../Win32_OculusRoomTiny.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Platform\Win32_Gamepad.cpp">
+ <Filter>CommonSrc</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="../../../RenderTiny_D3D11_Device.h">
@@ -19,10 +22,16 @@
<ClInclude Include="..\..\..\HSWDisplay_Util.h">
<Filter>Util</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Win32_Gamepad.h">
+ <Filter>CommonSrc</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="Util">
<UniqueIdentifier>{0750679b-ec1e-44c8-a78b-05d9e58a3588}</UniqueIdentifier>
</Filter>
+ <Filter Include="CommonSrc">
+ <UniqueIdentifier>{36ff2ee7-56d9-4606-9b8c-68dff117b124}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/Samples/OculusRoomTiny/Projects/Win/VS2012/OculusRoomTiny.vcxproj b/Samples/OculusRoomTiny/Projects/Win/VS2012/OculusRoomTiny.vcxproj
index e176e4b..cc9dd3e 100644
--- a/Samples/OculusRoomTiny/Projects/Win/VS2012/OculusRoomTiny.vcxproj
+++ b/Samples/OculusRoomTiny/Projects/Win/VS2012/OculusRoomTiny.vcxproj
@@ -186,9 +186,11 @@
<ClCompile Include="../../../RenderTiny_D3D11_Device.cpp" />
<ClCompile Include="../../../Win32_OculusRoomTiny.cpp" />
<ClCompile Include="../../../Win32_OculusRoomTiny_Util.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Platform\Win32_Gamepad.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="../../../RenderTiny_D3D11_Device.h" />
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Win32_Gamepad.h" />
<ClInclude Include="..\..\..\HSWDisplay_Util.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
diff --git a/Samples/OculusRoomTiny/Projects/Win/VS2012/OculusRoomTiny.vcxproj.filters b/Samples/OculusRoomTiny/Projects/Win/VS2012/OculusRoomTiny.vcxproj.filters
index 580b83a..4b0ebdd 100644
--- a/Samples/OculusRoomTiny/Projects/Win/VS2012/OculusRoomTiny.vcxproj.filters
+++ b/Samples/OculusRoomTiny/Projects/Win/VS2012/OculusRoomTiny.vcxproj.filters
@@ -11,11 +11,17 @@
<ClCompile Include="../../../Win32_OculusRoomTiny_Util.cpp">
<Filter>Util</Filter>
</ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Platform\Win32_Gamepad.cpp">
+ <Filter>CommonSrc</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<Filter Include="Util">
<UniqueIdentifier>{0750679b-ec1e-44c8-a78b-05d9e58a3588}</UniqueIdentifier>
</Filter>
+ <Filter Include="CommonSrc">
+ <UniqueIdentifier>{4b2897e2-d185-4e74-b7c9-b66282a1cbe7}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="../../../RenderTiny_D3D11_Device.h">
@@ -24,5 +30,8 @@
<ClInclude Include="..\..\..\HSWDisplay_Util.h">
<Filter>Util</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Win32_Gamepad.h">
+ <Filter>CommonSrc</Filter>
+ </ClInclude>
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/Samples/OculusRoomTiny/Projects/Win/VS2013/OculusRoomTiny.vcxproj b/Samples/OculusRoomTiny/Projects/Win/VS2013/OculusRoomTiny.vcxproj
index 232b7aa..a85b395 100644
--- a/Samples/OculusRoomTiny/Projects/Win/VS2013/OculusRoomTiny.vcxproj
+++ b/Samples/OculusRoomTiny/Projects/Win/VS2013/OculusRoomTiny.vcxproj
@@ -191,6 +191,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="../../../OculusRoomModel.cpp" />
+ <ClCompile Include="..\..\..\..\CommonSrc\Platform\Win32_Gamepad.cpp" />
<ClCompile Include="..\..\..\RenderTiny_D3D11_Device.cpp" />
<ClCompile Include="..\..\..\Win32_OculusRoomTiny.cpp" />
<ClCompile Include="..\..\..\Win32_OculusRoomTiny_Util.cpp" />
@@ -199,6 +200,7 @@
<ResourceCompile Include="../../../OculusRoomTiny2.rc" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Win32_Gamepad.h" />
<ClInclude Include="..\..\..\HSWDisplay_Util.h" />
<ClInclude Include="..\..\..\RenderTiny_D3D11_Device.h" />
</ItemGroup>
diff --git a/Samples/OculusRoomTiny/Projects/Win/VS2013/OculusRoomTiny.vcxproj.filters b/Samples/OculusRoomTiny/Projects/Win/VS2013/OculusRoomTiny.vcxproj.filters
index ae5e0eb..4beea60 100644
--- a/Samples/OculusRoomTiny/Projects/Win/VS2013/OculusRoomTiny.vcxproj.filters
+++ b/Samples/OculusRoomTiny/Projects/Win/VS2013/OculusRoomTiny.vcxproj.filters
@@ -11,6 +11,9 @@
<ClCompile Include="..\..\..\Win32_OculusRoomTiny_Util.cpp">
<Filter>Util</Filter>
</ClCompile>
+ <ClCompile Include="..\..\..\..\CommonSrc\Platform\Win32_Gamepad.cpp">
+ <Filter>CommonSrc</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="../../../OculusRoomTiny2.rc" />
@@ -19,6 +22,9 @@
<Filter Include="Util">
<UniqueIdentifier>{aa2ef577-a403-4088-a39c-0a87a96151a9}</UniqueIdentifier>
</Filter>
+ <Filter Include="CommonSrc">
+ <UniqueIdentifier>{0b10aa1d-2337-4b0b-942a-843ac96a682f}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\RenderTiny_D3D11_Device.h">
@@ -27,5 +33,8 @@
<ClInclude Include="..\..\..\HSWDisplay_Util.h">
<Filter>Util</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\..\CommonSrc\Platform\Win32_Gamepad.h">
+ <Filter>CommonSrc</Filter>
+ </ClInclude>
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/Samples/OculusRoomTiny/Win32_OculusRoomTiny.cpp b/Samples/OculusRoomTiny/Win32_OculusRoomTiny.cpp
index 48373ad..74a46e5 100644
--- a/Samples/OculusRoomTiny/Win32_OculusRoomTiny.cpp
+++ b/Samples/OculusRoomTiny/Win32_OculusRoomTiny.cpp
@@ -215,9 +215,9 @@ int Init()
ovrHmd_SetEnabledCaps(HMD, ovrHmdCap_LowPersistence | ovrHmdCap_DynamicPrediction);
// Start the sensor which informs of the Rift's pose and motion
- ovrHmd_ConfigureTracking(HMD, ovrTrackingCap_Orientation |
- ovrTrackingCap_MagYawCorrection |
- ovrTrackingCap_Position, 0);
+ ovrHmd_ConfigureTracking(HMD, ovrTrackingCap_Orientation |
+ ovrTrackingCap_MagYawCorrection |
+ ovrTrackingCap_Position, 0);
// This creates lights and models.
pRoomScene = new Scene;
@@ -304,13 +304,23 @@ void ProcessAndRender()
pRender->Render(&distortionShaderFill, MeshVBs[eyeNum], MeshIBs[eyeNum],sizeof(ovrDistortionVertex));
}
+ unsigned char latencyColor[3];
+ ovrBool drawDk2LatencyQuad = ovrHmd_GetLatencyTest2DrawColor(HMD, latencyColor);
+ if(drawDk2LatencyQuad)
+ {
+ const int latencyQuadSize = 20; // only needs to be 1-pixel, but larger helps visual debugging
+ pRender->SetViewport(HMD->Resolution.w - latencyQuadSize, 0, latencyQuadSize, latencyQuadSize);
+ pRender->Clear(latencyColor[0] / 255.0f, latencyColor[1] / 255.0f, latencyColor[2] / 255.0f, 0.0f);
+ }
+
pRender->SetDefaultRenderTarget();
pRender->Present( true ); // Vsync enabled
// Only flush GPU for ExtendDesktop; not needed in Direct App Renering with Oculus driver.
if (HMD->HmdCaps & ovrHmdCap_ExtendDesktop)
- pRender->WaitUntilGpuIdle();
+ pRender->WaitUntilGpuIdle();
+
ovrHmd_EndFrameTiming(HMD);
#endif
}
diff --git a/Samples/OculusRoomTiny/Win32_OculusRoomTiny_Util.cpp b/Samples/OculusRoomTiny/Win32_OculusRoomTiny_Util.cpp
index 8ad3798..f371ce1 100644
--- a/Samples/OculusRoomTiny/Win32_OculusRoomTiny_Util.cpp
+++ b/Samples/OculusRoomTiny/Win32_OculusRoomTiny_Util.cpp
@@ -21,6 +21,7 @@ limitations under the License.
#include "RenderTiny_D3D11_Device.h"
#include "OVR_CAPI.h"
+#include "../CommonSrc/Platform/Win32_Gamepad.h"
// Win32 System Variables
HWND hWnd = NULL;
@@ -52,6 +53,9 @@ int Init();
void ProcessAndRender();
void Release();
+// Gamepad Variables
+OvrPlatform::Win32::GamepadManager GamepadManager;
+OvrPlatform::GamepadState LastGamepadState = OvrPlatform::GamepadState();
//-------------------------------------------------------------------------------------
@@ -85,94 +89,117 @@ void OnKey(unsigned vk, bool down)
void OnMouseMove(int x)
{
- const float Sensitivity = 1.0f;
+ const float Sensitivity = 1.0f;
AdditionalYawFromMouse -= (Sensitivity * x)/ 360.0f;
}
bool Util_RespondToControls(float & EyeYaw, Vector3f & EyePos, Quatf PoseOrientation)
{
- #if 0//Optional debug output
- char debugString[1000];
- sprintf_s(debugString,"Pos = (%0.2f, %0.2f, %0.2f)\n",EyePos.x,EyePos.y,EyePos.z);
- OutputDebugStringA(debugString);
- #endif
+ #if 0//Optional debug output
+ char debugString[1000];
+ sprintf_s(debugString,"Pos = (%0.2f, %0.2f, %0.2f)\n",EyePos.x,EyePos.y,EyePos.z);
+ OutputDebugStringA(debugString);
+ #endif
- //Mouse rotation
- EyeYaw += AdditionalYawFromMouse;
- AdditionalYawFromMouse = 0;
+ //Mouse rotation
+ EyeYaw += AdditionalYawFromMouse;
+ AdditionalYawFromMouse = 0;
- //Get HeadYaw
- float tempHeadPitch, tempHeadRoll, HeadYaw;
- PoseOrientation.GetEulerAngles<Axis_Y, Axis_X, Axis_Z>(&HeadYaw,&tempHeadPitch, &tempHeadRoll);
+ //Get HeadYaw
+ float tempHeadPitch, tempHeadRoll, HeadYaw, GamepadYaw;
+ PoseOrientation.GetEulerAngles<Axis_Y, Axis_X, Axis_Z>(&HeadYaw,&tempHeadPitch, &tempHeadRoll);
- //Move on Eye pos from controls
+ //Move on Eye pos from controls
Vector3f localMoveVector(0,0,0);
- Matrix4f yawRotate = Matrix4f::RotationY(EyeYaw + HeadYaw);
- if (MoveForward) localMoveVector += Vector3f(0,0,-1);
+ if (MoveForward) localMoveVector += Vector3f(0,0,-1);
if (MoveBack) localMoveVector += Vector3f(0,0,+1);
if (MoveRight) localMoveVector += Vector3f(1,0,0);
if (MoveLeft) localMoveVector += Vector3f(-1,0,0);
- Vector3f orientationVector = yawRotate.Transform(localMoveVector);
+ //respond to gamepad
+ OvrPlatform::GamepadState gamepadstate;
+ if (GamepadManager.GetGamepadState(1, &gamepadstate))
+ {
+ if (gamepadstate.Buttons != 0)
+ ovrHmd_DismissHSWDisplay(HMD);
+ LastGamepadState = gamepadstate;
+ }
+
+ //move according to gamepad input
+ localMoveVector += Vector3f(LastGamepadState.LX, 0, -LastGamepadState.LY);
+
+ //prevents double speed using gamepad and
+ if (localMoveVector.x > 1) localMoveVector.x = 1;
+ if (localMoveVector.y > 1) localMoveVector.y = 1;
+
+ //rotate according to gamepad input
+ const float gamepad_sensitivity = .025;
+ GamepadYaw = -gamepad_sensitivity * LastGamepadState.RX;
+
+ EyeYaw += GamepadYaw;
+
+ Matrix4f yawRotate = Matrix4f::RotationY(EyeYaw + HeadYaw);
+
+ Vector3f orientationVector = yawRotate.Transform(localMoveVector);
- const float deltaTime = 1.0f/60.0f;
+ const float deltaTime = 1.0f/60.0f;
orientationVector *= MoveSpeed * deltaTime * (ShiftDown ? 3.0f : 1.0f);
- EyePos += orientationVector;
+ EyePos += orientationVector;
- //Some rudimentary limitation of movement, so not to go through walls
- const float minDistanceToWall = 0.30f;
- EyePos.x = max(EyePos.x,-10.0f + minDistanceToWall);
- EyePos.x = min(EyePos.x, 10.0f - minDistanceToWall);
- EyePos.z = max(EyePos.z,-20.0f + minDistanceToWall);
+ //Some rudimentary limitation of movement, so not to go through walls
+ const float minDistanceToWall = 0.30f;
+ EyePos.x = max(EyePos.x,-10.0f + minDistanceToWall);
+ EyePos.x = min(EyePos.x, 10.0f - minDistanceToWall);
+ EyePos.z = max(EyePos.z,-20.0f + minDistanceToWall);
- //Return if need to freeze or not
- return(FreezeEyeRender);
+ //Return if need to freeze or not
+ return(FreezeEyeRender);
}
LRESULT CALLBACK systemWindowProc(HWND arg_hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
- switch (msg)
+ switch (msg)
{
- case(WM_NCCREATE): hWnd = arg_hwnd; break;
-
- case WM_MOUSEMOVE: {
- // Convert mouse motion to be relative
- // (report the offset and re-center).
- POINT newPos = { LOWORD(lp), HIWORD(lp) };
- ::ClientToScreen(hWnd, &newPos);
- if ((newPos.x == WindowCenter.x) && (newPos.y == WindowCenter.y))
- break;
- ::SetCursorPos(WindowCenter.x, WindowCenter.y);
- OnMouseMove(newPos.x - WindowCenter.x);
- break;
- }
-
- case WM_MOVE: RECT r;
- GetClientRect(hWnd, &r);
- WindowCenter.x = r.right/2;
- WindowCenter.y = r.bottom/2;
- ::ClientToScreen(hWnd, &WindowCenter);
- break;
-
- case WM_KEYDOWN: OnKey((unsigned)wp, true); break;
- case WM_KEYUP: OnKey((unsigned)wp, false); break;
- case WM_CREATE: SetTimer(hWnd, 0, 100, NULL); break;
- case WM_TIMER: KillTimer(hWnd, 0);
-
- case WM_SETFOCUS:
- SetCursorPos(WindowCenter.x, WindowCenter.y);
- SetCapture(hWnd);
- ShowCursor(FALSE);
- break;
- case WM_KILLFOCUS:
- ReleaseCapture();
- ShowCursor(TRUE);
- break;
-
- case WM_QUIT:
- case WM_CLOSE: Quit = true;
+ case(WM_NCCREATE): hWnd = arg_hwnd; break;
+
+ case WM_MOUSEMOVE: {
+ // Convert mouse motion to be relative
+ // (report the offset and re-center).
+ POINT newPos = { LOWORD(lp), HIWORD(lp) };
+ ::ClientToScreen(hWnd, &newPos);
+ if ((newPos.x == WindowCenter.x) && (newPos.y == WindowCenter.y))
+ break;
+ ::SetCursorPos(WindowCenter.x, WindowCenter.y);
+ OnMouseMove(newPos.x - WindowCenter.x);
+ break;
+ }
+
+ case WM_MOVE: RECT r;
+ GetClientRect(hWnd, &r);
+ WindowCenter.x = r.right/2;
+ WindowCenter.y = r.bottom/2;
+ ::ClientToScreen(hWnd, &WindowCenter);
+ break;
+
+ case WM_KEYDOWN: OnKey((unsigned)wp, true); break;
+ case WM_KEYUP: OnKey((unsigned)wp, false); break;
+ case WM_CREATE: SetTimer(hWnd, 0, 100, NULL); break;
+ case WM_TIMER: KillTimer(hWnd, 0);
+
+ case WM_SETFOCUS:
+ SetCursorPos(WindowCenter.x, WindowCenter.y);
+ SetCapture(hWnd);
+ ShowCursor(FALSE);
+ break;
+ case WM_KILLFOCUS:
+ ReleaseCapture();
+ ShowCursor(TRUE);
+ break;
+
+ case WM_QUIT:
+ case WM_CLOSE: Quit = true;
return 0;
}
@@ -184,7 +211,7 @@ HWND Util_InitWindowAndGraphics(Recti vp, int fullscreen, int multiSampleCount,
{
RendererParams renderParams;
- // Window
+ // Window
WNDCLASS wc;
memset(&wc, 0, sizeof(wc));
wc.lpszClassName = L"OVRAppWindow";
@@ -205,11 +232,11 @@ HWND Util_InitWindowAndGraphics(Recti vp, int fullscreen, int multiSampleCount,
sizeDivisor = 2;
}
- RECT winSize = { 0, 0, vp.w / sizeDivisor, vp.h / sizeDivisor};
+ RECT winSize = { 0, 0, vp.w / sizeDivisor, vp.h / sizeDivisor};
AdjustWindowRect(&winSize, wsStyle, false);
hWnd = CreateWindowA("OVRAppWindow", "OculusRoomTiny",
wsStyle |WS_VISIBLE,
- vp.x, vp.y,
+ vp.x, vp.y,
winSize.right-winSize.left, winSize.bottom-winSize.top,
NULL, NULL, hInstance, NULL);
@@ -217,10 +244,10 @@ HWND Util_InitWindowAndGraphics(Recti vp, int fullscreen, int multiSampleCount,
::ClientToScreen(hWnd, &center);
WindowCenter = center;
- if (!hWnd) return(NULL);
+ if (!hWnd) return(NULL);
- // Graphics
- renderParams.Multisample = multiSampleCount;
+ // Graphics
+ renderParams.Multisample = multiSampleCount;
renderParams.Fullscreen = fullscreen;
*returnedDevice = RenderDevice::CreateDevice(renderParams, (void*)hWnd);
@@ -231,8 +258,8 @@ HWND Util_InitWindowAndGraphics(Recti vp, int fullscreen, int multiSampleCount,
void Util_ReleaseWindowAndGraphics(RenderDevice * prender)
{
- if (prender)
- prender->Release();
+ if (prender)
+ prender->Release();
if (hWnd)
{
@@ -248,29 +275,29 @@ void Util_ReleaseWindowAndGraphics(RenderDevice * prender)
//
int WINAPI WinMain(HINSTANCE hinst, HINSTANCE, LPSTR , int)
{
- hInstance = hinst;
+ hInstance = hinst;
if (!Init())
{
// Processes messages and calls OnIdle() to do rendering.
- while (!Quit)
- {
- MSG msg;
- if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- else
- {
- ProcessAndRender();
-
- // Keep sleeping when we're minimized.
- if (IsIconic(hWnd)) Sleep(10);
- }
- }
+ while (!Quit)
+ {
+ MSG msg;
+ if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ else
+ {
+ ProcessAndRender();
+
+ // Keep sleeping when we're minimized.
+ if (IsIconic(hWnd)) Sleep(10);
+ }
+ }
}
- Release();
+ Release();
OVR_ASSERT(!_CrtDumpMemoryLeaks());
return (0);
}
diff --git a/Samples/OculusWorldDemo/OculusWorldDemo.cpp b/Samples/OculusWorldDemo/OculusWorldDemo.cpp
index 7dfde26..99a924f 100644
--- a/Samples/OculusWorldDemo/OculusWorldDemo.cpp
+++ b/Samples/OculusWorldDemo/OculusWorldDemo.cpp
@@ -33,6 +33,11 @@ OculusWorldDemoApp::OculusWorldDemoApp()
WindowSize(1280,800),
ScreenNumber(0),
FirstScreenInCycle(0),
+ LastVisionProcessingTime(0.),
+ VisionTimesCount(0),
+ VisionProcessingSum(0.),
+ VisionProcessingAverage(0.),
+
Hmd(0),
StartTrackingCaps(0),
UsingDebugHmd(false),
@@ -70,6 +75,7 @@ OculusWorldDemoApp::OculusWorldDemoApp()
DisplaySleep(false),
PositionTrackingEnabled(true),
PixelLuminanceOverdrive(true),
+ HqAaDistortion(true),
MirrorToWindow(true),
SupportsSrgb(true),
@@ -122,6 +128,8 @@ int OculusWorldDemoApp::OnStartup(int argc, const char** argv)
if (!Hmd)
{
+ Menu.SetPopupMessage("Unable to create HMD: %s", ovrHmd_GetLastError(NULL));
+
// If we didn't detect an Hmd, create a simulated one for debugging.
Hmd = ovrHmd_CreateDebug(ovrHmd_DK1);
UsingDebugHmd = true;
@@ -146,7 +154,9 @@ int OculusWorldDemoApp::OnStartup(int argc, const char** argv)
// ***** Setup System Window & rendering.
if (!SetupWindowAndRendering(argc, argv))
+ {
return 1;
+ }
NotificationTimeout = ovr_GetTimeInSeconds() + 10.0f;
@@ -159,6 +169,7 @@ int OculusWorldDemoApp::OnStartup(int argc, const char** argv)
PixelLuminanceOverdrive = (Hmd->DistortionCaps & ovrDistortionCap_Overdrive) ? true : false;
+ HqAaDistortion = (Hmd->DistortionCaps & ovrDistortionCap_HqDistortion) ? true : false;
// *** Configure HMD Stereo settings.
@@ -280,7 +291,6 @@ static String FormatMaxFromSideTan(OptionVar* var)
return String(buff);
}
-
void OculusWorldDemoApp::PopulateOptionMenu()
{
// For shortened function member access.
@@ -359,6 +369,7 @@ void OculusWorldDemoApp::PopulateOptionMenu()
Menu.AddBool("Zero Head Movement", &ForceZeroHeadMovement) .AddShortcutKey(Key_F7, ShortcutKey::Shift_RequireOn);
Menu.AddBool("VSync 'V'", &VsyncEnabled) .AddShortcutKey(Key_V).SetNotify(this, &OWD::HmdSettingChange);
Menu.AddBool("MultiSample 'F4'", &MultisampleEnabled) .AddShortcutKey(Key_F4).SetNotify(this, &OWD::MultisampleChange);
+ Menu.AddBool("High Quality Distortion", &HqAaDistortion) .AddShortcutKey(Key_F5).SetNotify(this, &OWD::HmdSettingChange);
Menu.AddTrigger("Recenter HMD pose 'R'").AddShortcutKey(Key_R).SetNotify(this, &OWD::ResetHmdPose);
// Add DK2 options to menu only for that headset.
@@ -510,6 +521,8 @@ void OculusWorldDemoApp::CalculateHmdValues()
distortionCaps |= ovrDistortionCap_TimeWarp;
if(TimewarpNoJitEnabled)
distortionCaps |= ovrDistortionCap_ProfileNoTimewarpSpinWaits;
+ if(HqAaDistortion)
+ distortionCaps |= ovrDistortionCap_HqDistortion;
if (!ovrHmd_ConfigureRendering( Hmd, &config, distortionCaps,
eyeFov, EyeRenderDesc ))
@@ -796,12 +809,12 @@ void OculusWorldDemoApp::OnIdle()
GamepadStateChanged(gamepadState);
}
- ovrTrackingState ss = ovrHmd_GetTrackingState(Hmd, HmdFrameTiming.ScanoutMidpointSeconds);
- HmdStatus = ss.StatusFlags;
+ ovrTrackingState trackState = ovrHmd_GetTrackingState(Hmd, HmdFrameTiming.ScanoutMidpointSeconds);
+ HmdStatus = trackState.StatusFlags;
// Report vision tracking
bool hadVisionTracking = HaveVisionTracking;
- HaveVisionTracking = (ss.StatusFlags & ovrStatus_PositionTracked) != 0;
+ HaveVisionTracking = (trackState.StatusFlags & ovrStatus_PositionTracked) != 0;
if (HaveVisionTracking && !hadVisionTracking)
Menu.SetPopupMessage("Vision Tracking Acquired");
if (!HaveVisionTracking && hadVisionTracking)
@@ -809,7 +822,7 @@ void OculusWorldDemoApp::OnIdle()
// Report position tracker
bool hadPositionTracker = HavePositionTracker;
- HavePositionTracker = (ss.StatusFlags & ovrStatus_PositionConnected) != 0;
+ HavePositionTracker = (trackState.StatusFlags & ovrStatus_PositionConnected) != 0;
if (HavePositionTracker && !hadPositionTracker)
Menu.SetPopupMessage("Position Tracker Connected");
if (!HavePositionTracker && hadPositionTracker)
@@ -817,12 +830,14 @@ void OculusWorldDemoApp::OnIdle()
// Report position tracker
bool hadHMDConnected = HaveHMDConnected;
- HaveHMDConnected = (ss.StatusFlags & ovrStatus_HmdConnected) != 0;
+ HaveHMDConnected = (trackState.StatusFlags & ovrStatus_HmdConnected) != 0;
if (HaveHMDConnected && !hadHMDConnected)
Menu.SetPopupMessage("HMD Connected");
if (!HaveHMDConnected && hadHMDConnected)
Menu.SetPopupMessage("HMD Disconnected");
+ UpdateVisionProcessingTime(trackState);
+
// Check if any new devices were connected.
ProcessDeviceNotificationQueue();
// FPS count and timing.
@@ -830,7 +845,7 @@ void OculusWorldDemoApp::OnIdle()
// Update pose based on frame!
- ThePlayer.HeadPose = ss.HeadPose.ThePose;
+ ThePlayer.HeadPose = trackState.HeadPose.ThePose;
// Movement/rotation with the gamepad.
ThePlayer.BodyYaw -= ThePlayer.GamepadRotate.x * dt;
ThePlayer.HandleMovement(dt, &CollisionModels, &GroundCollisionModels, ShiftDown);
@@ -1032,6 +1047,27 @@ void OculusWorldDemoApp::UpdateFrameRateCounter(double curtime)
}
}
+void OculusWorldDemoApp::UpdateVisionProcessingTime(const ovrTrackingState& trackState)
+{
+ // Update LastVisionProcessingTime
+ if (trackState.LastVisionProcessingTime != LastVisionProcessingTime)
+ {
+ LastVisionProcessingTime = trackState.LastVisionProcessingTime;
+
+ VisionProcessingSum += LastVisionProcessingTime;
+
+ if (VisionTimesCount >= 20)
+ {
+ VisionProcessingAverage = VisionProcessingSum / 20.;
+ VisionProcessingSum = 0.;
+ VisionTimesCount = 0;
+ }
+ else
+ {
+ VisionTimesCount++;
+ }
+ }
+}
void OculusWorldDemoApp::RenderEyeView(ovrEyeType eye)
{
@@ -1145,7 +1181,7 @@ void OculusWorldDemoApp::RenderTextInfoHud(float textHeight)
{
case Text_Info:
{
- char buf[512], gpustat[256];
+ char buf[512];
// Average FOVs.
FovPort leftFov = EyeRenderDesc[0].Fov;
@@ -1175,8 +1211,9 @@ void OculusWorldDemoApp::RenderTextInfoHud(float textHeight)
OVR_sprintf(latency2Text, sizeof(latency2Text),
" DK2 Latency Ren: %s TWrp: %s\n"
- " PostPresent: %s ",
- latencyText0, latencyText1, latencyText2);
+ " PostPresent: %s VisionProc: %1.2f ms ",
+ latencyText0, latencyText1, latencyText2,
+ (float)VisionProcessingAverage * 1000);
}
}
@@ -1207,12 +1244,15 @@ void OculusWorldDemoApp::RenderTextInfoHud(float textHeight)
latency2Text
);
+#if 0 // Enable if interested in texture memory usage stats
size_t texMemInMB = pRender->GetTotalTextureMemoryUsage() / (1024 * 1024); // 1 MB
if (texMemInMB)
{
- OVR_sprintf(gpustat, sizeof(gpustat), " GPU Tex: %u MB", texMemInMB);
+ char gpustat[256];
+ OVR_sprintf(gpustat, sizeof(gpustat), "\nGPU Tex: %u MB", texMemInMB);
OVR_strcat(buf, sizeof(buf), gpustat);
}
+#endif
DrawTextBox(pRender, 0.0f, 0.0f, textHeight, buf, DrawText_Center);
}
@@ -1244,14 +1284,9 @@ void OculusWorldDemoApp::RenderTextInfoHud(float textHeight)
// Non-trivial callback go here.
-void OculusWorldDemoApp::HmdSensorToggle(OptionVar*)
+void OculusWorldDemoApp::HmdSensorToggle(OptionVar* var)
{
- if (EnableSensor)
- {
- EnableSensor = false;
- ovrHmd_ConfigureTracking(Hmd, 0, 0);
- }
- else
+ if (*var->AsBool())
{
EnableSensor = true;
if (!ovrHmd_ConfigureTracking(Hmd, StartTrackingCaps, 0))
@@ -1259,6 +1294,11 @@ void OculusWorldDemoApp::HmdSensorToggle(OptionVar*)
OVR_ASSERT(false);
}
}
+ else
+ {
+ EnableSensor = false;
+ ovrHmd_ConfigureTracking(Hmd, 0, 0);
+ }
}
void OculusWorldDemoApp::HmdSettingChangeFreeRTs(OptionVar*)
diff --git a/Samples/OculusWorldDemo/OculusWorldDemo.h b/Samples/OculusWorldDemo/OculusWorldDemo.h
index 86f68b0..54a6936 100644
--- a/Samples/OculusWorldDemo/OculusWorldDemo.h
+++ b/Samples/OculusWorldDemo/OculusWorldDemo.h
@@ -136,7 +136,7 @@ public:
bool FrameNeedsRendering(double curtime);
void ApplyDynamicResolutionScaling();
void UpdateFrameRateCounter(double curtime);
-
+ void UpdateVisionProcessingTime(const ovrTrackingState& trackState);
// Model creation and misc functions.
Model* CreateModel(Vector3f pos, struct SlabModel* sm);
@@ -172,9 +172,14 @@ protected:
Sizei WindowSize;
int ScreenNumber;
int FirstScreenInCycle;
-
bool SupportsSrgb;
+ // Last vision processing statistics
+ double LastVisionProcessingTime;
+ int VisionTimesCount;
+ double VisionProcessingSum;
+ double VisionProcessingAverage;
+
struct RenderTarget
{
Ptr<Texture> pTex;
@@ -285,6 +290,7 @@ protected:
bool DisplaySleep;
bool PositionTrackingEnabled;
bool PixelLuminanceOverdrive;
+ bool HqAaDistortion;
bool MirrorToWindow;
// Support toggling background color for distortion so that we can see
diff --git a/Samples/OculusWorldDemo/Projects/Win/VS2010/OculusWorldDemo.vcxproj b/Samples/OculusWorldDemo/Projects/Win/VS2010/OculusWorldDemo.vcxproj
index 1e88967..82576cb 100644
--- a/Samples/OculusWorldDemo/Projects/Win/VS2010/OculusWorldDemo.vcxproj
+++ b/Samples/OculusWorldDemo/Projects/Win/VS2010/OculusWorldDemo.vcxproj
@@ -213,7 +213,6 @@
<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" />
diff --git a/Samples/OculusWorldDemo/Projects/Win/VS2010/OculusWorldDemo.vcxproj.filters b/Samples/OculusWorldDemo/Projects/Win/VS2010/OculusWorldDemo.vcxproj.filters
index de6f19a..bf9274e 100644
--- a/Samples/OculusWorldDemo/Projects/Win/VS2010/OculusWorldDemo.vcxproj.filters
+++ b/Samples/OculusWorldDemo/Projects/Win/VS2010/OculusWorldDemo.vcxproj.filters
@@ -87,7 +87,6 @@
<ClInclude Include="..\..\..\..\CommonSrc\Render\Render_D3D11_Device.h">
<Filter>CommonSrc\Render</Filter>
</ClInclude>
- <ClInclude Include="..\..\3rdParty\TinyXml\tinyxml2.h" />
<ClInclude Include="..\..\..\..\CommonSrc\Render\Render_XmlSceneLoader.h">
<Filter>CommonSrc\Render</Filter>
</ClInclude>
diff --git a/Samples/OculusWorldDemo/Projects/Win/VS2012/OculusWorldDemo.vcxproj b/Samples/OculusWorldDemo/Projects/Win/VS2012/OculusWorldDemo.vcxproj
index 6e60113..e6fdc4a 100644
--- a/Samples/OculusWorldDemo/Projects/Win/VS2012/OculusWorldDemo.vcxproj
+++ b/Samples/OculusWorldDemo/Projects/Win/VS2012/OculusWorldDemo.vcxproj
@@ -219,7 +219,6 @@
<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" />
diff --git a/Samples/OculusWorldDemo/Projects/Win/VS2012/OculusWorldDemo.vcxproj.filters b/Samples/OculusWorldDemo/Projects/Win/VS2012/OculusWorldDemo.vcxproj.filters
index b0127f4..6ab7a7f 100644
--- a/Samples/OculusWorldDemo/Projects/Win/VS2012/OculusWorldDemo.vcxproj.filters
+++ b/Samples/OculusWorldDemo/Projects/Win/VS2012/OculusWorldDemo.vcxproj.filters
@@ -87,7 +87,6 @@
<ClInclude Include="..\..\..\..\CommonSrc\Render\Render_D3D11_Device.h">
<Filter>CommonSrc\Render</Filter>
</ClInclude>
- <ClInclude Include="..\..\3rdParty\TinyXml\tinyxml2.h" />
<ClInclude Include="..\..\..\..\CommonSrc\Render\Render_XmlSceneLoader.h">
<Filter>CommonSrc\Render</Filter>
</ClInclude>
diff --git a/Samples/OculusWorldDemo/Projects/Win/VS2013/OculusWorldDemo.vcxproj b/Samples/OculusWorldDemo/Projects/Win/VS2013/OculusWorldDemo.vcxproj
index 068dc94..549c09e 100644
--- a/Samples/OculusWorldDemo/Projects/Win/VS2013/OculusWorldDemo.vcxproj
+++ b/Samples/OculusWorldDemo/Projects/Win/VS2013/OculusWorldDemo.vcxproj
@@ -223,7 +223,6 @@
<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" />
diff --git a/Samples/OculusWorldDemo/Projects/Win/VS2013/OculusWorldDemo.vcxproj.filters b/Samples/OculusWorldDemo/Projects/Win/VS2013/OculusWorldDemo.vcxproj.filters
index 6fc8094..72ed0d9 100644
--- a/Samples/OculusWorldDemo/Projects/Win/VS2013/OculusWorldDemo.vcxproj.filters
+++ b/Samples/OculusWorldDemo/Projects/Win/VS2013/OculusWorldDemo.vcxproj.filters
@@ -87,7 +87,6 @@
<ClInclude Include="..\..\..\..\CommonSrc\Render\Render_D3D11_Device.h">
<Filter>CommonSrc\Render</Filter>
</ClInclude>
- <ClInclude Include="..\..\3rdParty\TinyXml\tinyxml2.h" />
<ClInclude Include="..\..\..\..\CommonSrc\Render\Render_XmlSceneLoader.h">
<Filter>CommonSrc\Render</Filter>
</ClInclude>