summaryrefslogtreecommitdiff
path: root/sample/d3d11
diff options
context:
space:
mode:
authorJason Maskell <[email protected]>2016-05-31 11:24:52 +0200
committerJason Maskell <[email protected]>2016-05-31 11:24:52 +0200
commit999fd20ca96b8d44d3ce418f118fb3b846038978 (patch)
treefc86969d4eb006f592560e7bd425b9a2db865be2 /sample/d3d11
parentAdded path to opengl media search path. Removed commented out code left over ... (diff)
downloadwaveworks_archive-999fd20ca96b8d44d3ce418f118fb3b846038978.tar.xz
waveworks_archive-999fd20ca96b8d44d3ce418f118fb3b846038978.zip
Added support for RFC 104, the logging interface: https://docs.google.com/document/d/102b8k5pKYj9e-tMmG53aT5izur-qfUSPX1gBro4gN0Q/edit
Added a dumb implementation of the logger in the D3D11 sample. Added a method to the WaveWorks API to allow the user to set (override) the internal logger with their own supplied nv::ILogger derived object.
Diffstat (limited to 'sample/d3d11')
-rw-r--r--sample/d3d11/distance_field.cpp7
-rw-r--r--sample/d3d11/distance_field.h2
-rw-r--r--sample/d3d11/ocean_surface.cpp16
-rw-r--r--sample/d3d11/ocean_surface.h2
-rw-r--r--sample/d3d11/sample_d3d11.cpp18
-rw-r--r--sample/d3d11/terrain.cpp2
6 files changed, 28 insertions, 19 deletions
diff --git a/sample/d3d11/distance_field.cpp b/sample/d3d11/distance_field.cpp
index 61e335b..b660fde 100644
--- a/sample/d3d11/distance_field.cpp
+++ b/sample/d3d11/distance_field.cpp
@@ -286,7 +286,12 @@ float DistanceField::FindNearestPixel( float* pTextureData, const int cx, const
return originPositive ? -minDistance/kMaxDistance : minDistance/kMaxDistance;
}
-void DistanceField::GetWorldToTopDownTextureMatrix( XMMATRIX worldToTopDownMatrix )
+void DistanceField::GetWorldToTopDownTextureMatrix( XMMATRIX &worldToTopDownMatrix )
{
+// XMMATRIX wtvMat, vtpMat;
+//
+// XMLoadFloat4x4(&m_worldToViewMatrix);
+// XMLoadFloat4x4(&m_viewToProjectionMatrix);
+
worldToTopDownMatrix = XMLoadFloat4x4(&m_worldToViewMatrix) * XMLoadFloat4x4(&m_viewToProjectionMatrix);
} \ No newline at end of file
diff --git a/sample/d3d11/distance_field.h b/sample/d3d11/distance_field.h
index 5b2e3a2..a8cbe9b 100644
--- a/sample/d3d11/distance_field.h
+++ b/sample/d3d11/distance_field.h
@@ -43,8 +43,8 @@ struct DistanceField
// --------------------------------- Accessors -----------------------------------
ID3D11ShaderResourceView* GetDataTextureSRV() const { return m_pTopDownDataSRV; }
- void GetWorldToTopDownTextureMatrix( XMMATRIX worldToTopDownMatrix );
+ void GetWorldToTopDownTextureMatrix(XMMATRIX &worldToTopDownMatrix);
// --------------------------------- Rendering routines -----------------------------------
void GenerateDataTexture(ID3D11DeviceContext* pDC );
diff --git a/sample/d3d11/ocean_surface.cpp b/sample/d3d11/ocean_surface.cpp
index 4bd0dc6..3bf11c8 100644
--- a/sample/d3d11/ocean_surface.cpp
+++ b/sample/d3d11/ocean_surface.cpp
@@ -31,10 +31,11 @@
#include "ocean_surface.h"
#include "GFSDK_WaveWorks_D3D_Util.h"
+#include "../common/Logger.h"
+#include "../common/LoggerImpl.h"
#pragma warning(disable:4127)
-
OceanSurface::OceanSurface()
{
m_pOceanFX = NULL;
@@ -72,8 +73,10 @@ OceanSurface::~OceanSurface()
HRESULT OceanSurface::initQuadTree(const GFSDK_WaveWorks_Quadtree_Params& params)
{
+ NV_LOG("Initing the QuadTree");
+
if(NULL == m_hOceanQuadTree)
-{
+ {
return GFSDK_WaveWorks_Quadtree_CreateD3D11(params, m_pd3dDevice, &m_hOceanQuadTree);
}
else
@@ -148,13 +151,10 @@ HRESULT OceanSurface::init()
if(NULL == m_pOceanFX)
{
- ID3DBlob* pEffectBuffer = NULL;
-
TCHAR path[MAX_PATH];
V_RETURN(DXUTFindDXSDKMediaFileCch(path, MAX_PATH, TEXT("ocean_surface_d3d11.fxo")));
- V_RETURN(D3DX11CreateEffectFromFile(path, 0, m_pd3dDevice, &m_pOceanFX));// pEffectBuffer->GetBufferPointer(), pEffectBuffer->GetBufferSize(), 0, pd3dDevice, &g_pEffect));
- SAFE_RELEASE(pEffectBuffer);
+ V_RETURN(D3DX11CreateEffectFromFile(path, 0, m_pd3dDevice, &m_pOceanFX));
// Hook up the shader mappings
@@ -197,7 +197,7 @@ HRESULT OceanSurface::init()
pShadedShoreReflectionHS->Release();
pShadedShoreReflectionDS->Release();
- m_pRenderSurfaceWireframeWithShorelinePass = m_pRenderSurfaceTechnique->GetPassByName("Pass_Wireframe_WithShoreline");
+ //m_pRenderSurfaceWireframeWithShorelinePass = m_pRenderSurfaceTechnique->GetPassByName("Pass_Wireframe_WithShoreline");
}
if(NULL == m_pQuadLayout)
@@ -309,7 +309,7 @@ void OceanSurface::renderShaded( ID3D11DeviceContext* pDC,
m_pOceanFX->GetVariableByName("g_BaseGerstnerWavelength")->AsScalar()->SetFloat( wavelength );
m_pOceanFX->GetVariableByName("g_BaseGerstnerSpeed")->AsScalar()->SetFloat( speed );
m_pOceanFX->GetVariableByName("g_BaseGerstnerParallelness")->AsScalar()->SetFloat( parallelness );
- m_pOceanFX->GetVariableByName("g_WindDirection")->AsVector()->SetFloatVector( &windDir.x );
+ m_pOceanFX->GetVariableByName("g_WindDirection")->AsVector()->SetFloatVector( (FLOAT*) &windDir );
m_pOceanFX->GetVariableByName("g_DataTexture")->AsShaderResource()->SetResource( pDistanceFieldModule->GetDataTextureSRV() );
m_pOceanFX->GetVariableByName("g_Time")->AsScalar()->SetFloat( totalTime );
diff --git a/sample/d3d11/ocean_surface.h b/sample/d3d11/ocean_surface.h
index 5910970..d3b8f00 100644
--- a/sample/d3d11/ocean_surface.h
+++ b/sample/d3d11/ocean_surface.h
@@ -50,7 +50,7 @@ public:
ID3DX11Effect* m_pOceanFX;
ID3DX11EffectTechnique* m_pRenderSurfaceTechnique;
ID3DX11EffectPass* m_pRenderSurfaceShadedWithShorelinePass;
- ID3DX11EffectPass* m_pRenderSurfaceWireframeWithShorelinePass;
+// ID3DX11EffectPass* m_pRenderSurfaceWireframeWithShorelinePass;
ID3D11InputLayout* m_pQuadLayout;
ID3D11InputLayout* m_pRayContactLayout;
diff --git a/sample/d3d11/sample_d3d11.cpp b/sample/d3d11/sample_d3d11.cpp
index 20c2a1c..929ba11 100644
--- a/sample/d3d11/sample_d3d11.cpp
+++ b/sample/d3d11/sample_d3d11.cpp
@@ -46,6 +46,8 @@
#include <locale>
#include <codecvt>
#include <xlocbuf>
+#include "../common/Logger.h"
+#include "../common/LoggerImpl.h"
//#define DEBUG_VS // Uncomment this line to debug vertex shaders
//#define DEBUG_PS // Uncomment this line to debug pixel shaders
@@ -53,8 +55,6 @@
// Disable warning "conditional expression is constant"
#pragma warning(disable:4127)
-extern HRESULT LoadFile(LPCTSTR FileName, ID3DBlob** ppBuffer);
-
//--------------------------------------------------------------------------------------
// Global variables
//--------------------------------------------------------------------------------------
@@ -209,6 +209,12 @@ INT WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR cmdline, int )
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif
+ NV_LOG("Testing!");
+
+ GFSDK_WaveWorks_SetUserLogger(static_cast<nv::ILogger*>(g_Logger));
+
+ NV_LOG("User logger set!");
+
//TODO: Take from cmdline
auto mediaPath = "..\\..\\media\\sample";
@@ -494,10 +500,8 @@ HRESULT CALLBACK OnD3D11CreateDevice( ID3D11Device* pd3dDevice, const DXGI_SURFA
SAFE_RELEASE(pD3D11Resource);
// Terrain and sky fx
- ID3DBlob* pEffectBuffer = NULL;
V_RETURN(DXUTFindDXSDKMediaFileCch(path, MAX_PATH, TEXT("sample_d3d11.fxo")));
- V_RETURN(D3DX11CreateEffectFromFile(path, 0, pd3dDevice, &g_pEffect));// pEffectBuffer->GetBufferPointer(), pEffectBuffer->GetBufferSize(), 0, pd3dDevice, &g_pEffect));
- SAFE_RELEASE(pEffectBuffer);
+ V_RETURN(D3DX11CreateEffectFromFile(path, 0, pd3dDevice, &g_pEffect));
// Initialize shoreline interaction.
g_pDistanceField = new DistanceField( &g_Terrain );
@@ -708,7 +712,7 @@ void CALLBACK OnD3D11FrameRender( ID3D11Device* pd3dDevice, ID3D11DeviceContext*
oceanFX->GetVariableByName("g_ZNear")->AsScalar()->SetFloat(scene_z_near);
oceanFX->GetVariableByName("g_ZFar")->AsScalar()->SetFloat(scene_z_far);
- XMFLOAT3 light_pos = XMFLOAT3(140000.0f,65000.0f,40000.0f);
+ XMFLOAT4 light_pos = XMFLOAT4(140000.0f,65000.0f,40000.0f,0);
g_pEffect->GetVariableByName("g_LightPosition")->AsVector()->SetFloatVector((FLOAT*)&light_pos);
g_pEffect->GetVariableByName("g_ScreenSizeInv")->AsVector()->SetFloatVector((FLOAT*)&ScreenSizeInv);
oceanFX->GetVariableByName("g_ScreenSizeInv")->AsVector()->SetFloatVector((FLOAT*)&ScreenSizeInv);
@@ -722,7 +726,7 @@ void CALLBACK OnD3D11FrameRender( ID3D11Device* pd3dDevice, ID3D11DeviceContext*
- RenderLogo(pDC);
+ //RenderLogo(pDC);
if(g_bShowUI) {
diff --git a/sample/d3d11/terrain.cpp b/sample/d3d11/terrain.cpp
index d52059b..32356db 100644
--- a/sample/d3d11/terrain.cpp
+++ b/sample/d3d11/terrain.cpp
@@ -955,7 +955,7 @@ HRESULT CTerrain::LoadTextures()
V_RETURN(DirectX::CreateDDSTextureFromFile(pDevice, static_cast<const wchar_t *>(path), &pD3D11Resource, &foam_intensity_textureSRV));
SAFE_RELEASE(pD3D11Resource);
- V_RETURN(DXUTFindDXSDKMediaFileCch(path, MAX_PATH, TEXT("foam.dds")));
+ V_RETURN(DXUTFindDXSDKMediaFileCch(path, MAX_PATH, TEXT("foam24bit.dds")));
V_RETURN(DirectX::CreateDDSTextureFromFile(pDevice, static_cast<const wchar_t *>(path), &pD3D11Resource, &foam_diffuse_textureSRV));
SAFE_RELEASE(pD3D11Resource);