Skip to content

Commit

Permalink
can build now but exception right after launch
Browse files Browse the repository at this point in the history
  • Loading branch information
duchuule committed Jun 8, 2015
1 parent fd42c9a commit 5105c59
Show file tree
Hide file tree
Showing 17 changed files with 372 additions and 371 deletions.
14 changes: 7 additions & 7 deletions Common/DeviceResources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ void DX::DeviceResources::CreateDeviceResources()
// than the API default. It is required for compatibility with Direct2D.
UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;

#if defined(_DEBUG)
if (DX::SdkLayersAvailable())
{
// If the project is in a debug build, enable debugging via SDK Layers with this flag.
creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
}
#endif
//#if defined(_DEBUG)
// if (DX::SdkLayersAvailable())
// {
// // If the project is in a debug build, enable debugging via SDK Layers with this flag.
// creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
// }
//#endif

// This array defines the set of DirectX hardware feature levels this app will support.
// Note the ordering should be preserved.
Expand Down
36 changes: 18 additions & 18 deletions Common/DeviceResources.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace DX
{
// Provides an interface for an application that owns DeviceResources to be notified of the device being lost or created.
// Provides an interface for an application that owns DeviceResources to be notified of the device being lost or created.
interface IDeviceNotify
{
virtual void OnDeviceLost() = 0;
Expand All @@ -26,27 +26,27 @@ namespace DX
void Present();

// Device Accessors.
Windows::Foundation::Size GetOutputSize() const { return m_outputSize; }
Windows::Foundation::Size GetLogicalSize() const { return m_logicalSize; }
Windows::Foundation::Size GetOutputSize() const { return m_outputSize; }
Windows::Foundation::Size GetLogicalSize() const { return m_logicalSize; }

// D3D Accessors.
ID3D11Device2* GetD3DDevice() const { return m_d3dDevice.Get(); }
ID3D11DeviceContext2* GetD3DDeviceContext() const { return m_d3dContext.Get(); }
IDXGISwapChain1* GetSwapChain() const { return m_swapChain.Get(); }
D3D_FEATURE_LEVEL GetDeviceFeatureLevel() const { return m_d3dFeatureLevel; }
ID3D11RenderTargetView* GetBackBufferRenderTargetView() const { return m_d3dRenderTargetView.Get(); }
ID3D11DepthStencilView* GetDepthStencilView() const { return m_d3dDepthStencilView.Get(); }
D3D11_VIEWPORT GetScreenViewport() const { return m_screenViewport; }
DirectX::XMFLOAT4X4 GetOrientationTransform3D() const { return m_orientationTransform3D; }
ID3D11Device2* GetD3DDevice() const { return m_d3dDevice.Get(); }
ID3D11DeviceContext2* GetD3DDeviceContext() const { return m_d3dContext.Get(); }
IDXGISwapChain1* GetSwapChain() const { return m_swapChain.Get(); }
D3D_FEATURE_LEVEL GetDeviceFeatureLevel() const { return m_d3dFeatureLevel; }
ID3D11RenderTargetView* GetBackBufferRenderTargetView() const { return m_d3dRenderTargetView.Get(); }
ID3D11DepthStencilView* GetDepthStencilView() const { return m_d3dDepthStencilView.Get(); }
D3D11_VIEWPORT GetScreenViewport() const { return m_screenViewport; }
DirectX::XMFLOAT4X4 GetOrientationTransform3D() const { return m_orientationTransform3D; }

// D2D Accessors.
ID2D1Factory2* GetD2DFactory() const { return m_d2dFactory.Get(); }
ID2D1Device1* GetD2DDevice() const { return m_d2dDevice.Get(); }
ID2D1DeviceContext1* GetD2DDeviceContext() const { return m_d2dContext.Get(); }
ID2D1Bitmap1* GetD2DTargetBitmap() const { return m_d2dTargetBitmap.Get(); }
IDWriteFactory2* GetDWriteFactory() const { return m_dwriteFactory.Get(); }
IWICImagingFactory2* GetWicImagingFactory() const { return m_wicFactory.Get(); }
D2D1::Matrix3x2F GetOrientationTransform2D() const { return m_orientationTransform2D; }
ID2D1Factory2* GetD2DFactory() const { return m_d2dFactory.Get(); }
ID2D1Device1* GetD2DDevice() const { return m_d2dDevice.Get(); }
ID2D1DeviceContext1* GetD2DDeviceContext() const { return m_d2dContext.Get(); }
ID2D1Bitmap1* GetD2DTargetBitmap() const { return m_d2dTargetBitmap.Get(); }
IDWriteFactory2* GetDWriteFactory() const { return m_dwriteFactory.Get(); }
IWICImagingFactory2* GetWicImagingFactory() const { return m_wicFactory.Get(); }
D2D1::Matrix3x2F GetOrientationTransform2D() const { return m_orientationTransform2D; }

private:
void CreateDeviceIndependentResources();
Expand Down
48 changes: 25 additions & 23 deletions Common/DirectXHelper.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma once

#include <ppltasks.h> // For create_task
//#include <wrl/client.h>
//#include <ppl.h>
#include <ppltasks.h>

namespace DX
{
Expand All @@ -21,10 +23,10 @@ namespace DX

auto folder = Windows::ApplicationModel::Package::Current->InstalledLocation;

return create_task(folder->GetFileAsync(Platform::StringReference(filename.c_str()))).then([] (StorageFile^ file)
return create_task(folder->GetFileAsync(Platform::StringReference(filename.c_str()))).then([](StorageFile^ file)
{
return FileIO::ReadBufferAsync(file);
}).then([] (Streams::IBuffer^ fileBuffer) -> std::vector<byte>
}).then([](Streams::IBuffer^ fileBuffer) -> std::vector<byte>
{
std::vector<byte> returnBuffer;
returnBuffer.resize(fileBuffer->Length);
Expand All @@ -40,24 +42,24 @@ namespace DX
return floorf(dips * dpi / dipsPerInch + 0.5f); // Round to nearest integer.
}

#if defined(_DEBUG)
// Check for SDK Layer support.
inline bool SdkLayersAvailable()
{
HRESULT hr = D3D11CreateDevice(
nullptr,
D3D_DRIVER_TYPE_NULL, // There is no need to create a real hardware device.
0,
D3D11_CREATE_DEVICE_DEBUG, // Check for the SDK layers.
nullptr, // Any feature level will do.
0,
D3D11_SDK_VERSION, // Always set this to D3D11_SDK_VERSION for Windows Store apps.
nullptr, // No need to keep the D3D device reference.
nullptr, // No need to know the feature level.
nullptr // No need to keep the D3D device context reference.
);

return SUCCEEDED(hr);
}
#endif
//#if defined(_DEBUG)
// // Check for SDK Layer support.
// inline bool SdkLayersAvailable()
// {
// HRESULT hr = D3D11CreateDevice(
// nullptr,
// D3D_DRIVER_TYPE_NULL, // There is no need to create a real hardware device.
// 0,
// D3D11_CREATE_DEVICE_DEBUG, // Check for the SDK layers.
// nullptr, // Any feature level will do.
// 0,
// D3D11_SDK_VERSION, // Always set this to D3D11_SDK_VERSION for Windows Store apps.
// nullptr, // No need to keep the D3D device reference.
// nullptr, // No need to know the feature level.
// nullptr // No need to keep the D3D device context reference.
// );
//
// return SUCCEEDED(hr);
// }
//#endif
}
Loading

0 comments on commit 5105c59

Please sign in to comment.