diff options
| author | mtamis <[email protected]> | 2017-02-28 18:24:59 +0100 |
|---|---|---|
| committer | mtamis <[email protected]> | 2017-02-28 18:24:59 +0100 |
| commit | 5581909a4d19db97304449f66404ff99a0429d3f (patch) | |
| tree | a90f7eb85c095a8aba45cf5e909c82c1cdbed77d /NvCloth/samples/external/DXUT | |
| parent | Fix cmake visual studio project generation (locate_gw_root.bat) (diff) | |
| download | nvcloth-5581909a4d19db97304449f66404ff99a0429d3f.tar.xz nvcloth-5581909a4d19db97304449f66404ff99a0429d3f.zip | |
Add visual samples.
Diffstat (limited to 'NvCloth/samples/external/DXUT')
82 files changed, 4052 insertions, 0 deletions
diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2013/Win32/Debug/DXUT.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2013/Win32/Debug/DXUT.lib Binary files differnew file mode 100644 index 0000000..4b07cc7 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2013/Win32/Debug/DXUT.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2013/Win32/Debug/dxut.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2013/Win32/Debug/dxut.pdb Binary files differnew file mode 100644 index 0000000..3706a90 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2013/Win32/Debug/dxut.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2013/Win32/Release/DXUT.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2013/Win32/Release/DXUT.lib Binary files differnew file mode 100644 index 0000000..3f08396 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2013/Win32/Release/DXUT.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2013/Win32/Release/dxut.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2013/Win32/Release/dxut.pdb Binary files differnew file mode 100644 index 0000000..d518e74 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2013/Win32/Release/dxut.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2013/x64/Debug/DXUT.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2013/x64/Debug/DXUT.lib Binary files differnew file mode 100644 index 0000000..fa3ac34 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2013/x64/Debug/DXUT.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2013/x64/Debug/dxut.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2013/x64/Debug/dxut.pdb Binary files differnew file mode 100644 index 0000000..1f6d382 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2013/x64/Debug/dxut.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2013/x64/Release/DXUT.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2013/x64/Release/DXUT.lib Binary files differnew file mode 100644 index 0000000..b256786 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2013/x64/Release/DXUT.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2013/x64/Release/dxut.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2013/x64/Release/dxut.pdb Binary files differnew file mode 100644 index 0000000..cef2b95 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2013/x64/Release/dxut.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2015/Win32/Debug/DXUT.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2015/Win32/Debug/DXUT.lib Binary files differnew file mode 100644 index 0000000..df8d5de --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2015/Win32/Debug/DXUT.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2015/Win32/Debug/DXUT.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2015/Win32/Debug/DXUT.pdb Binary files differnew file mode 100644 index 0000000..23fc237 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2015/Win32/Debug/DXUT.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2015/Win32/Release/DXUT.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2015/Win32/Release/DXUT.lib Binary files differnew file mode 100644 index 0000000..8a0fa77 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2015/Win32/Release/DXUT.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2015/Win32/Release/DXUT.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2015/Win32/Release/DXUT.pdb Binary files differnew file mode 100644 index 0000000..a573d76 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2015/Win32/Release/DXUT.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2015/x64/Debug/DXUT.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2015/x64/Debug/DXUT.lib Binary files differnew file mode 100644 index 0000000..61396f7 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2015/x64/Debug/DXUT.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2015/x64/Debug/DXUT.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2015/x64/Debug/DXUT.pdb Binary files differnew file mode 100644 index 0000000..0a3ab9d --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2015/x64/Debug/DXUT.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2015/x64/Release/DXUT.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2015/x64/Release/DXUT.lib Binary files differnew file mode 100644 index 0000000..ae3bbdc --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2015/x64/Release/DXUT.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2015/x64/Release/DXUT.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2015/x64/Release/DXUT.pdb Binary files differnew file mode 100644 index 0000000..b1fba2f --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/dynamiccrt/vs2015/x64/Release/DXUT.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2013/Win32/Debug/DXUT.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2013/Win32/Debug/DXUT.lib Binary files differnew file mode 100644 index 0000000..78ac45e --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2013/Win32/Debug/DXUT.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2013/Win32/Debug/dxut.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2013/Win32/Debug/dxut.pdb Binary files differnew file mode 100644 index 0000000..f6ab878 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2013/Win32/Debug/dxut.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2013/Win32/Release/DXUT.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2013/Win32/Release/DXUT.lib Binary files differnew file mode 100644 index 0000000..c056849 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2013/Win32/Release/DXUT.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2013/Win32/Release/dxut.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2013/Win32/Release/dxut.pdb Binary files differnew file mode 100644 index 0000000..9df7c09 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2013/Win32/Release/dxut.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2013/x64/Debug/DXUT.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2013/x64/Debug/DXUT.lib Binary files differnew file mode 100644 index 0000000..8d6b78e --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2013/x64/Debug/DXUT.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2013/x64/Debug/dxut.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2013/x64/Debug/dxut.pdb Binary files differnew file mode 100644 index 0000000..124dca8 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2013/x64/Debug/dxut.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2013/x64/Release/DXUT.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2013/x64/Release/DXUT.lib Binary files differnew file mode 100644 index 0000000..a6d75b1 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2013/x64/Release/DXUT.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2013/x64/Release/dxut.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2013/x64/Release/dxut.pdb Binary files differnew file mode 100644 index 0000000..64a0479 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2013/x64/Release/dxut.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2015/Win32/Debug/DXUT.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2015/Win32/Debug/DXUT.lib Binary files differnew file mode 100644 index 0000000..29d1418 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2015/Win32/Debug/DXUT.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2015/Win32/Debug/DXUT.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2015/Win32/Debug/DXUT.pdb Binary files differnew file mode 100644 index 0000000..ce70c1e --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2015/Win32/Debug/DXUT.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2015/Win32/Release/DXUT.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2015/Win32/Release/DXUT.lib Binary files differnew file mode 100644 index 0000000..6e1b231 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2015/Win32/Release/DXUT.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2015/Win32/Release/DXUT.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2015/Win32/Release/DXUT.pdb Binary files differnew file mode 100644 index 0000000..d273b05 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2015/Win32/Release/DXUT.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2015/x64/Debug/DXUT.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2015/x64/Debug/DXUT.lib Binary files differnew file mode 100644 index 0000000..a02da67 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2015/x64/Debug/DXUT.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2015/x64/Debug/DXUT.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2015/x64/Debug/DXUT.pdb Binary files differnew file mode 100644 index 0000000..0e1b4c5 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2015/x64/Debug/DXUT.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2015/x64/Release/DXUT.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2015/x64/Release/DXUT.lib Binary files differnew file mode 100644 index 0000000..50bc741 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2015/x64/Release/DXUT.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2015/x64/Release/DXUT.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2015/x64/Release/DXUT.pdb Binary files differnew file mode 100644 index 0000000..5a620f6 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/Bin/staticcrt/vs2015/x64/Release/DXUT.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/DDSTextureLoader.h b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/DDSTextureLoader.h new file mode 100644 index 0000000..122df9f --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/DDSTextureLoader.h @@ -0,0 +1,133 @@ +//-------------------------------------------------------------------------------------- +// File: DDSTextureLoader.h +// +// Functions for loading a DDS texture and creating a Direct3D 11 runtime resource for it +// +// Note these functions are useful as a light-weight runtime loader for DDS files. For +// a full-featured DDS file reader, writer, and texture processing pipeline see +// the 'Texconv' sample and the 'DirectXTex' library. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248926 +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#include <d3d11_1.h> +#include <stdint.h> + + +namespace DirectX +{ + enum DDS_ALPHA_MODE + { + DDS_ALPHA_MODE_UNKNOWN = 0, + DDS_ALPHA_MODE_STRAIGHT = 1, + DDS_ALPHA_MODE_PREMULTIPLIED = 2, + DDS_ALPHA_MODE_OPAQUE = 3, + DDS_ALPHA_MODE_CUSTOM = 4, + }; + + // Standard version + HRESULT CreateDDSTextureFromMemory( _In_ ID3D11Device* d3dDevice, + _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, + _In_ size_t ddsDataSize, + _Outptr_opt_ ID3D11Resource** texture, + _Outptr_opt_ ID3D11ShaderResourceView** textureView, + _In_ size_t maxsize = 0, + _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr + ); + + HRESULT CreateDDSTextureFromFile( _In_ ID3D11Device* d3dDevice, + _In_z_ const wchar_t* szFileName, + _Outptr_opt_ ID3D11Resource** texture, + _Outptr_opt_ ID3D11ShaderResourceView** textureView, + _In_ size_t maxsize = 0, + _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr + ); + + // Standard version with optional auto-gen mipmap support + HRESULT CreateDDSTextureFromMemory( _In_ ID3D11Device* d3dDevice, + _In_opt_ ID3D11DeviceContext* d3dContext, + _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, + _In_ size_t ddsDataSize, + _Outptr_opt_ ID3D11Resource** texture, + _Outptr_opt_ ID3D11ShaderResourceView** textureView, + _In_ size_t maxsize = 0, + _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr + ); + + HRESULT CreateDDSTextureFromFile( _In_ ID3D11Device* d3dDevice, + _In_opt_ ID3D11DeviceContext* d3dContext, + _In_z_ const wchar_t* szFileName, + _Outptr_opt_ ID3D11Resource** texture, + _Outptr_opt_ ID3D11ShaderResourceView** textureView, + _In_ size_t maxsize = 0, + _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr + ); + + // Extended version + HRESULT CreateDDSTextureFromMemoryEx( _In_ ID3D11Device* d3dDevice, + _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, + _In_ size_t ddsDataSize, + _In_ size_t maxsize, + _In_ D3D11_USAGE usage, + _In_ unsigned int bindFlags, + _In_ unsigned int cpuAccessFlags, + _In_ unsigned int miscFlags, + _In_ bool forceSRGB, + _Outptr_opt_ ID3D11Resource** texture, + _Outptr_opt_ ID3D11ShaderResourceView** textureView, + _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr + ); + + HRESULT CreateDDSTextureFromFileEx( _In_ ID3D11Device* d3dDevice, + _In_z_ const wchar_t* szFileName, + _In_ size_t maxsize, + _In_ D3D11_USAGE usage, + _In_ unsigned int bindFlags, + _In_ unsigned int cpuAccessFlags, + _In_ unsigned int miscFlags, + _In_ bool forceSRGB, + _Outptr_opt_ ID3D11Resource** texture, + _Outptr_opt_ ID3D11ShaderResourceView** textureView, + _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr + ); + + // Extended version with optional auto-gen mipmap support + HRESULT CreateDDSTextureFromMemoryEx( _In_ ID3D11Device* d3dDevice, + _In_opt_ ID3D11DeviceContext* d3dContext, + _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, + _In_ size_t ddsDataSize, + _In_ size_t maxsize, + _In_ D3D11_USAGE usage, + _In_ unsigned int bindFlags, + _In_ unsigned int cpuAccessFlags, + _In_ unsigned int miscFlags, + _In_ bool forceSRGB, + _Outptr_opt_ ID3D11Resource** texture, + _Outptr_opt_ ID3D11ShaderResourceView** textureView, + _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr + ); + + HRESULT CreateDDSTextureFromFileEx( _In_ ID3D11Device* d3dDevice, + _In_opt_ ID3D11DeviceContext* d3dContext, + _In_z_ const wchar_t* szFileName, + _In_ size_t maxsize, + _In_ D3D11_USAGE usage, + _In_ unsigned int bindFlags, + _In_ unsigned int cpuAccessFlags, + _In_ unsigned int miscFlags, + _In_ bool forceSRGB, + _Outptr_opt_ ID3D11Resource** texture, + _Outptr_opt_ ID3D11ShaderResourceView** textureView, + _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr + ); +}
\ No newline at end of file diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/DXUT.h b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/DXUT.h new file mode 100644 index 0000000..fc6247e --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/DXUT.h @@ -0,0 +1,341 @@ +//-------------------------------------------------------------------------------------- +// File: DXUT.h +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=320437 +//-------------------------------------------------------------------------------------- +#pragma once + +#ifndef UNICODE +#error "DXUT requires a Unicode build." +#endif + +#ifndef STRICT +#define STRICT +#endif + +// If app hasn't choosen, set to work with Windows Vista and beyond +#ifndef WINVER +#define WINVER 0x0600 +#endif +#ifndef _WIN32_WINDOWS +#define _WIN32_WINDOWS 0x0600 +#endif +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0600 +#endif + +#if (_WIN32_WINNT >= 0x0A00) && !defined(USE_DIRECT3D11_3) +#define USE_DIRECT3D11_3 +#endif + +#if (_WIN32_WINNT >= 0x0603) && !defined(USE_DIRECT3D11_2) +#define USE_DIRECT3D11_2 +#endif + +#if defined(USE_DIRECT3D11_3) && !defined(USE_DIRECT3D11_2) +#define USE_DIRECT3D11_2 +#endif + +// #define DXUT_AUTOLIB to automatically include the libs needed for DXUT +#ifdef DXUT_AUTOLIB +#pragma comment( lib, "comctl32.lib" ) +#pragma comment( lib, "dxguid.lib" ) +#pragma comment( lib, "d3dcompiler.lib" ) +#pragma comment( lib, "ole32.lib" ) +#pragma comment( lib, "uuid.lib" ) +#endif + +#pragma warning( disable : 4481 ) + +// Standard Windows includes +#if !defined(NOMINMAX) +#define NOMINMAX +#endif + +#include <windows.h> +#include <initguid.h> +#include <assert.h> +#include <commctrl.h> // for InitCommonControls() +#include <shellapi.h> // for ExtractIcon() +#include <new.h> // for placement new +#include <shlobj.h> +#include <math.h> +#include <limits.h> +#include <stdio.h> + +// CRT's memory leak detection +#if defined(DEBUG) || defined(_DEBUG) +#include <crtdbg.h> +#endif + +// Direct3D11 includes +#include <d3dcommon.h> +#include <dxgi.h> +#include <d3d11_1.h> +#include <d3dcompiler.h> + +#ifdef USE_DIRECT3D11_2 +#include <d3d11_2.h> +#endif + +#ifdef USE_DIRECT3D11_3 +#include <d3d11_3.h> +#endif + +// DirectXMath includes +#include <DirectXMath.h> +#include <DirectXColors.h> + +// WIC includes +#include <wincodec.h> + +// XInput includes +#include <xinput.h> + +// HRESULT translation for Direct3D and other APIs +#include "dxerr.h" + +// STL includes +#include <algorithm> +#include <memory> +#include <vector> + +#if defined(DEBUG) || defined(_DEBUG) +#ifndef V +#define V(x) { hr = (x); if( FAILED(hr) ) { DXUTTrace( __FILE__, (DWORD)__LINE__, hr, L#x, true ); } } +#endif +#ifndef V_RETURN +#define V_RETURN(x) { hr = (x); if( FAILED(hr) ) { return DXUTTrace( __FILE__, (DWORD)__LINE__, hr, L#x, true ); } } +#endif +#else +#ifndef V +#define V(x) { hr = (x); } +#endif +#ifndef V_RETURN +#define V_RETURN(x) { hr = (x); if( FAILED(hr) ) { return hr; } } +#endif +#endif + +#ifndef SAFE_DELETE +#define SAFE_DELETE(p) { if (p) { delete (p); (p) = nullptr; } } +#endif +#ifndef SAFE_DELETE_ARRAY +#define SAFE_DELETE_ARRAY(p) { if (p) { delete[] (p); (p) = nullptr; } } +#endif +#ifndef SAFE_RELEASE +#define SAFE_RELEASE(p) { if (p) { (p)->Release(); (p) = nullptr; } } +#endif + +#ifndef D3DCOLOR_ARGB +#define D3DCOLOR_ARGB(a,r,g,b) \ + ((DWORD)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff))) +#endif + +#define DXUT_VERSION 1114 + +//-------------------------------------------------------------------------------------- +// Structs +//-------------------------------------------------------------------------------------- +struct DXUTD3D11DeviceSettings +{ + UINT AdapterOrdinal; + D3D_DRIVER_TYPE DriverType; + UINT Output; + DXGI_SWAP_CHAIN_DESC sd; + UINT32 CreateFlags; + UINT32 SyncInterval; + DWORD PresentFlags; + bool AutoCreateDepthStencil; // DXUT will create the depth stencil resource and view if true + DXGI_FORMAT AutoDepthStencilFormat; + D3D_FEATURE_LEVEL DeviceFeatureLevel; +}; + +struct DXUTDeviceSettings +{ + D3D_FEATURE_LEVEL MinimumFeatureLevel; + DXUTD3D11DeviceSettings d3d11; +}; + + +//-------------------------------------------------------------------------------------- +// Error codes +//-------------------------------------------------------------------------------------- +#define DXUTERR_NODIRECT3D MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0901) +#define DXUTERR_NOCOMPATIBLEDEVICES MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0902) +#define DXUTERR_MEDIANOTFOUND MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0903) +#define DXUTERR_NONZEROREFCOUNT MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0904) +#define DXUTERR_CREATINGDEVICE MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0905) +#define DXUTERR_RESETTINGDEVICE MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0906) +#define DXUTERR_CREATINGDEVICEOBJECTS MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0907) +#define DXUTERR_RESETTINGDEVICEOBJECTS MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0908) +#define DXUTERR_DEVICEREMOVED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x090A) + + +//-------------------------------------------------------------------------------------- +// Callback registration +//-------------------------------------------------------------------------------------- + +// General callbacks +typedef void (CALLBACK *LPDXUTCALLBACKFRAMEMOVE)( _In_ double fTime, _In_ float fElapsedTime, _In_opt_ void* pUserContext ); +typedef void (CALLBACK *LPDXUTCALLBACKKEYBOARD)( _In_ UINT nChar, _In_ bool bKeyDown, _In_ bool bAltDown, _In_opt_ void* pUserContext ); +typedef void (CALLBACK *LPDXUTCALLBACKMOUSE)( _In_ bool bLeftButtonDown, _In_ bool bRightButtonDown, _In_ bool bMiddleButtonDown, + _In_ bool bSideButton1Down, _In_ bool bSideButton2Down, _In_ int nMouseWheelDelta, + _In_ int xPos, _In_ int yPos, _In_opt_ void* pUserContext ); +typedef LRESULT (CALLBACK *LPDXUTCALLBACKMSGPROC)( _In_ HWND hWnd, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam, + _Out_ bool* pbNoFurtherProcessing, _In_opt_ void* pUserContext ); +typedef void (CALLBACK *LPDXUTCALLBACKTIMER)( _In_ UINT idEvent, _In_opt_ void* pUserContext ); +typedef bool (CALLBACK *LPDXUTCALLBACKMODIFYDEVICESETTINGS)( _In_ DXUTDeviceSettings* pDeviceSettings, _In_opt_ void* pUserContext ); +typedef bool (CALLBACK *LPDXUTCALLBACKDEVICEREMOVED)( _In_opt_ void* pUserContext ); + +class CD3D11EnumAdapterInfo; +class CD3D11EnumDeviceInfo; + +// Direct3D 11 callbacks +typedef bool (CALLBACK *LPDXUTCALLBACKISD3D11DEVICEACCEPTABLE)( _In_ const CD3D11EnumAdapterInfo *AdapterInfo, _In_ UINT Output, _In_ const CD3D11EnumDeviceInfo *DeviceInfo, + _In_ DXGI_FORMAT BackBufferFormat, _In_ bool bWindowed, _In_opt_ void* pUserContext ); +typedef HRESULT (CALLBACK *LPDXUTCALLBACKD3D11DEVICECREATED)( _In_ ID3D11Device* pd3dDevice, _In_ const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc, _In_opt_ void* pUserContext ); +typedef HRESULT (CALLBACK *LPDXUTCALLBACKD3D11SWAPCHAINRESIZED)( _In_ ID3D11Device* pd3dDevice, _In_ IDXGISwapChain *pSwapChain, _In_ const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc, _In_opt_ void* pUserContext ); +typedef void (CALLBACK *LPDXUTCALLBACKD3D11FRAMERENDER)( _In_ ID3D11Device* pd3dDevice, _In_ ID3D11DeviceContext* pd3dImmediateContext, _In_ double fTime, _In_ float fElapsedTime, _In_opt_ void* pUserContext ); +typedef void (CALLBACK *LPDXUTCALLBACKD3D11SWAPCHAINRELEASING)( _In_opt_ void* pUserContext ); +typedef void (CALLBACK *LPDXUTCALLBACKD3D11DEVICEDESTROYED)( _In_opt_ void* pUserContext ); + +// General callbacks +void WINAPI DXUTSetCallbackFrameMove( _In_ LPDXUTCALLBACKFRAMEMOVE pCallback, _In_opt_ void* pUserContext = nullptr ); +void WINAPI DXUTSetCallbackKeyboard( _In_ LPDXUTCALLBACKKEYBOARD pCallback, _In_opt_ void* pUserContext = nullptr ); +void WINAPI DXUTSetCallbackMouse( _In_ LPDXUTCALLBACKMOUSE pCallback, bool bIncludeMouseMove = false, _In_opt_ void* pUserContext = nullptr ); +void WINAPI DXUTSetCallbackMsgProc( _In_ LPDXUTCALLBACKMSGPROC pCallback, _In_opt_ void* pUserContext = nullptr ); +void WINAPI DXUTSetCallbackDeviceChanging( _In_ LPDXUTCALLBACKMODIFYDEVICESETTINGS pCallback, _In_opt_ void* pUserContext = nullptr ); +void WINAPI DXUTSetCallbackDeviceRemoved( _In_ LPDXUTCALLBACKDEVICEREMOVED pCallback, _In_opt_ void* pUserContext = nullptr ); + +// Direct3D 11 callbacks +void WINAPI DXUTSetCallbackD3D11DeviceAcceptable( _In_ LPDXUTCALLBACKISD3D11DEVICEACCEPTABLE pCallback, _In_opt_ void* pUserContext = nullptr ); +void WINAPI DXUTSetCallbackD3D11DeviceCreated( _In_ LPDXUTCALLBACKD3D11DEVICECREATED pCallback, _In_opt_ void* pUserContext = nullptr ); +void WINAPI DXUTSetCallbackD3D11SwapChainResized( _In_ LPDXUTCALLBACKD3D11SWAPCHAINRESIZED pCallback, _In_opt_ void* pUserContext = nullptr ); +void WINAPI DXUTSetCallbackD3D11FrameRender( _In_ LPDXUTCALLBACKD3D11FRAMERENDER pCallback, _In_opt_ void* pUserContext = nullptr ); +void WINAPI DXUTSetCallbackD3D11SwapChainReleasing( _In_ LPDXUTCALLBACKD3D11SWAPCHAINRELEASING pCallback, _In_opt_ void* pUserContext = nullptr ); +void WINAPI DXUTSetCallbackD3D11DeviceDestroyed( _In_ LPDXUTCALLBACKD3D11DEVICEDESTROYED pCallback, _In_opt_ void* pUserContext = nullptr ); + + +//-------------------------------------------------------------------------------------- +// Initialization +//-------------------------------------------------------------------------------------- +HRESULT WINAPI DXUTInit( _In_ bool bParseCommandLine = true, + _In_ bool bShowMsgBoxOnError = true, + _In_opt_ WCHAR* strExtraCommandLineParams = nullptr, + _In_ bool bThreadSafeDXUT = false ); + +// Choose either DXUTCreateWindow or DXUTSetWindow. If using DXUTSetWindow, consider using DXUTStaticWndProc +HRESULT WINAPI DXUTCreateWindow( _In_z_ const WCHAR* strWindowTitle = L"Direct3D Window", + _In_opt_ HINSTANCE hInstance = nullptr, _In_opt_ HICON hIcon = nullptr, _In_opt_ HMENU hMenu = nullptr, + _In_ int x = CW_USEDEFAULT, _In_ int y = CW_USEDEFAULT ); +HRESULT WINAPI DXUTSetWindow( _In_ HWND hWndFocus, _In_ HWND hWndDeviceFullScreen, _In_ HWND hWndDeviceWindowed, _In_ bool bHandleMessages = true ); +LRESULT CALLBACK DXUTStaticWndProc( _In_ HWND hWnd, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ); + +// Choose either DXUTCreateDevice or DXUTCreateD3DDeviceFromSettings + +HRESULT WINAPI DXUTCreateDevice(_In_ D3D_FEATURE_LEVEL reqFL, _In_ bool bWindowed= true, _In_ int nSuggestedWidth =0,_In_ int nSuggestedHeight =0 ); +HRESULT WINAPI DXUTCreateDeviceFromSettings( _In_ DXUTDeviceSettings* pDeviceSettings, _In_ bool bClipWindowToSingleAdapter = true ); + +// Choose either DXUTMainLoop or implement your own main loop +HRESULT WINAPI DXUTMainLoop( _In_opt_ HACCEL hAccel = nullptr ); + +// If not using DXUTMainLoop consider using DXUTRender3DEnvironment +void WINAPI DXUTRender3DEnvironment(); + + +//-------------------------------------------------------------------------------------- +// Common Tasks +//-------------------------------------------------------------------------------------- +HRESULT WINAPI DXUTToggleFullScreen(); +HRESULT WINAPI DXUTToggleREF(); +HRESULT WINAPI DXUTToggleWARP(); +void WINAPI DXUTPause( _In_ bool bPauseTime, _In_ bool bPauseRendering ); +void WINAPI DXUTSetConstantFrameTime( _In_ bool bConstantFrameTime, _In_ float fTimePerFrame = 0.0333f ); +void WINAPI DXUTSetCursorSettings( _In_ bool bShowCursorWhenFullScreen = false, _In_ bool bClipCursorWhenFullScreen = false ); +void WINAPI DXUTSetHotkeyHandling( _In_ bool bAltEnterToToggleFullscreen = true, _In_ bool bEscapeToQuit = true, _In_ bool bPauseToToggleTimePause = true ); +void WINAPI DXUTSetMultimonSettings( _In_ bool bAutoChangeAdapter = true ); +void WINAPI DXUTSetShortcutKeySettings( _In_ bool bAllowWhenFullscreen = false, _In_ bool bAllowWhenWindowed = true ); // Controls the Windows key, and accessibility shortcut keys +void WINAPI DXUTSetWindowSettings( _In_ bool bCallDefWindowProc = true ); +HRESULT WINAPI DXUTSetTimer( _In_ LPDXUTCALLBACKTIMER pCallbackTimer, _In_ float fTimeoutInSecs = 1.0f, _Out_opt_ UINT* pnIDEvent = nullptr, _In_opt_ void* pCallbackUserContext = nullptr ); +HRESULT WINAPI DXUTKillTimer( _In_ UINT nIDEvent ); +void WINAPI DXUTResetFrameworkState(); +void WINAPI DXUTShutdown( _In_ int nExitCode = 0 ); +void WINAPI DXUTSetIsInGammaCorrectMode( _In_ bool bGammaCorrect ); +bool WINAPI DXUTGetMSAASwapChainCreated(); + + +//-------------------------------------------------------------------------------------- +// State Retrieval +//-------------------------------------------------------------------------------------- + +// Direct3D 11.x (These do not addref unlike typical Get* APIs) +IDXGIFactory1* WINAPI DXUTGetDXGIFactory(); +IDXGISwapChain* WINAPI DXUTGetDXGISwapChain(); +const DXGI_SURFACE_DESC* WINAPI DXUTGetDXGIBackBufferSurfaceDesc(); +HRESULT WINAPI DXUTSetupD3D11Views( _In_ ID3D11DeviceContext* pd3dDeviceContext ); // Supports immediate or deferred context +D3D_FEATURE_LEVEL WINAPI DXUTGetD3D11DeviceFeatureLevel(); // Returns the D3D11 devices current feature level +ID3D11RenderTargetView* WINAPI DXUTGetD3D11RenderTargetView(); +ID3D11DepthStencilView* WINAPI DXUTGetD3D11DepthStencilView(); + +ID3D11Device* WINAPI DXUTGetD3D11Device(); +ID3D11DeviceContext* WINAPI DXUTGetD3D11DeviceContext(); + +ID3D11Device1* WINAPI DXUTGetD3D11Device1(); +ID3D11DeviceContext1* WINAPI DXUTGetD3D11DeviceContext1(); + +#ifdef USE_DIRECT3D11_2 +ID3D11Device2* WINAPI DXUTGetD3D11Device2(); +ID3D11DeviceContext2* WINAPI DXUTGetD3D11DeviceContext2(); +#endif + +#ifdef USE_DIRECT3D11_3 +ID3D11Device3* WINAPI DXUTGetD3D11Device3(); +ID3D11DeviceContext3* WINAPI DXUTGetD3D11DeviceContext3(); +#endif + +// General +DXUTDeviceSettings WINAPI DXUTGetDeviceSettings(); +HINSTANCE WINAPI DXUTGetHINSTANCE(); +HWND WINAPI DXUTGetHWND(); +HWND WINAPI DXUTGetHWNDFocus(); +HWND WINAPI DXUTGetHWNDDeviceFullScreen(); +HWND WINAPI DXUTGetHWNDDeviceWindowed(); +RECT WINAPI DXUTGetWindowClientRect(); +LONG WINAPI DXUTGetWindowWidth(); +LONG WINAPI DXUTGetWindowHeight(); +RECT WINAPI DXUTGetWindowClientRectAtModeChange(); // Useful for returning to windowed mode with the same resolution as before toggle to full screen mode +RECT WINAPI DXUTGetFullsceenClientRectAtModeChange(); // Useful for returning to full screen mode with the same resolution as before toggle to windowed mode +double WINAPI DXUTGetTime(); +float WINAPI DXUTGetElapsedTime(); +bool WINAPI DXUTIsWindowed(); +bool WINAPI DXUTIsInGammaCorrectMode(); +float WINAPI DXUTGetFPS(); +LPCWSTR WINAPI DXUTGetWindowTitle(); +LPCWSTR WINAPI DXUTGetFrameStats( _In_ bool bIncludeFPS = false ); +LPCWSTR WINAPI DXUTGetDeviceStats(); + +bool WINAPI DXUTIsVsyncEnabled(); +bool WINAPI DXUTIsRenderingPaused(); +bool WINAPI DXUTIsTimePaused(); +bool WINAPI DXUTIsActive(); +int WINAPI DXUTGetExitCode(); +bool WINAPI DXUTGetShowMsgBoxOnError(); +bool WINAPI DXUTGetAutomation(); // Returns true if -automation parameter is used to launch the app +bool WINAPI DXUTIsKeyDown( _In_ BYTE vKey ); // Pass a virtual-key code, ex. VK_F1, 'A', VK_RETURN, VK_LSHIFT, etc +bool WINAPI DXUTWasKeyPressed( _In_ BYTE vKey ); // Like DXUTIsKeyDown() but return true only if the key was just pressed +bool WINAPI DXUTIsMouseButtonDown( _In_ BYTE vButton ); // Pass a virtual-key code: VK_LBUTTON, VK_RBUTTON, VK_MBUTTON, VK_XBUTTON1, VK_XBUTTON2 +HRESULT WINAPI DXUTCreateState(); // Optional method to create DXUT's memory. If its not called by the application it will be automatically called when needed +void WINAPI DXUTDestroyState(); // Optional method to destroy DXUT's memory. If its not called by the application it will be automatically called after the application exits WinMain + +//-------------------------------------------------------------------------------------- +// DXUT core layer includes +//-------------------------------------------------------------------------------------- +#include "DXUTmisc.h" +#include "DXUTDevice11.h" diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/DXUTDevice11.h b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/DXUTDevice11.h new file mode 100644 index 0000000..1e38a63 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/DXUTDevice11.h @@ -0,0 +1,210 @@ +//-------------------------------------------------------------------------------------- +// File: DXUTDevice11.h +// +// Enumerates D3D adapters, devices, modes, etc. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=320437 +//-------------------------------------------------------------------------------------- +#pragma once + +void DXUTApplyDefaultDeviceSettings(DXUTDeviceSettings *modifySettings); + +//-------------------------------------------------------------------------------------- +// Functions to get bit depth from formats +//-------------------------------------------------------------------------------------- +HRESULT WINAPI DXUTGetD3D11AdapterDisplayMode( _In_ UINT AdapterOrdinal, _In_ UINT Output, _Out_ DXGI_MODE_DESC* pModeDesc ); + + + + +//-------------------------------------------------------------------------------------- +// Optional memory create/destory functions. If not call, these will be called automatically +//-------------------------------------------------------------------------------------- +HRESULT WINAPI DXUTCreateD3D11Enumeration(); +void WINAPI DXUTDestroyD3D11Enumeration(); + + + + +//-------------------------------------------------------------------------------------- +// Forward declarations +//-------------------------------------------------------------------------------------- +class CD3D11EnumAdapterInfo; +class CD3D11EnumDeviceInfo; +class CD3D11EnumOutputInfo; +struct CD3D11EnumDeviceSettingsCombo; + + + +//-------------------------------------------------------------------------------------- +// Enumerates available Direct3D11 adapters, devices, modes, etc. +//-------------------------------------------------------------------------------------- +class CD3D11Enumeration +{ +public: + // These should be called before Enumerate(). + // + // Use these calls and the IsDeviceAcceptable to control the contents of + // the enumeration object, which affects the device selection and the device settings dialog. + void SetResolutionMinMax( _In_ UINT nMinWidth, _In_ UINT nMinHeight, _In_ UINT nMaxWidth, _In_ UINT nMaxHeight ); + void SetRefreshMinMax( _In_ UINT nMin, _In_ UINT nMax ); + void SetForceFeatureLevel( _In_ D3D_FEATURE_LEVEL forceFL) { m_forceFL = forceFL; } + void SetMultisampleQualityMax( _In_ UINT nMax ); + void ResetPossibleDepthStencilFormats(); + void SetEnumerateAllAdapterFormats( _In_ bool bEnumerateAllAdapterFormats ); + + // Call Enumerate() to enumerate available D3D11 adapters, devices, modes, etc. + bool HasEnumerated() { return m_bHasEnumerated; } + HRESULT Enumerate( _In_ LPDXUTCALLBACKISD3D11DEVICEACCEPTABLE IsD3D11DeviceAcceptableFunc, + _In_opt_ void* pIsD3D11DeviceAcceptableFuncUserContext ); + + // These should be called after Enumerate() is called + std::vector<CD3D11EnumAdapterInfo*>* GetAdapterInfoList(); + CD3D11EnumAdapterInfo* GetAdapterInfo( _In_ UINT AdapterOrdinal ) const; + CD3D11EnumDeviceInfo* GetDeviceInfo( _In_ UINT AdapterOrdinal, _In_ D3D_DRIVER_TYPE DeviceType ) const; + CD3D11EnumOutputInfo* GetOutputInfo( _In_ UINT AdapterOrdinal, _In_ UINT Output ) const; + CD3D11EnumDeviceSettingsCombo* GetDeviceSettingsCombo( _In_ DXUTD3D11DeviceSettings* pDeviceSettings ) const { return GetDeviceSettingsCombo( pDeviceSettings->AdapterOrdinal, pDeviceSettings->sd.BufferDesc.Format, pDeviceSettings->sd.Windowed ); } + CD3D11EnumDeviceSettingsCombo* GetDeviceSettingsCombo( _In_ UINT AdapterOrdinal, _In_ DXGI_FORMAT BackBufferFormat, _In_ BOOL Windowed ) const; + D3D_FEATURE_LEVEL GetWARPFeaturevel() const { return m_warpFL; } + D3D_FEATURE_LEVEL GetREFFeaturevel() const { return m_refFL; } + + ~CD3D11Enumeration(); + +private: + friend HRESULT WINAPI DXUTCreateD3D11Enumeration(); + + // Use DXUTGetD3D11Enumeration() to access global instance + CD3D11Enumeration(); + + bool m_bHasEnumerated; + LPDXUTCALLBACKISD3D11DEVICEACCEPTABLE m_IsD3D11DeviceAcceptableFunc; + void* m_pIsD3D11DeviceAcceptableFuncUserContext; + + std::vector<DXGI_FORMAT> m_DepthStencilPossibleList; + + bool m_bEnumerateAllAdapterFormats; + D3D_FEATURE_LEVEL m_forceFL; + D3D_FEATURE_LEVEL m_warpFL; + D3D_FEATURE_LEVEL m_refFL; + + std::vector<CD3D11EnumAdapterInfo*> m_AdapterInfoList; + + HRESULT EnumerateOutputs( _In_ CD3D11EnumAdapterInfo *pAdapterInfo ); + HRESULT EnumerateDevices( _In_ CD3D11EnumAdapterInfo *pAdapterInfo ); + HRESULT EnumerateDeviceCombos( _In_ CD3D11EnumAdapterInfo* pAdapterInfo ); + HRESULT EnumerateDeviceCombosNoAdapter( _In_ CD3D11EnumAdapterInfo* pAdapterInfo ); + + HRESULT EnumerateDisplayModes( _In_ CD3D11EnumOutputInfo *pOutputInfo ); + void BuildMultiSampleQualityList( _In_ DXGI_FORMAT fmt, _In_ CD3D11EnumDeviceSettingsCombo* pDeviceCombo ); + void ClearAdapterInfoList(); +}; + +CD3D11Enumeration* WINAPI DXUTGetD3D11Enumeration(_In_ bool bForceEnumerate = false, _In_ bool EnumerateAllAdapterFormats = true, _In_ D3D_FEATURE_LEVEL forceFL = ((D3D_FEATURE_LEVEL )0) ); + + +#define DXGI_MAX_DEVICE_IDENTIFIER_STRING 128 + +//-------------------------------------------------------------------------------------- +// A class describing an adapter which contains a unique adapter ordinal +// that is installed on the system +//-------------------------------------------------------------------------------------- +class CD3D11EnumAdapterInfo +{ + const CD3D11EnumAdapterInfo &operator = ( const CD3D11EnumAdapterInfo &rhs ); + +public: + CD3D11EnumAdapterInfo() : + AdapterOrdinal( 0 ), + m_pAdapter( nullptr ), + bAdapterUnavailable(false) + { + *szUniqueDescription = 0; + memset( &AdapterDesc, 0, sizeof(AdapterDesc) ); + } + ~CD3D11EnumAdapterInfo(); + + UINT AdapterOrdinal; + DXGI_ADAPTER_DESC AdapterDesc; + WCHAR szUniqueDescription[DXGI_MAX_DEVICE_IDENTIFIER_STRING]; + IDXGIAdapter *m_pAdapter; + bool bAdapterUnavailable; + + std::vector<CD3D11EnumOutputInfo*> outputInfoList; // Array of CD3D11EnumOutputInfo* + std::vector<CD3D11EnumDeviceInfo*> deviceInfoList; // Array of CD3D11EnumDeviceInfo* + // List of CD3D11EnumDeviceSettingsCombo* with a unique set + // of BackBufferFormat, and Windowed + std::vector<CD3D11EnumDeviceSettingsCombo*> deviceSettingsComboList; +}; + + +class CD3D11EnumOutputInfo +{ + const CD3D11EnumOutputInfo &operator = ( const CD3D11EnumOutputInfo &rhs ); + +public: + CD3D11EnumOutputInfo() : + AdapterOrdinal( 0 ), + Output( 0 ), + m_pOutput( nullptr ) {} + ~CD3D11EnumOutputInfo(); + + UINT AdapterOrdinal; + UINT Output; + IDXGIOutput* m_pOutput; + DXGI_OUTPUT_DESC Desc; + + std::vector <DXGI_MODE_DESC> displayModeList; // Array of supported D3DDISPLAYMODEs +}; + + +//-------------------------------------------------------------------------------------- +// A class describing a Direct3D11 device that contains a unique supported driver type +//-------------------------------------------------------------------------------------- +class CD3D11EnumDeviceInfo +{ + const CD3D11EnumDeviceInfo& operator =( const CD3D11EnumDeviceInfo& rhs ); + +public: + ~CD3D11EnumDeviceInfo(); + + UINT AdapterOrdinal; + D3D_DRIVER_TYPE DeviceType; + D3D_FEATURE_LEVEL SelectedLevel; + D3D_FEATURE_LEVEL MaxLevel; + BOOL ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x; +}; + + +//-------------------------------------------------------------------------------------- +// A struct describing device settings that contains a unique combination of +// adapter format, back buffer format, and windowed that is compatible with a +// particular Direct3D device and the app. +//-------------------------------------------------------------------------------------- +struct CD3D11EnumDeviceSettingsCombo +{ + UINT AdapterOrdinal; + D3D_DRIVER_TYPE DeviceType; + DXGI_FORMAT BackBufferFormat; + BOOL Windowed; + UINT Output; + + std::vector <UINT> multiSampleCountList; // List of valid sampling counts (multisampling) + std::vector <UINT> multiSampleQualityList; // List of number of quality levels for each multisample count + + CD3D11EnumAdapterInfo* pAdapterInfo; + CD3D11EnumDeviceInfo* pDeviceInfo; + CD3D11EnumOutputInfo* pOutputInfo; +}; + +float DXUTRankD3D11DeviceCombo( _In_ CD3D11EnumDeviceSettingsCombo* pDeviceSettingsCombo, + _In_ DXUTD3D11DeviceSettings* pOptimalDeviceSettings, + _Out_ int &bestModeIndex, + _Out_ int &bestMSAAIndex + ); diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/DXUTmisc.h b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/DXUTmisc.h new file mode 100644 index 0000000..9706ccc --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/DXUTmisc.h @@ -0,0 +1,298 @@ +//-------------------------------------------------------------------------------------- +// File: DXUTMisc.h +// +// Helper functions for Direct3D programming. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=320437 +//-------------------------------------------------------------------------------------- +#pragma once + +//-------------------------------------------------------------------------------------- +// XInput helper state/function +// This performs extra processing on XInput gamepad data to make it slightly more convenient to use +// +// Example usage: +// +// DXUT_GAMEPAD gamepad[4]; +// for( DWORD iPort=0; iPort<DXUT_MAX_CONTROLLERS; iPort++ ) +// DXUTGetGamepadState( iPort, gamepad[iPort] ); +// +//-------------------------------------------------------------------------------------- +#define DXUT_MAX_CONTROLLERS 4 // XInput handles up to 4 controllers + +struct DXUT_GAMEPAD +{ + // From XINPUT_GAMEPAD + WORD wButtons; + BYTE bLeftTrigger; + BYTE bRightTrigger; + SHORT sThumbLX; + SHORT sThumbLY; + SHORT sThumbRX; + SHORT sThumbRY; + + // Device properties + XINPUT_CAPABILITIES caps; + bool bConnected; // If the controller is currently connected + bool bInserted; // If the controller was inserted this frame + bool bRemoved; // If the controller was removed this frame + + // Thumb stick values converted to range [-1,+1] + float fThumbRX; + float fThumbRY; + float fThumbLX; + float fThumbLY; + + // Records which buttons were pressed this frame. + // These are only set on the first frame that the button is pressed + WORD wPressedButtons; + bool bPressedLeftTrigger; + bool bPressedRightTrigger; + + // Last state of the buttons + WORD wLastButtons; + bool bLastLeftTrigger; + bool bLastRightTrigger; +}; + +HRESULT DXUTGetGamepadState( _In_ DWORD dwPort, _In_ DXUT_GAMEPAD* pGamePad, _In_ bool bThumbstickDeadZone = true, + _In_ bool bSnapThumbstickToCardinals = true ); +HRESULT DXUTStopRumbleOnAllControllers(); +void DXUTEnableXInput( _In_ bool bEnable ); + + +//-------------------------------------------------------------------------------------- +// Takes a screen shot of a 32bit D3D11 back buffer and saves the images to a BMP or DDS file +//-------------------------------------------------------------------------------------- + +HRESULT DXUTSnapD3D11Screenshot( _In_z_ LPCWSTR szFileName, _In_ bool usedds = true ); + +//-------------------------------------------------------------------------------------- +// Performs timer operations +// Use DXUTGetGlobalTimer() to get the global instance +//-------------------------------------------------------------------------------------- +class CDXUTTimer +{ +public: + CDXUTTimer(); + + void Reset(); // resets the timer + void Start(); // starts the timer + void Stop(); // stop (or pause) the timer + void Advance(); // advance the timer by 0.1 seconds + double GetAbsoluteTime() const; // get the absolute system time + double GetTime() const; // get the current time + float GetElapsedTime(); // get the time that elapsed between Get*ElapsedTime() calls + void GetTimeValues( _Out_ double* pfTime, _Out_ double* pfAbsoluteTime, _Out_ float* pfElapsedTime ); // get all time values at once + bool IsStopped() const { return m_bTimerStopped; } // returns true if timer stopped + + // Limit the current thread to one processor (the current one). This ensures that timing code runs + // on only one processor, and will not suffer any ill effects from power management. + void LimitThreadAffinityToCurrentProc(); + +protected: + LARGE_INTEGER GetAdjustedCurrentTime() const; + + bool m_bUsingQPF; + bool m_bTimerStopped; + LONGLONG m_llQPFTicksPerSec; + + LONGLONG m_llStopTime; + LONGLONG m_llLastElapsedTime; + LONGLONG m_llBaseTime; +}; + +CDXUTTimer* WINAPI DXUTGetGlobalTimer(); + + +//-------------------------------------------------------------------------------------- +// Returns the string for the given DXGI_FORMAT. +// bWithPrefix determines whether the string should include the "DXGI_FORMAT_" +//-------------------------------------------------------------------------------------- +LPCWSTR WINAPI DXUTDXGIFormatToString( _In_ DXGI_FORMAT format, _In_ bool bWithPrefix ); + + +//-------------------------------------------------------------------------------------- +// Debug printing support +// See dxerr.h for more debug printing support +//-------------------------------------------------------------------------------------- +void WINAPI DXUTOutputDebugStringW( _In_z_ LPCWSTR strMsg, ... ); +void WINAPI DXUTOutputDebugStringA( _In_z_ LPCSTR strMsg, ... ); +HRESULT WINAPI DXUTTrace( _In_z_ const CHAR* strFile, _In_ DWORD dwLine, _In_ HRESULT hr, _In_z_ const WCHAR* strMsg, _In_ bool bPopMsgBox ); +const WCHAR* WINAPI DXUTTraceWindowsMessage( _In_ UINT uMsg ); + +#ifdef UNICODE +#define DXUTOutputDebugString DXUTOutputDebugStringW +#else +#define DXUTOutputDebugString DXUTOutputDebugStringA +#endif + +// These macros are very similar to dxerr's but it special cases the HRESULT defined +// by DXUT to pop better message boxes. +#if defined(DEBUG) || defined(_DEBUG) +#define DXUT_ERR(str,hr) DXUTTrace( __FILE__, (DWORD)__LINE__, hr, str, false ) +#define DXUT_ERR_MSGBOX(str,hr) DXUTTrace( __FILE__, (DWORD)__LINE__, hr, str, true ) +#define DXUTTRACE DXUTOutputDebugString +#else +#define DXUT_ERR(str,hr) (hr) +#define DXUT_ERR_MSGBOX(str,hr) (hr) +#define DXUTTRACE (__noop) +#endif + + +//-------------------------------------------------------------------------------------- +// Direct3D dynamic linking support -- calls top-level D3D APIs with graceful +// failure if APIs are not present. +//-------------------------------------------------------------------------------------- + +int WINAPI DXUT_Dynamic_D3DPERF_BeginEvent( _In_ DWORD col, _In_z_ LPCWSTR wszName ); +int WINAPI DXUT_Dynamic_D3DPERF_EndEvent( void ); +void WINAPI DXUT_Dynamic_D3DPERF_SetMarker( _In_ DWORD col, _In_z_ LPCWSTR wszName ); +void WINAPI DXUT_Dynamic_D3DPERF_SetRegion( _In_ DWORD col, _In_z_ LPCWSTR wszName ); +BOOL WINAPI DXUT_Dynamic_D3DPERF_QueryRepeatFrame( void ); +void WINAPI DXUT_Dynamic_D3DPERF_SetOptions( _In_ DWORD dwOptions ); +DWORD WINAPI DXUT_Dynamic_D3DPERF_GetStatus(); +HRESULT WINAPI DXUT_Dynamic_CreateDXGIFactory1( _In_ REFIID rInterface, _Out_ void** ppOut ); +HRESULT WINAPI DXUT_Dynamic_DXGIGetDebugInterface( _In_ REFIID rInterface, _Out_ void** ppOut ); + +HRESULT WINAPI DXUT_Dynamic_D3D11CreateDevice( _In_opt_ IDXGIAdapter* pAdapter, + _In_ D3D_DRIVER_TYPE DriverType, + _In_opt_ HMODULE Software, + _In_ UINT32 Flags, + _In_reads_(FeatureLevels) const D3D_FEATURE_LEVEL* pFeatureLevels, + _In_ UINT FeatureLevels, + _In_ UINT32 SDKVersion, + _Deref_out_ ID3D11Device** ppDevice, + _Out_opt_ D3D_FEATURE_LEVEL* pFeatureLevel, + _Out_opt_ ID3D11DeviceContext** ppImmediateContext ); + +bool DXUT_EnsureD3D11APIs(); + + +//-------------------------------------------------------------------------------------- +// Profiling/instrumentation support +//-------------------------------------------------------------------------------------- + +// Use DXUT_SetDebugName() to attach names to D3D objects for use by +// SDKDebugLayer, PIX's object table, etc. +#if defined(PROFILE) || defined(DEBUG) +inline void DXUT_SetDebugName( _In_ IDXGIObject* pObj, _In_z_ const CHAR* pstrName ) +{ + if ( pObj ) + pObj->SetPrivateData( WKPDID_D3DDebugObjectName, (UINT)strlen(pstrName), pstrName ); +} +inline void DXUT_SetDebugName( _In_ ID3D11Device* pObj, _In_z_ const CHAR* pstrName ) +{ + if ( pObj ) + pObj->SetPrivateData( WKPDID_D3DDebugObjectName, (UINT)strlen(pstrName), pstrName ); +} +inline void DXUT_SetDebugName( _In_ ID3D11DeviceChild* pObj, _In_z_ const CHAR* pstrName ) +{ + if ( pObj ) + pObj->SetPrivateData( WKPDID_D3DDebugObjectName, (UINT)strlen(pstrName), pstrName ); +} +#else +#define DXUT_SetDebugName( pObj, pstrName ) +#endif + + +//-------------------------------------------------------------------------------------- +// Some D3DPERF APIs take a color that can be used when displaying user events in +// performance analysis tools. The following constants are provided for your +// convenience, but you can use any colors you like. +//-------------------------------------------------------------------------------------- +const DWORD DXUT_PERFEVENTCOLOR = 0xFFC86464; +const DWORD DXUT_PERFEVENTCOLOR2 = 0xFF64C864; +const DWORD DXUT_PERFEVENTCOLOR3 = 0xFF6464C8; + +//-------------------------------------------------------------------------------------- +// The following macros provide a convenient way for your code to call the D3DPERF +// functions only when PROFILE is defined. If PROFILE is not defined (as for the final +// release version of a program), these macros evaluate to nothing, so no detailed event +// information is embedded in your shipping program. It is recommended that you create +// and use three build configurations for your projects: +// Debug (nonoptimized code, asserts active, PROFILE defined to assist debugging) +// Profile (optimized code, asserts disabled, PROFILE defined to assist optimization) +// Release (optimized code, asserts disabled, PROFILE not defined) +//-------------------------------------------------------------------------------------- +#ifdef PROFILE +// PROFILE is defined, so these macros call the D3DPERF functions +#define DXUT_BeginPerfEvent( color, pstrMessage ) DXUT_Dynamic_D3DPERF_BeginEvent( color, pstrMessage ) +#define DXUT_EndPerfEvent() DXUT_Dynamic_D3DPERF_EndEvent() +#define DXUT_SetPerfMarker( color, pstrMessage ) DXUT_Dynamic_D3DPERF_SetMarker( color, pstrMessage ) +#else +// PROFILE is not defined, so these macros do nothing +#define DXUT_BeginPerfEvent( color, pstrMessage ) (__noop) +#define DXUT_EndPerfEvent() (__noop) +#define DXUT_SetPerfMarker( color, pstrMessage ) (__noop) +#endif + +//-------------------------------------------------------------------------------------- +// CDXUTPerfEventGenerator is a helper class that makes it easy to attach begin and end +// events to a block of code. Simply define a CDXUTPerfEventGenerator variable anywhere +// in a block of code, and the class's constructor will call DXUT_BeginPerfEvent when +// the block of code begins, and the class's destructor will call DXUT_EndPerfEvent when +// the block ends. +//-------------------------------------------------------------------------------------- +class CDXUTPerfEventGenerator +{ +public: +CDXUTPerfEventGenerator( _In_ DWORD color, _In_z_ LPCWSTR pstrMessage ) +{ +#ifdef PROFILE + DXUT_BeginPerfEvent( color, pstrMessage ); +#else + UNREFERENCED_PARAMETER(color); + UNREFERENCED_PARAMETER(pstrMessage); +#endif +} +~CDXUTPerfEventGenerator() +{ + DXUT_EndPerfEvent(); +} +}; + + +//-------------------------------------------------------------------------------------- +// Multimon handling to support OSes with or without multimon API support. +// Purposely avoiding the use of multimon.h so DXUT.lib doesn't require +// COMPILE_MULTIMON_STUBS and cause complication with MFC or other users of multimon.h +//-------------------------------------------------------------------------------------- +#ifndef MONITOR_DEFAULTTOPRIMARY +#define MONITORINFOF_PRIMARY 0x00000001 +#define MONITOR_DEFAULTTONULL 0x00000000 +#define MONITOR_DEFAULTTOPRIMARY 0x00000001 +#define MONITOR_DEFAULTTONEAREST 0x00000002 +typedef struct tagMONITORINFO +{ + DWORD cbSize; + RECT rcMonitor; + RECT rcWork; + DWORD dwFlags; +} MONITORINFO, *LPMONITORINFO; +typedef struct tagMONITORINFOEXW : public tagMONITORINFO +{ + WCHAR szDevice[CCHDEVICENAME]; +} MONITORINFOEXW, *LPMONITORINFOEXW; +typedef MONITORINFOEXW MONITORINFOEX; +typedef LPMONITORINFOEXW LPMONITORINFOEX; +#endif + +HMONITOR WINAPI DXUTMonitorFromWindow( _In_ HWND hWnd, _In_ DWORD dwFlags ); +HMONITOR WINAPI DXUTMonitorFromRect( _In_ LPCRECT lprcScreenCoords, _In_ DWORD dwFlags ); +BOOL WINAPI DXUTGetMonitorInfo( _In_ HMONITOR hMonitor, _Out_ LPMONITORINFO lpMonitorInfo ); +void WINAPI DXUTGetDesktopResolution( _In_ UINT AdapterOrdinal, _Out_ UINT* pWidth, _Out_ UINT* pHeight ); + + +//-------------------------------------------------------------------------------------- +// Helper functions to create SRGB formats from typeless formats and vice versa +//-------------------------------------------------------------------------------------- +DXGI_FORMAT MAKE_SRGB( _In_ DXGI_FORMAT format ); +DXGI_FORMAT MAKE_TYPELESS( _In_ DXGI_FORMAT format ); diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/ScreenGrab.h b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/ScreenGrab.h new file mode 100644 index 0000000..d643073 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/ScreenGrab.h @@ -0,0 +1,43 @@ +//-------------------------------------------------------------------------------------- +// File: ScreenGrab.h +// +// Function for capturing a 2D texture and saving it to a file (aka a 'screenshot' +// when used on a Direct3D 11 Render Target). +// +// Note these functions are useful as a light-weight runtime screen grabber. For +// full-featured texture capture, DDS writer, and texture processing pipeline, +// see the 'Texconv' sample and the 'DirectXTex' library. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248926 +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#include <d3d11_1.h> + +#include <ocidl.h> +#include <stdint.h> +#include <functional> + + +namespace DirectX +{ + HRESULT SaveDDSTextureToFile( _In_ ID3D11DeviceContext* pContext, + _In_ ID3D11Resource* pSource, + _In_z_ LPCWSTR fileName ); + + HRESULT SaveWICTextureToFile( _In_ ID3D11DeviceContext* pContext, + _In_ ID3D11Resource* pSource, + _In_ REFGUID guidContainerFormat, + _In_z_ LPCWSTR fileName, + _In_opt_ const GUID* targetFormat = nullptr, + _In_opt_ std::function<void(IPropertyBag2*)> setCustomProps = nullptr ); +}
\ No newline at end of file diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/WICTextureLoader.h b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/WICTextureLoader.h new file mode 100644 index 0000000..2b0340c --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/WICTextureLoader.h @@ -0,0 +1,123 @@ +//-------------------------------------------------------------------------------------- +// File: WICTextureLoader.h +// +// Function for loading a WIC image and creating a Direct3D 11 runtime texture for it +// (auto-generating mipmaps if possible) +// +// Note: Assumes application has already called CoInitializeEx +// +// Warning: CreateWICTexture* functions are not thread-safe if given a d3dContext instance for +// auto-gen mipmap support. +// +// Note these functions are useful for images created as simple 2D textures. For +// more complex resources, DDSTextureLoader is an excellent light-weight runtime loader. +// For a full-featured DDS file reader, writer, and texture processing pipeline see +// the 'Texconv' sample and the 'DirectXTex' library. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=248926 +// http://go.microsoft.com/fwlink/?LinkId=248929 +//-------------------------------------------------------------------------------------- + +#pragma once + +#include <d3d11_1.h> +#include <stdint.h> + + +namespace DirectX +{ + // Standard version + HRESULT CreateWICTextureFromMemory( _In_ ID3D11Device* d3dDevice, + _In_reads_bytes_(wicDataSize) const uint8_t* wicData, + _In_ size_t wicDataSize, + _Out_opt_ ID3D11Resource** texture, + _Out_opt_ ID3D11ShaderResourceView** textureView, + _In_ size_t maxsize = 0 + ); + + HRESULT CreateWICTextureFromFile( _In_ ID3D11Device* d3dDevice, + _In_z_ const wchar_t* szFileName, + _Out_opt_ ID3D11Resource** texture, + _Out_opt_ ID3D11ShaderResourceView** textureView, + _In_ size_t maxsize = 0 + ); + + // Standard version with optional auto-gen mipmap support + HRESULT CreateWICTextureFromMemory( _In_ ID3D11Device* d3dDevice, + _In_opt_ ID3D11DeviceContext* d3dContext, + _In_reads_bytes_(wicDataSize) const uint8_t* wicData, + _In_ size_t wicDataSize, + _Out_opt_ ID3D11Resource** texture, + _Out_opt_ ID3D11ShaderResourceView** textureView, + _In_ size_t maxsize = 0 + ); + + HRESULT CreateWICTextureFromFile( _In_ ID3D11Device* d3dDevice, + _In_opt_ ID3D11DeviceContext* d3dContext, + _In_z_ const wchar_t* szFileName, + _Out_opt_ ID3D11Resource** texture, + _Out_opt_ ID3D11ShaderResourceView** textureView, + _In_ size_t maxsize = 0 + ); + + // Extended version + HRESULT CreateWICTextureFromMemoryEx( _In_ ID3D11Device* d3dDevice, + _In_reads_bytes_(wicDataSize) const uint8_t* wicData, + _In_ size_t wicDataSize, + _In_ size_t maxsize, + _In_ D3D11_USAGE usage, + _In_ unsigned int bindFlags, + _In_ unsigned int cpuAccessFlags, + _In_ unsigned int miscFlags, + _In_ bool forceSRGB, + _Out_opt_ ID3D11Resource** texture, + _Out_opt_ ID3D11ShaderResourceView** textureView + ); + + HRESULT CreateWICTextureFromFileEx( _In_ ID3D11Device* d3dDevice, + _In_z_ const wchar_t* szFileName, + _In_ size_t maxsize, + _In_ D3D11_USAGE usage, + _In_ unsigned int bindFlags, + _In_ unsigned int cpuAccessFlags, + _In_ unsigned int miscFlags, + _In_ bool forceSRGB, + _Out_opt_ ID3D11Resource** texture, + _Out_opt_ ID3D11ShaderResourceView** textureView + ); + + // Extended version with optional auto-gen mipmap support + HRESULT CreateWICTextureFromMemoryEx( _In_ ID3D11Device* d3dDevice, + _In_opt_ ID3D11DeviceContext* d3dContext, + _In_reads_bytes_(wicDataSize) const uint8_t* wicData, + _In_ size_t wicDataSize, + _In_ size_t maxsize, + _In_ D3D11_USAGE usage, + _In_ unsigned int bindFlags, + _In_ unsigned int cpuAccessFlags, + _In_ unsigned int miscFlags, + _In_ bool forceSRGB, + _Out_opt_ ID3D11Resource** texture, + _Out_opt_ ID3D11ShaderResourceView** textureView + ); + + HRESULT CreateWICTextureFromFileEx( _In_ ID3D11Device* d3dDevice, + _In_opt_ ID3D11DeviceContext* d3dContext, + _In_z_ const wchar_t* szFileName, + _In_ size_t maxsize, + _In_ D3D11_USAGE usage, + _In_ unsigned int bindFlags, + _In_ unsigned int cpuAccessFlags, + _In_ unsigned int miscFlags, + _In_ bool forceSRGB, + _Out_opt_ ID3D11Resource** texture, + _Out_opt_ ID3D11ShaderResourceView** textureView + ); +}
\ No newline at end of file diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Core/dxerr.h b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/dxerr.h new file mode 100644 index 0000000..39e348d --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Core/dxerr.h @@ -0,0 +1,76 @@ +//-------------------------------------------------------------------------------------- +// File: DXErr.h +// +// DirectX Error Library +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +//-------------------------------------------------------------------------------------- + +// This version only supports UNICODE. + +#pragma once + +#include <windows.h> +#include <sal.h> + +#ifdef __cplusplus +extern "C" { +#endif + +//-------------------------------------------------------------------------------------- +// DXGetErrorString +//-------------------------------------------------------------------------------------- +const WCHAR* WINAPI DXGetErrorStringW( _In_ HRESULT hr ); + +#define DXGetErrorString DXGetErrorStringW + +//-------------------------------------------------------------------------------------- +// DXGetErrorDescription has to be modified to return a copy in a buffer rather than +// the original static string. +//-------------------------------------------------------------------------------------- +void WINAPI DXGetErrorDescriptionW( _In_ HRESULT hr, _Out_cap_(count) WCHAR* desc, _In_ size_t count ); + +#define DXGetErrorDescription DXGetErrorDescriptionW + +//-------------------------------------------------------------------------------------- +// DXTrace +// +// Desc: Outputs a formatted error message to the debug stream +// +// Args: WCHAR* strFile The current file, typically passed in using the +// __FILEW__ macro. +// DWORD dwLine The current line number, typically passed in using the +// __LINE__ macro. +// HRESULT hr An HRESULT that will be traced to the debug stream. +// CHAR* strMsg A string that will be traced to the debug stream (may be NULL) +// BOOL bPopMsgBox If TRUE, then a message box will popup also containing the passed info. +// +// Return: The hr that was passed in. +//-------------------------------------------------------------------------------------- +HRESULT WINAPI DXTraceW( _In_z_ const WCHAR* strFile, _In_ DWORD dwLine, _In_ HRESULT hr, _In_opt_ const WCHAR* strMsg, _In_ bool bPopMsgBox ); + +#define DXTrace DXTraceW + +//-------------------------------------------------------------------------------------- +// +// Helper macros +// +//-------------------------------------------------------------------------------------- +#if defined(DEBUG) || defined(_DEBUG) +#define DXTRACE_MSG(str) DXTrace( __FILEW__, (DWORD)__LINE__, 0, str, false ) +#define DXTRACE_ERR(str,hr) DXTrace( __FILEW__, (DWORD)__LINE__, hr, str, false ) +#define DXTRACE_ERR_MSGBOX(str,hr) DXTrace( __FILEW__, (DWORD)__LINE__, hr, str, true ) +#else +#define DXTRACE_MSG(str) (0L) +#define DXTRACE_ERR(str,hr) (hr) +#define DXTRACE_ERR_MSGBOX(str,hr) (hr) +#endif + +#ifdef __cplusplus +} +#endif //__cplusplus diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/Win32/Debug/DXUTOpt.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/Win32/Debug/DXUTOpt.lib Binary files differnew file mode 100644 index 0000000..7f275b0 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/Win32/Debug/DXUTOpt.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/Win32/Debug/dxutopt.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/Win32/Debug/dxutopt.pdb Binary files differnew file mode 100644 index 0000000..88ff303 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/Win32/Debug/dxutopt.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2013/Win32/Debug/DXUTOpt.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2013/Win32/Debug/DXUTOpt.lib Binary files differnew file mode 100644 index 0000000..7f275b0 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2013/Win32/Debug/DXUTOpt.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2013/Win32/Debug/dxutopt.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2013/Win32/Debug/dxutopt.pdb Binary files differnew file mode 100644 index 0000000..88ff303 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2013/Win32/Debug/dxutopt.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2013/Win32/Release/DXUTOpt.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2013/Win32/Release/DXUTOpt.lib Binary files differnew file mode 100644 index 0000000..1ac2426 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2013/Win32/Release/DXUTOpt.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2013/Win32/Release/dxutopt.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2013/Win32/Release/dxutopt.pdb Binary files differnew file mode 100644 index 0000000..ca0e159 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2013/Win32/Release/dxutopt.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2013/x64/Debug/DXUTOpt.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2013/x64/Debug/DXUTOpt.lib Binary files differnew file mode 100644 index 0000000..97d0afb --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2013/x64/Debug/DXUTOpt.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2013/x64/Debug/dxutopt.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2013/x64/Debug/dxutopt.pdb Binary files differnew file mode 100644 index 0000000..24dca7d --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2013/x64/Debug/dxutopt.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2013/x64/Release/DXUTOpt.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2013/x64/Release/DXUTOpt.lib Binary files differnew file mode 100644 index 0000000..c9d32a0 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2013/x64/Release/DXUTOpt.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2013/x64/Release/dxutopt.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2013/x64/Release/dxutopt.pdb Binary files differnew file mode 100644 index 0000000..85c771e --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2013/x64/Release/dxutopt.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2015/Win32/Debug/DXUTOpt.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2015/Win32/Debug/DXUTOpt.lib Binary files differnew file mode 100644 index 0000000..635c553 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2015/Win32/Debug/DXUTOpt.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2015/Win32/Debug/DXUTOpt.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2015/Win32/Debug/DXUTOpt.pdb Binary files differnew file mode 100644 index 0000000..89b4bab --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2015/Win32/Debug/DXUTOpt.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2015/Win32/Release/DXUTOpt.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2015/Win32/Release/DXUTOpt.lib Binary files differnew file mode 100644 index 0000000..6984b55 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2015/Win32/Release/DXUTOpt.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2015/Win32/Release/DXUTOpt.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2015/Win32/Release/DXUTOpt.pdb Binary files differnew file mode 100644 index 0000000..0c28b2e --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2015/Win32/Release/DXUTOpt.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2015/x64/Debug/DXUTOpt.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2015/x64/Debug/DXUTOpt.lib Binary files differnew file mode 100644 index 0000000..8540d6b --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2015/x64/Debug/DXUTOpt.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2015/x64/Debug/DXUTOpt.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2015/x64/Debug/DXUTOpt.pdb Binary files differnew file mode 100644 index 0000000..cc20170 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2015/x64/Debug/DXUTOpt.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2015/x64/Release/DXUTOpt.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2015/x64/Release/DXUTOpt.lib Binary files differnew file mode 100644 index 0000000..298f121 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2015/x64/Release/DXUTOpt.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2015/x64/Release/DXUTOpt.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2015/x64/Release/DXUTOpt.pdb Binary files differnew file mode 100644 index 0000000..4c0748e --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/dynamiccrt/vs2015/x64/Release/DXUTOpt.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2013/Win32/Debug/DXUTOpt.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2013/Win32/Debug/DXUTOpt.lib Binary files differnew file mode 100644 index 0000000..b7bd479 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2013/Win32/Debug/DXUTOpt.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2013/Win32/Debug/dxutopt.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2013/Win32/Debug/dxutopt.pdb Binary files differnew file mode 100644 index 0000000..670d106 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2013/Win32/Debug/dxutopt.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2013/Win32/Release/DXUTOpt.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2013/Win32/Release/DXUTOpt.lib Binary files differnew file mode 100644 index 0000000..68c4933 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2013/Win32/Release/DXUTOpt.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2013/Win32/Release/dxutopt.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2013/Win32/Release/dxutopt.pdb Binary files differnew file mode 100644 index 0000000..5e44847 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2013/Win32/Release/dxutopt.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2013/x64/Debug/DXUTOpt.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2013/x64/Debug/DXUTOpt.lib Binary files differnew file mode 100644 index 0000000..3049c41 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2013/x64/Debug/DXUTOpt.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2013/x64/Debug/dxutopt.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2013/x64/Debug/dxutopt.pdb Binary files differnew file mode 100644 index 0000000..e0db268 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2013/x64/Debug/dxutopt.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2013/x64/Release/DXUTOpt.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2013/x64/Release/DXUTOpt.lib Binary files differnew file mode 100644 index 0000000..e3d071e --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2013/x64/Release/DXUTOpt.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2013/x64/Release/dxutopt.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2013/x64/Release/dxutopt.pdb Binary files differnew file mode 100644 index 0000000..cefc664 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2013/x64/Release/dxutopt.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2015/Win32/Debug/DXUTOpt.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2015/Win32/Debug/DXUTOpt.lib Binary files differnew file mode 100644 index 0000000..d5d77a2 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2015/Win32/Debug/DXUTOpt.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2015/Win32/Debug/DXUTOpt.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2015/Win32/Debug/DXUTOpt.pdb Binary files differnew file mode 100644 index 0000000..e718bb0 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2015/Win32/Debug/DXUTOpt.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2015/Win32/Release/DXUTOpt.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2015/Win32/Release/DXUTOpt.lib Binary files differnew file mode 100644 index 0000000..e66fdbd --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2015/Win32/Release/DXUTOpt.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2015/Win32/Release/DXUTOpt.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2015/Win32/Release/DXUTOpt.pdb Binary files differnew file mode 100644 index 0000000..9b0dcd7 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2015/Win32/Release/DXUTOpt.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2015/x64/Debug/DXUTOpt.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2015/x64/Debug/DXUTOpt.lib Binary files differnew file mode 100644 index 0000000..0023238 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2015/x64/Debug/DXUTOpt.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2015/x64/Debug/DXUTOpt.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2015/x64/Debug/DXUTOpt.pdb Binary files differnew file mode 100644 index 0000000..2e3c329 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2015/x64/Debug/DXUTOpt.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2015/x64/Release/DXUTOpt.lib b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2015/x64/Release/DXUTOpt.lib Binary files differnew file mode 100644 index 0000000..e1d99d1 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2015/x64/Release/DXUTOpt.lib diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2015/x64/Release/DXUTOpt.pdb b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2015/x64/Release/DXUTOpt.pdb Binary files differnew file mode 100644 index 0000000..e4b57e0 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/Bin/staticcrt/vs2015/x64/Release/DXUTOpt.pdb diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/DXUTLockFreePipe.h b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/DXUTLockFreePipe.h new file mode 100644 index 0000000..e6bd360 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/DXUTLockFreePipe.h @@ -0,0 +1,226 @@ +//-------------------------------------------------------------------------------------- +// DXUTLockFreePipe.h +// +// See the "Lockless Programming Considerations for Xbox 360 and Microsoft Windows" +// article for more details. +// +// http://msdn.microsoft.com/en-us/library/ee418650.aspx +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=320437 +//-------------------------------------------------------------------------------------- +#pragma once + +#include <sal.h> +#include <algorithm> + +#pragma pack(push) +#pragma pack(8) +#include <windows.h> +#pragma pack (pop) + +extern "C" + void _ReadWriteBarrier(); +#pragma intrinsic(_ReadWriteBarrier) + +// Prevent the compiler from rearranging loads +// and stores, sufficiently for read-acquire +// and write-release. This is sufficient on +// x86 and x64. +#define DXUTImportBarrier _ReadWriteBarrier +#define DXUTExportBarrier _ReadWriteBarrier + +// +// Pipe class designed for use by at most two threads: one reader, one writer. +// Access by more than two threads isn't guaranteed to be safe. +// +// In order to provide efficient access the size of the buffer is passed +// as a template parameter and restricted to powers of two less than 31. +// + +template <BYTE cbBufferSizeLog2> class DXUTLockFreePipe +{ +public: + DXUTLockFreePipe() : m_readOffset( 0 ), + m_writeOffset( 0 ) + { + } + + DWORD GetBufferSize() const + { + return c_cbBufferSize; + } + + __forceinline unsigned long BytesAvailable() const + { + return m_writeOffset - m_readOffset; + } + + bool __forceinline Read( _Out_writes_(cbDest) void* pvDest, _In_ unsigned long cbDest ) + { + // Store the read and write offsets into local variables--this is + // essentially a snapshot of their values so that they stay constant + // for the duration of the function (and so we don't end up with cache + // misses due to false sharing). + DWORD readOffset = m_readOffset; + DWORD writeOffset = m_writeOffset; + + // Compare the two offsets to see if we have anything to read. + // Note that we don't do anything to synchronize the offsets here. + // Really there's not much we *can* do unless we're willing to completely + // synchronize access to the entire object. We have to assume that as we + // read, someone else may be writing, and the write offset we have now + // may be out of date by the time we read it. Fortunately that's not a + // very big deal. We might miss reading some data that was just written. + // But the assumption is that we'll be back before long to grab more data + // anyway. + // + // Note that this comparison works because we're careful to constrain + // the total buffer size to be a power of 2, which means it will divide + // evenly into ULONG_MAX+1. That, and the fact that the offsets are + // unsigned, means that the calculation returns correct results even + // when the values wrap around. + DWORD cbAvailable = writeOffset - readOffset; + if( cbDest > cbAvailable ) + { + return false; + } + + // The data has been made available, but we need to make sure + // that our view on the data is up to date -- at least as up to + // date as the control values we just read. We need to prevent + // the compiler or CPU from moving any of the data reads before + // the control value reads. This import barrier serves this + // purpose, on Xbox 360 and on Windows. + + // Reading a control value and then having a barrier is known + // as a "read-acquire." + DXUTImportBarrier(); + + unsigned char* pbDest = ( unsigned char* )pvDest; + + unsigned long actualReadOffset = readOffset & c_sizeMask; + unsigned long bytesLeft = cbDest; + + // + // Copy from the tail, then the head. Note that there's no explicit + // check to see if the write offset comes between the read offset + // and the end of the buffer--that particular condition is implicitly + // checked by the comparison with AvailableToRead(), above. If copying + // cbDest bytes off the tail would cause us to cross the write offset, + // then the previous comparison would have failed since that would imply + // that there were less than cbDest bytes available to read. + // + unsigned long cbTailBytes = std::min( bytesLeft, c_cbBufferSize - actualReadOffset ); + memcpy( pbDest, m_pbBuffer + actualReadOffset, cbTailBytes ); + bytesLeft -= cbTailBytes; + + if( bytesLeft ) + { + memcpy( pbDest + cbTailBytes, m_pbBuffer, bytesLeft ); + } + + // When we update the read offset we are, effectively, 'freeing' buffer + // memory so that the writing thread can use it. We need to make sure that + // we don't free the memory before we have finished reading it. That is, + // we need to make sure that the write to m_readOffset can't get reordered + // above the reads of the buffer data. The only way to guarantee this is to + // have an export barrier to prevent both compiler and CPU rearrangements. + DXUTExportBarrier(); + + // Advance the read offset. From the CPUs point of view this is several + // operations--read, modify, store--and we'd normally want to make sure that + // all of the operations happened atomically. But in the case of a single + // reader, only one thread updates this value and so the only operation that + // must be atomic is the store. That's lucky, because 32-bit aligned stores are + // atomic on all modern processors. + // + readOffset += cbDest; + m_readOffset = readOffset; + + return true; + } + + bool __forceinline Write( _In_reads_(cbSrc) const void* pvSrc, _In_ unsigned long cbSrc ) + { + // Reading the read offset here has the same caveats as reading + // the write offset had in the Read() function above. + DWORD readOffset = m_readOffset; + DWORD writeOffset = m_writeOffset; + + // Compute the available write size. This comparison relies on + // the fact that the buffer size is always a power of 2, and the + // offsets are unsigned integers, so that when the write pointer + // wraps around the subtraction still yields a value (assuming + // we haven't messed up somewhere else) between 0 and c_cbBufferSize - 1. + DWORD cbAvailable = c_cbBufferSize - ( writeOffset - readOffset ); + if( cbSrc > cbAvailable ) + { + return false; + } + + // It is theoretically possible for writes of the data to be reordered + // above the reads to see if the data is available. Improbable perhaps, + // but possible. This barrier guarantees that the reordering will not + // happen. + DXUTImportBarrier(); + + // Write the data + const unsigned char* pbSrc = ( const unsigned char* )pvSrc; + unsigned long actualWriteOffset = writeOffset & c_sizeMask; + unsigned long bytesLeft = cbSrc; + + // See the explanation in the Read() function as to why we don't + // explicitly check against the read offset here. + unsigned long cbTailBytes = std::min( bytesLeft, c_cbBufferSize - actualWriteOffset ); + memcpy( m_pbBuffer + actualWriteOffset, pbSrc, cbTailBytes ); + bytesLeft -= cbTailBytes; + + if( bytesLeft ) + { + memcpy( m_pbBuffer, pbSrc + cbTailBytes, bytesLeft ); + } + + // Now it's time to update the write offset, but since the updated position + // of the write offset will imply that there's data to be read, we need to + // make sure that the data all actually gets written before the update to + // the write offset. The writes could be reordered by the compiler (on any + // platform) or by the CPU (on Xbox 360). We need a barrier which prevents + // the writes from being reordered past each other. + // + // Having a barrier and then writing a control value is called "write-release." + DXUTExportBarrier(); + + // See comments in Read() as to why this operation isn't interlocked. + writeOffset += cbSrc; + m_writeOffset = writeOffset; + + return true; + } + +private: + // Values derived from the buffer size template parameter + // + const static BYTE c_cbBufferSizeLog2 = __min( cbBufferSizeLog2, 31 ); + const static DWORD c_cbBufferSize = ( 1 << c_cbBufferSizeLog2 ); + const static DWORD c_sizeMask = c_cbBufferSize - 1; + + // Leave these private and undefined to prevent their use + DXUTLockFreePipe( const DXUTLockFreePipe& ); + DXUTLockFreePipe& operator =( const DXUTLockFreePipe& ); + + // Member data + // + BYTE m_pbBuffer[c_cbBufferSize]; + // Note that these offsets are not clamped to the buffer size. + // Instead the calculations rely on wrapping at ULONG_MAX+1. + // See the comments in Read() for details. + volatile DWORD __declspec( align( 4 ) ) m_readOffset; + volatile DWORD __declspec( align( 4 ) ) m_writeOffset; +};
\ No newline at end of file diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/DXUTcamera.h b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/DXUTcamera.h new file mode 100644 index 0000000..047760d --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/DXUTcamera.h @@ -0,0 +1,426 @@ +//-------------------------------------------------------------------------------------- +// File: Camera.h +// +// Helper functions for Direct3D programming. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=320437 +//-------------------------------------------------------------------------------------- +#pragma once + +//-------------------------------------------------------------------------------------- +class CD3DArcBall +{ +public: + CD3DArcBall(); + + // Functions to change behavior + void Reset(); + void SetTranslationRadius( _In_ float fRadiusTranslation ) + { + m_fRadiusTranslation = fRadiusTranslation; + } + void SetWindow( _In_ INT nWidth, _In_ INT nHeight, _In_ float fRadius = 0.9f ) + { + m_nWidth = nWidth; + m_nHeight = nHeight; + m_fRadius = fRadius; + m_vCenter.x = float(m_nWidth) / 2.0f; + m_vCenter.y = float(m_nHeight) / 2.0f; + } + void SetOffset( _In_ INT nX, _In_ INT nY ) { m_Offset.x = nX; m_Offset.y = nY; } + + // Call these from client and use GetRotationMatrix() to read new rotation matrix + void OnBegin( _In_ int nX, _In_ int nY ); // start the rotation (pass current mouse position) + void OnMove( _In_ int nX, _In_ int nY ); // continue the rotation (pass current mouse position) + void OnEnd(); // end the rotation + + // Or call this to automatically handle left, middle, right buttons + LRESULT HandleMessages( _In_ HWND hWnd, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ); + + // Functions to get/set state + DirectX::XMMATRIX GetRotationMatrix() const + { + using namespace DirectX; + XMVECTOR q = XMLoadFloat4( &m_qNow ); + return DirectX::XMMatrixRotationQuaternion( q ); + } + DirectX::XMMATRIX GetTranslationMatrix() const { return DirectX::XMLoadFloat4x4( &m_mTranslation ); } + DirectX::XMMATRIX GetTranslationDeltaMatrix() const { return DirectX::XMLoadFloat4x4( &m_mTranslationDelta ); } + bool IsBeingDragged() const { return m_bDrag; } + DirectX::XMVECTOR GetQuatNow() const { return DirectX::XMLoadFloat4( &m_qNow ); } + void SetQuatNow( _In_ DirectX::FXMVECTOR& q ) { DirectX::XMStoreFloat4( &m_qNow, q ); } + + static DirectX::XMVECTOR QuatFromBallPoints( _In_ DirectX::FXMVECTOR vFrom, _In_ DirectX::FXMVECTOR vTo ) + { + using namespace DirectX; + + XMVECTOR dot = XMVector3Dot( vFrom, vTo ); + XMVECTOR vPart = XMVector3Cross( vFrom, vTo ); + return XMVectorSelect( dot, vPart, g_XMSelect1110 ); + } + +protected: + DirectX::XMFLOAT4X4 m_mRotation; // Matrix for arc ball's orientation + DirectX::XMFLOAT4X4 m_mTranslation; // Matrix for arc ball's position + DirectX::XMFLOAT4X4 m_mTranslationDelta;// Matrix for arc ball's position + + POINT m_Offset; // window offset, or upper-left corner of window + INT m_nWidth; // arc ball's window width + INT m_nHeight; // arc ball's window height + DirectX::XMFLOAT2 m_vCenter; // center of arc ball + float m_fRadius; // arc ball's radius in screen coords + float m_fRadiusTranslation; // arc ball's radius for translating the target + + DirectX::XMFLOAT4 m_qDown; // Quaternion before button down + DirectX::XMFLOAT4 m_qNow; // Composite quaternion for current drag + bool m_bDrag; // Whether user is dragging arc ball + + POINT m_ptLastMouse; // position of last mouse point + DirectX::XMFLOAT3 m_vDownPt; // starting point of rotation arc + DirectX::XMFLOAT3 m_vCurrentPt; // current point of rotation arc + + DirectX::XMVECTOR ScreenToVector( _In_ float fScreenPtX, _In_ float fScreenPtY ) + { + // Scale to screen + float x = -( fScreenPtX - m_Offset.x - m_nWidth / 2 ) / ( m_fRadius * m_nWidth / 2 ); + float y = ( fScreenPtY - m_Offset.y - m_nHeight / 2 ) / ( m_fRadius * m_nHeight / 2 ); + + float z = 0.0f; + float mag = x * x + y * y; + + if( mag > 1.0f ) + { + float scale = 1.0f / sqrtf( mag ); + x *= scale; + y *= scale; + } + else + z = sqrtf( 1.0f - mag ); + + return DirectX::XMVectorSet( x, y, z, 0 ); + } +}; + + +//-------------------------------------------------------------------------------------- +// used by CCamera to map WM_KEYDOWN keys +//-------------------------------------------------------------------------------------- +enum D3DUtil_CameraKeys +{ + CAM_STRAFE_LEFT = 0, + CAM_STRAFE_RIGHT, + CAM_MOVE_FORWARD, + CAM_MOVE_BACKWARD, + CAM_MOVE_UP, + CAM_MOVE_DOWN, + CAM_RESET, + CAM_CONTROLDOWN, + CAM_MAX_KEYS, + CAM_UNKNOWN = 0xFF +}; + +#define KEY_WAS_DOWN_MASK 0x80 +#define KEY_IS_DOWN_MASK 0x01 + +#define MOUSE_LEFT_BUTTON 0x01 +#define MOUSE_MIDDLE_BUTTON 0x02 +#define MOUSE_RIGHT_BUTTON 0x04 +#define MOUSE_WHEEL 0x08 + + +//-------------------------------------------------------------------------------------- +// Simple base camera class that moves and rotates. The base class +// records mouse and keyboard input for use by a derived class, and +// keeps common state. +//-------------------------------------------------------------------------------------- +class CBaseCamera +{ +public: + CBaseCamera(); + + // Call these from client and use Get*Matrix() to read new matrices + virtual LRESULT HandleMessages( _In_ HWND hWnd, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ); + virtual void FrameMove( _In_ float fElapsedTime ) = 0; + + // Functions to change camera matrices + virtual void Reset(); + virtual void SetViewParams( _In_ DirectX::FXMVECTOR vEyePt, _In_ DirectX::FXMVECTOR vLookatPt ); + virtual void SetProjParams( _In_ float fFOV, _In_ float fAspect, _In_ float fNearPlane, _In_ float fFarPlane ); + + // Functions to change behavior + virtual void SetDragRect( _In_ const RECT& rc ) { m_rcDrag = rc; } + void SetInvertPitch( _In_ bool bInvertPitch ) { m_bInvertPitch = bInvertPitch; } + void SetDrag( _In_ bool bMovementDrag, _In_ float fTotalDragTimeToZero = 0.25f ) + { + m_bMovementDrag = bMovementDrag; + m_fTotalDragTimeToZero = fTotalDragTimeToZero; + } + void SetEnableYAxisMovement( _In_ bool bEnableYAxisMovement ) { m_bEnableYAxisMovement = bEnableYAxisMovement; } + void SetEnablePositionMovement( _In_ bool bEnablePositionMovement ) { m_bEnablePositionMovement = bEnablePositionMovement; } + void SetClipToBoundary( _In_ bool bClipToBoundary, _In_opt_ DirectX::XMFLOAT3* pvMinBoundary, _In_opt_ DirectX::XMFLOAT3* pvMaxBoundary ) + { + m_bClipToBoundary = bClipToBoundary; + if( pvMinBoundary ) m_vMinBoundary = *pvMinBoundary; + if( pvMaxBoundary ) m_vMaxBoundary = *pvMaxBoundary; + } + void SetScalers( _In_ float fRotationScaler = 0.01f, _In_ float fMoveScaler = 5.0f ) + { + m_fRotationScaler = fRotationScaler; + m_fMoveScaler = fMoveScaler; + } + void SetNumberOfFramesToSmoothMouseData( _In_ int nFrames ) { if( nFrames > 0 ) m_fFramesToSmoothMouseData = ( float )nFrames; } + void SetResetCursorAfterMove( _In_ bool bResetCursorAfterMove ) { m_bResetCursorAfterMove = bResetCursorAfterMove; } + + // Functions to get state + DirectX::XMMATRIX GetViewMatrix() const { return DirectX::XMLoadFloat4x4( &m_mView ); } + DirectX::XMMATRIX GetProjMatrix() const { return DirectX::XMLoadFloat4x4( &m_mProj ); } + DirectX::XMVECTOR GetEyePt() const { return DirectX::XMLoadFloat3( &m_vEye ); } + DirectX::XMVECTOR GetLookAtPt() const { return DirectX::XMLoadFloat3( &m_vLookAt ); } + float GetNearClip() const { return m_fNearPlane; } + float GetFarClip() const { return m_fFarPlane; } + + bool IsBeingDragged() const { return ( m_bMouseLButtonDown || m_bMouseMButtonDown || m_bMouseRButtonDown ); } + bool IsMouseLButtonDown() const { return m_bMouseLButtonDown; } + bool IsMouseMButtonDown() const { return m_bMouseMButtonDown; } + bool sMouseRButtonDown() const { return m_bMouseRButtonDown; } + +protected: + // Functions to map a WM_KEYDOWN key to a D3DUtil_CameraKeys enum + virtual D3DUtil_CameraKeys MapKey( _In_ UINT nKey ); + + bool IsKeyDown( _In_ BYTE key ) const { return( ( key & KEY_IS_DOWN_MASK ) == KEY_IS_DOWN_MASK ); } + bool WasKeyDown( _In_ BYTE key ) const { return( ( key & KEY_WAS_DOWN_MASK ) == KEY_WAS_DOWN_MASK ); } + + DirectX::XMVECTOR ConstrainToBoundary( _In_ DirectX::FXMVECTOR v ) + { + using namespace DirectX; + + XMVECTOR vMin = XMLoadFloat3( &m_vMinBoundary ); + XMVECTOR vMax = XMLoadFloat3( &m_vMaxBoundary ); + + // Constrain vector to a bounding box + return XMVectorClamp( v, vMin, vMax ); + } + + void UpdateMouseDelta(); + void UpdateVelocity( _In_ float fElapsedTime ); + void GetInput( _In_ bool bGetKeyboardInput, _In_ bool bGetMouseInput, _In_ bool bGetGamepadInput ); + + DirectX::XMFLOAT4X4 m_mView; // View matrix + DirectX::XMFLOAT4X4 m_mProj; // Projection matrix + + DXUT_GAMEPAD m_GamePad[DXUT_MAX_CONTROLLERS]; // XInput controller state + DirectX::XMFLOAT3 m_vGamePadLeftThumb; + DirectX::XMFLOAT3 m_vGamePadRightThumb; + double m_GamePadLastActive[DXUT_MAX_CONTROLLERS]; + + int m_cKeysDown; // Number of camera keys that are down. + BYTE m_aKeys[CAM_MAX_KEYS]; // State of input - KEY_WAS_DOWN_MASK|KEY_IS_DOWN_MASK + DirectX::XMFLOAT3 m_vKeyboardDirection; // Direction vector of keyboard input + POINT m_ptLastMousePosition; // Last absolute position of mouse cursor + int m_nCurrentButtonMask; // mask of which buttons are down + int m_nMouseWheelDelta; // Amount of middle wheel scroll (+/-) + DirectX::XMFLOAT2 m_vMouseDelta; // Mouse relative delta smoothed over a few frames + float m_fFramesToSmoothMouseData; // Number of frames to smooth mouse data over + DirectX::XMFLOAT3 m_vDefaultEye; // Default camera eye position + DirectX::XMFLOAT3 m_vDefaultLookAt; // Default LookAt position + DirectX::XMFLOAT3 m_vEye; // Camera eye position + DirectX::XMFLOAT3 m_vLookAt; // LookAt position + float m_fCameraYawAngle; // Yaw angle of camera + float m_fCameraPitchAngle; // Pitch angle of camera + + RECT m_rcDrag; // Rectangle within which a drag can be initiated. + DirectX::XMFLOAT3 m_vVelocity; // Velocity of camera + DirectX::XMFLOAT3 m_vVelocityDrag; // Velocity drag force + float m_fDragTimer; // Countdown timer to apply drag + float m_fTotalDragTimeToZero; // Time it takes for velocity to go from full to 0 + DirectX::XMFLOAT2 m_vRotVelocity; // Velocity of camera + + float m_fFOV; // Field of view + float m_fAspect; // Aspect ratio + float m_fNearPlane; // Near plane + float m_fFarPlane; // Far plane + + float m_fRotationScaler; // Scaler for rotation + float m_fMoveScaler; // Scaler for movement + + bool m_bMouseLButtonDown; // True if left button is down + bool m_bMouseMButtonDown; // True if middle button is down + bool m_bMouseRButtonDown; // True if right button is down + bool m_bMovementDrag; // If true, then camera movement will slow to a stop otherwise movement is instant + bool m_bInvertPitch; // Invert the pitch axis + bool m_bEnablePositionMovement; // If true, then the user can translate the camera/model + bool m_bEnableYAxisMovement; // If true, then camera can move in the y-axis + bool m_bClipToBoundary; // If true, then the camera will be clipped to the boundary + bool m_bResetCursorAfterMove; // If true, the class will reset the cursor position so that the cursor always has space to move + + DirectX::XMFLOAT3 m_vMinBoundary; // Min point in clip boundary + DirectX::XMFLOAT3 m_vMaxBoundary; // Max point in clip boundary +}; + + +//-------------------------------------------------------------------------------------- +// Simple first person camera class that moves and rotates. +// It allows yaw and pitch but not roll. It uses WM_KEYDOWN and +// GetCursorPos() to respond to keyboard and mouse input and updates the +// view matrix based on input. +//-------------------------------------------------------------------------------------- +class CFirstPersonCamera : public CBaseCamera +{ +public: + CFirstPersonCamera(); + + // Call these from client and use Get*Matrix() to read new matrices + virtual void FrameMove( _In_ float fElapsedTime ) override; + + // Functions to change behavior + void SetRotateButtons( _In_ bool bLeft, _In_ bool bMiddle, _In_ bool bRight, _In_ bool bRotateWithoutButtonDown = false ); + + // Functions to get state + DirectX::XMMATRIX GetWorldMatrix() const { return DirectX::XMLoadFloat4x4( &m_mCameraWorld ); } + + DirectX::XMVECTOR GetWorldRight() const { return DirectX::XMLoadFloat3( reinterpret_cast<const DirectX::XMFLOAT3*>( &m_mCameraWorld._11 ) ); } + DirectX::XMVECTOR GetWorldUp() const { return DirectX::XMLoadFloat3( reinterpret_cast<const DirectX::XMFLOAT3*>( &m_mCameraWorld._21 ) ); } + DirectX::XMVECTOR GetWorldAhead() const { return DirectX::XMLoadFloat3( reinterpret_cast<const DirectX::XMFLOAT3*>( &m_mCameraWorld._31 ) ); } + DirectX::XMVECTOR GetEyePt() const { return DirectX::XMLoadFloat3( reinterpret_cast<const DirectX::XMFLOAT3*>( &m_mCameraWorld._41 ) ); } + +protected: + DirectX::XMFLOAT4X4 m_mCameraWorld; // World matrix of the camera (inverse of the view matrix) + + int m_nActiveButtonMask; // Mask to determine which button to enable for rotation + bool m_bRotateWithoutButtonDown; +}; + + +//-------------------------------------------------------------------------------------- +// Simple model viewing camera class that rotates around the object. +//-------------------------------------------------------------------------------------- +class CModelViewerCamera : public CBaseCamera +{ +public: + CModelViewerCamera(); + + // Call these from client and use Get*Matrix() to read new matrices + virtual LRESULT HandleMessages( _In_ HWND hWnd, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ) override; + virtual void FrameMove( _In_ float fElapsedTime ) override; + + // Functions to change behavior + virtual void SetDragRect( _In_ const RECT& rc ) override; + virtual void Reset() override; + virtual void SetViewParams( _In_ DirectX::FXMVECTOR pvEyePt, _In_ DirectX::FXMVECTOR pvLookatPt ) override; + void SetButtonMasks( _In_ int nRotateModelButtonMask = MOUSE_LEFT_BUTTON, _In_ int nZoomButtonMask = MOUSE_WHEEL, + _In_ int nRotateCameraButtonMask = MOUSE_RIGHT_BUTTON ) + { + m_nRotateModelButtonMask = nRotateModelButtonMask, m_nZoomButtonMask = nZoomButtonMask; + m_nRotateCameraButtonMask = nRotateCameraButtonMask; + } + void SetAttachCameraToModel( _In_ bool bEnable = false ) { m_bAttachCameraToModel = bEnable; } + void SetWindow( _In_ int nWidth, _In_ int nHeight, _In_ float fArcballRadius=0.9f ) + { + m_WorldArcBall.SetWindow( nWidth, nHeight, fArcballRadius ); + m_ViewArcBall.SetWindow( nWidth, nHeight, fArcballRadius ); + } + void SetRadius( _In_ float fDefaultRadius=5.0f, _In_ float fMinRadius=1.0f, _In_ float fMaxRadius=FLT_MAX ) + { + m_fDefaultRadius = m_fRadius = fDefaultRadius; m_fMinRadius = fMinRadius; m_fMaxRadius = fMaxRadius; + m_bDragSinceLastUpdate = true; + } + void SetModelCenter( _In_ const DirectX::XMFLOAT3& vModelCenter ) { m_vModelCenter = vModelCenter; } + void SetLimitPitch( _In_ bool bLimitPitch ) { m_bLimitPitch = bLimitPitch; } + void SetViewQuat( _In_ DirectX::FXMVECTOR q ) + { + m_ViewArcBall.SetQuatNow( q ); + m_bDragSinceLastUpdate = true; + } + void SetWorldQuat( _In_ DirectX::FXMVECTOR q ) + { + m_WorldArcBall.SetQuatNow( q ); + m_bDragSinceLastUpdate = true; + } + + // Functions to get state + DirectX::XMMATRIX GetWorldMatrix() const { return DirectX::XMLoadFloat4x4( &m_mWorld ); } + void SetWorldMatrix( _In_ DirectX::CXMMATRIX mWorld ) + { + XMStoreFloat4x4( &m_mWorld, mWorld ); + m_bDragSinceLastUpdate = true; + } + +protected: + CD3DArcBall m_WorldArcBall; + CD3DArcBall m_ViewArcBall; + DirectX::XMFLOAT3 m_vModelCenter; + DirectX::XMFLOAT4X4 m_mModelLastRot; // Last arcball rotation matrix for model + DirectX::XMFLOAT4X4 m_mModelRot; // Rotation matrix of model + DirectX::XMFLOAT4X4 m_mWorld; // World matrix of model + + int m_nRotateModelButtonMask; + int m_nZoomButtonMask; + int m_nRotateCameraButtonMask; + + bool m_bAttachCameraToModel; + bool m_bLimitPitch; + bool m_bDragSinceLastUpdate; // True if mouse drag has happened since last time FrameMove is called. + float m_fRadius; // Distance from the camera to model + float m_fDefaultRadius; // Distance from the camera to model + float m_fMinRadius; // Min radius + float m_fMaxRadius; // Max radius + + DirectX::XMFLOAT4X4 m_mCameraRotLast; +}; + + +//-------------------------------------------------------------------------------------- +// Manages the mesh, direction, mouse events of a directional arrow that +// rotates around a radius controlled by an arcball +//-------------------------------------------------------------------------------------- +class CDXUTDirectionWidget +{ +public: + CDXUTDirectionWidget(); + + LRESULT HandleMessages( _In_ HWND hWnd, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ); + + HRESULT OnRender( _In_ DirectX::FXMVECTOR color, _In_ DirectX::CXMMATRIX pmView, _In_ DirectX::CXMMATRIX pmProj, _In_ DirectX::FXMVECTOR vEyePt ); + + DirectX::XMVECTOR GetLightDirection() const { return DirectX::XMLoadFloat3( &m_vCurrentDir ); } + void SetLightDirection( _In_ DirectX::FXMVECTOR vDir ) + { + DirectX::XMStoreFloat3( &m_vCurrentDir, vDir ); + m_vDefaultDir = m_vCurrentDir; + } + void SetLightDirection( _In_ DirectX::XMFLOAT3 vDir ) + { + m_vDefaultDir = m_vCurrentDir = vDir; + } + void SetButtonMask( _In_ int nRotate = MOUSE_RIGHT_BUTTON ) { m_nRotateMask = nRotate; } + + float GetRadius() const { return m_fRadius; } + void SetRadius( _In_ float fRadius ) { m_fRadius = fRadius; } + + bool IsBeingDragged() { return m_ArcBall.IsBeingDragged(); } + + static HRESULT WINAPI StaticOnD3D11CreateDevice( _In_ ID3D11Device* pd3dDevice, _In_ ID3D11DeviceContext* pd3dImmediateContext ); + static void WINAPI StaticOnD3D11DestroyDevice(); + +protected: + HRESULT UpdateLightDir(); + + // TODO - need support for Direct3D 11 widget + + DirectX::XMFLOAT4X4 m_mRot; + DirectX::XMFLOAT4X4 m_mRotSnapshot; + float m_fRadius; + int m_nRotateMask; + CD3DArcBall m_ArcBall; + DirectX::XMFLOAT3 m_vDefaultDir; + DirectX::XMFLOAT3 m_vCurrentDir; + DirectX::XMFLOAT4X4 m_mView; +}; diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/DXUTgui.h b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/DXUTgui.h new file mode 100644 index 0000000..870d1e6 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/DXUTgui.h @@ -0,0 +1,1125 @@ +//-------------------------------------------------------------------------------------- +// File: DXUTgui.h +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=320437 +//-------------------------------------------------------------------------------------- +#pragma once + +#include <usp10.h> +#include <dimm.h> + +#ifdef DXUT_AUTOLIB +#pragma comment( lib, "usp10.lib" ) +#endif + +//-------------------------------------------------------------------------------------- +// Defines and macros +//-------------------------------------------------------------------------------------- +#define EVENT_BUTTON_CLICKED 0x0101 +#define EVENT_COMBOBOX_SELECTION_CHANGED 0x0201 +#define EVENT_RADIOBUTTON_CHANGED 0x0301 +#define EVENT_CHECKBOX_CHANGED 0x0401 +#define EVENT_SLIDER_VALUE_CHANGED 0x0501 +#define EVENT_SLIDER_VALUE_CHANGED_UP 0x0502 + +#define EVENT_EDITBOX_STRING 0x0601 +// EVENT_EDITBOX_CHANGE is sent when the listbox content changes +// due to user input. +#define EVENT_EDITBOX_CHANGE 0x0602 +#define EVENT_LISTBOX_ITEM_DBLCLK 0x0701 +// EVENT_LISTBOX_SELECTION is fired off when the selection changes in +// a single selection list box. +#define EVENT_LISTBOX_SELECTION 0x0702 +#define EVENT_LISTBOX_SELECTION_END 0x0703 + + +//-------------------------------------------------------------------------------------- +// Forward declarations +//-------------------------------------------------------------------------------------- +class CDXUTDialogResourceManager; +class CDXUTControl; +class CDXUTButton; +class CDXUTStatic; +class CDXUTCheckBox; +class CDXUTRadioButton; +class CDXUTComboBox; +class CDXUTSlider; +class CDXUTEditBox; +class CDXUTListBox; +class CDXUTScrollBar; +class CDXUTElement; +struct DXUTElementHolder; +struct DXUTTextureNode; +struct DXUTFontNode; +typedef void ( CALLBACK*PCALLBACKDXUTGUIEVENT )( _In_ UINT nEvent, _In_ int nControlID, _In_ CDXUTControl* pControl, + _In_opt_ void* pUserContext ); + + +//-------------------------------------------------------------------------------------- +// Enums for pre-defined control types +//-------------------------------------------------------------------------------------- +enum DXUT_CONTROL_TYPE +{ + DXUT_CONTROL_BUTTON, + DXUT_CONTROL_STATIC, + DXUT_CONTROL_CHECKBOX, + DXUT_CONTROL_RADIOBUTTON, + DXUT_CONTROL_COMBOBOX, + DXUT_CONTROL_SLIDER, + DXUT_CONTROL_EDITBOX, + DXUT_CONTROL_IMEEDITBOX, + DXUT_CONTROL_LISTBOX, + DXUT_CONTROL_SCROLLBAR, +}; + +enum DXUT_CONTROL_STATE +{ + DXUT_STATE_NORMAL = 0, + DXUT_STATE_DISABLED, + DXUT_STATE_HIDDEN, + DXUT_STATE_FOCUS, + DXUT_STATE_MOUSEOVER, + DXUT_STATE_PRESSED, +}; + +#define MAX_CONTROL_STATES 6 + +struct DXUTBlendColor +{ + void Init( _In_ DWORD defaultColor, _In_ DWORD disabledColor = D3DCOLOR_ARGB( 200, 128, 128, 128 ), _In_ DWORD hiddenColor = 0 ); + void Blend( _In_ UINT iState, _In_ float fElapsedTime, _In_ float fRate = 0.7f ); + + DWORD States[ MAX_CONTROL_STATES ]; // Modulate colors for all possible control states + DirectX::XMFLOAT4 Current; + + void SetCurrent( DWORD color ); +}; + + +//----------------------------------------------------------------------------- +// Contains all the display tweakables for a sub-control +//----------------------------------------------------------------------------- +class CDXUTElement +{ +public: + void SetTexture( _In_ UINT texture, _In_ RECT* prcTexture, _In_ DWORD defaultTextureColor = D3DCOLOR_ARGB( 255, 255, 255, 255 ) ); + void SetFont( _In_ UINT font, _In_ DWORD defaultFontColor = D3DCOLOR_ARGB( 255, 255, 255, 255 ), DWORD textFormat = DT_CENTER | DT_VCENTER ); + + void Refresh(); + + UINT iTexture; // Index of the texture for this Element + UINT iFont; // Index of the font for this Element + DWORD dwTextFormat; // The format argument to DrawText + + RECT rcTexture; // Bounding rect of this element on the composite texture + + DXUTBlendColor TextureColor; + DXUTBlendColor FontColor; +}; + + +//----------------------------------------------------------------------------- +// All controls must be assigned to a dialog, which handles +// input and rendering for the controls. +//----------------------------------------------------------------------------- +class CDXUTDialog +{ + friend class CDXUTDialogResourceManager; + +public: + CDXUTDialog(); + ~CDXUTDialog(); + + // Need to call this now + void Init( _In_ CDXUTDialogResourceManager* pManager, _In_ bool bRegisterDialog = true ); + void Init( _In_ CDXUTDialogResourceManager* pManager, _In_ bool bRegisterDialog, + _In_z_ LPCWSTR pszControlTextureFilename ); + void Init( _In_ CDXUTDialogResourceManager* pManager, _In_ bool bRegisterDialog, + _In_z_ LPCWSTR szControlTextureResourceName, _In_ HMODULE hControlTextureResourceModule ); + + // Windows message handler + bool MsgProc( _In_ HWND hWnd, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ); + + // Control creation + HRESULT AddStatic( _In_ int ID, _In_z_ LPCWSTR strText, _In_ int x, _In_ int y, _In_ int width, _In_ int height, _In_ bool bIsDefault=false, + _Out_opt_ CDXUTStatic** ppCreated = nullptr ); + HRESULT AddButton( _In_ int ID, _In_z_ LPCWSTR strText, _In_ int x, _In_ int y, _In_ int width, _In_ int height, _In_ UINT nHotkey=0, + _In_ bool bIsDefault=false, _Out_opt_ CDXUTButton** ppCreated = nullptr ); + HRESULT AddCheckBox( _In_ int ID, _In_z_ LPCWSTR strText, _In_ int x, _In_ int y, _In_ int width, _In_ int height, _In_ bool bChecked=false, + _In_ UINT nHotkey=0, _In_ bool bIsDefault=false, _Out_opt_ CDXUTCheckBox** ppCreated = nullptr ); + HRESULT AddRadioButton( _In_ int ID, _In_ UINT nButtonGroup, _In_z_ LPCWSTR strText, _In_ int x, _In_ int y, _In_ int width, + _In_ int height, _In_ bool bChecked=false, _In_ UINT nHotkey=0, _In_ bool bIsDefault=false, + _Out_opt_ CDXUTRadioButton** ppCreated = nullptr ); + HRESULT AddComboBox( _In_ int ID, _In_ int x, _In_ int y, _In_ int width, _In_ int height, _In_ UINT nHotKey=0, _In_ bool bIsDefault=false, + _Out_opt_ CDXUTComboBox** ppCreated = nullptr ); + HRESULT AddSlider( _In_ int ID, _In_ int x, _In_ int y, _In_ int width, _In_ int height, _In_ int min=0, _In_ int max=100, _In_ int value=50, + _In_ bool bIsDefault=false, _Out_opt_ CDXUTSlider** ppCreated = nullptr ); + // AddIMEEditBox has been renamed into DXUTguiIME.cpp as CDXUTIMEEditBox::CreateIMEEditBox + HRESULT AddEditBox( _In_ int ID, _In_z_ LPCWSTR strText, _In_ int x, _In_ int y, _In_ int width, _In_ int height, _In_ bool bIsDefault=false, + _Out_opt_ CDXUTEditBox** ppCreated = nullptr ); + HRESULT AddListBox( _In_ int ID, _In_ int x, _In_ int y, _In_ int width, _In_ int height, _In_ DWORD dwStyle=0, + _Out_opt_ CDXUTListBox** ppCreated = nullptr ); + HRESULT AddControl( _In_ CDXUTControl* pControl ); + HRESULT InitControl( _In_ CDXUTControl* pControl ); + + // Control retrieval + CDXUTStatic* GetStatic( _In_ int ID ) const + { + return reinterpret_cast<CDXUTStatic*>( GetControl( ID, DXUT_CONTROL_STATIC ) ); + } + CDXUTButton* GetButton( _In_ int ID ) const + { + return reinterpret_cast<CDXUTButton*>( GetControl(ID, DXUT_CONTROL_BUTTON) ); + } + CDXUTCheckBox* GetCheckBox( _In_ int ID ) const + { + return reinterpret_cast<CDXUTCheckBox*>( GetControl(ID, DXUT_CONTROL_CHECKBOX) ); + } + CDXUTRadioButton* GetRadioButton( _In_ int ID ) const + { + return reinterpret_cast<CDXUTRadioButton*>( GetControl(ID, DXUT_CONTROL_RADIOBUTTON) ); + } + CDXUTComboBox* GetComboBox( _In_ int ID ) const + { + return reinterpret_cast<CDXUTComboBox*>( GetControl(ID, DXUT_CONTROL_COMBOBOX) ); + } + CDXUTSlider* GetSlider( _In_ int ID ) const + { + return reinterpret_cast<CDXUTSlider*>( GetControl(ID, DXUT_CONTROL_SLIDER) ); + } + CDXUTEditBox* GetEditBox( _In_ int ID ) const + { + return reinterpret_cast<CDXUTEditBox*>( GetControl(ID, DXUT_CONTROL_EDITBOX) ); + } + CDXUTListBox* GetListBox( _In_ int ID ) const + { + return reinterpret_cast<CDXUTListBox*>( GetControl(ID, DXUT_CONTROL_LISTBOX) ); + } + + CDXUTControl* GetControl( _In_ int ID ) const; + CDXUTControl* GetControl( _In_ int ID, _In_ UINT nControlType ) const; + CDXUTControl* GetControlAtPoint( _In_ const POINT& pt ) const; + + bool GetControlEnabled( _In_ int ID ) const; + void SetControlEnabled( _In_ int ID, _In_ bool bEnabled ); + + void ClearRadioButtonGroup( _In_ UINT nGroup ); + void ClearComboBox( _In_ int ID ); + + // Access the default display Elements used when adding new controls + HRESULT SetDefaultElement( _In_ UINT nControlType, _In_ UINT iElement, _In_ CDXUTElement* pElement ); + CDXUTElement* GetDefaultElement( _In_ UINT nControlType, _In_ UINT iElement ) const; + + // Methods called by controls + void SendEvent( _In_ UINT nEvent, _In_ bool bTriggeredByUser, _In_ CDXUTControl* pControl ); + void RequestFocus( _In_ CDXUTControl* pControl ); + + // Render helpers + HRESULT DrawRect( _In_ const RECT* pRect, _In_ DWORD color ); + HRESULT DrawSprite( _In_ CDXUTElement* pElement, _In_ const RECT* prcDest, _In_ float fDepth ); + HRESULT DrawSprite11( _In_ CDXUTElement* pElement, _In_ const RECT* prcDest, _In_ float fDepth ); + HRESULT CalcTextRect( _In_z_ LPCWSTR strText, _In_ CDXUTElement* pElement, _In_ const RECT* prcDest, _In_ int nCount = -1 ); + HRESULT DrawText( _In_z_ LPCWSTR strText, _In_ CDXUTElement* pElement, _In_ const RECT* prcDest, _In_ bool bShadow = false, + _In_ bool bCenter = false ); + + // Attributes + bool GetVisible() const { return m_bVisible; } + void SetVisible( _In_ bool bVisible ) { m_bVisible = bVisible; } + bool GetMinimized() const { return m_bMinimized; } + void SetMinimized( _In_ bool bMinimized ) {m_bMinimized = bMinimized; } + void SetBackgroundColors( _In_ DWORD colorAllCorners ) { SetBackgroundColors( colorAllCorners, colorAllCorners, colorAllCorners, colorAllCorners ); } + void SetBackgroundColors( _In_ DWORD colorTopLeft, _In_ DWORD colorTopRight, _In_ DWORD colorBottomLeft, _In_ DWORD colorBottomRight ); + void EnableCaption( _In_ bool bEnable ) { m_bCaption = bEnable; } + int GetCaptionHeight() const { return m_nCaptionHeight; } + void SetCaptionHeight( _In_ int nHeight ) { m_nCaptionHeight = nHeight; } + void SetCaptionText( _In_ const WCHAR* pwszText ) { wcscpy_s( m_wszCaption, sizeof( m_wszCaption ) / sizeof( m_wszCaption[0] ), pwszText ); } + void GetLocation( _Out_ POINT& Pt ) const + { + Pt.x = m_x; + Pt.y = m_y; + } + void SetLocation( _In_ int x, _In_ int y ) + { + m_x = x; + m_y = y; + } + void SetSize( _In_ int width, _In_ int height ) + { + m_width = width; + m_height = height; + } + int GetWidth() const { return m_width; } + int GetHeight() const { return m_height; } + + static void WINAPI SetRefreshTime( _In_ float fTime ) { s_fTimeRefresh = fTime; } + + static CDXUTControl* WINAPI GetNextControl( _In_ CDXUTControl* pControl ); + static CDXUTControl* WINAPI GetPrevControl( _In_ CDXUTControl* pControl ); + + void RemoveControl( _In_ int ID ); + void RemoveAllControls(); + + // Sets the callback used to notify the app of control events + void SetCallback( _In_ PCALLBACKDXUTGUIEVENT pCallback, _In_opt_ void* pUserContext = nullptr ); + void EnableNonUserEvents( _In_ bool bEnable ) { m_bNonUserEvents = bEnable; } + void EnableKeyboardInput( _In_ bool bEnable ) { m_bKeyboardInput = bEnable; } + void EnableMouseInput( _In_ bool bEnable ) { m_bMouseInput = bEnable; } + bool IsKeyboardInputEnabled() const { return m_bKeyboardInput; } + + // Device state notification + void Refresh(); + HRESULT OnRender( _In_ float fElapsedTime ); + + // Shared resource access. Indexed fonts and textures are shared among + // all the controls. + HRESULT SetFont( _In_ UINT index, _In_z_ LPCWSTR strFaceName, _In_ LONG height, _In_ LONG weight ); + DXUTFontNode* GetFont( _In_ UINT index ) const; + + HRESULT SetTexture( _In_ UINT index, _In_z_ LPCWSTR strFilename ); + HRESULT SetTexture( _In_ UINT index, _In_z_ LPCWSTR strResourceName, _In_ HMODULE hResourceModule ); + DXUTTextureNode* GetTexture( _In_ UINT index ) const; + + CDXUTDialogResourceManager* GetManager() const { return m_pManager; } + + static void WINAPI ClearFocus(); + void FocusDefaultControl(); + + bool m_bNonUserEvents; + bool m_bKeyboardInput; + bool m_bMouseInput; + +private: + int m_nDefaultControlID; + + static double s_fTimeRefresh; + double m_fTimeLastRefresh; + + // Initialize default Elements + void InitDefaultElements(); + + // Windows message handlers + void OnMouseMove( _In_ const POINT& pt ); + void OnMouseUp( _In_ const POINT& pt ); + + void SetNextDialog( _In_ CDXUTDialog* pNextDialog ); + + // Control events + bool OnCycleFocus( _In_ bool bForward ); + + static CDXUTControl* s_pControlFocus; // The control which has focus + static CDXUTControl* s_pControlPressed; // The control currently pressed + + CDXUTControl* m_pControlMouseOver; // The control which is hovered over + + bool m_bVisible; + bool m_bCaption; + bool m_bMinimized; + bool m_bDrag; + WCHAR m_wszCaption[256]; + + int m_x; + int m_y; + int m_width; + int m_height; + int m_nCaptionHeight; + + DWORD m_colorTopLeft; + DWORD m_colorTopRight; + DWORD m_colorBottomLeft; + DWORD m_colorBottomRight; + + CDXUTDialogResourceManager* m_pManager; + PCALLBACKDXUTGUIEVENT m_pCallbackEvent; + void* m_pCallbackEventUserContext; + + std::vector<int> m_Textures; // Index into m_TextureCache; + std::vector<int> m_Fonts; // Index into m_FontCache; + + std::vector<CDXUTControl*> m_Controls; + std::vector<DXUTElementHolder*> m_DefaultElements; + + CDXUTElement m_CapElement; // Element for the caption + + CDXUTDialog* m_pNextDialog; + CDXUTDialog* m_pPrevDialog; +}; + + +//-------------------------------------------------------------------------------------- +// Structs for shared resources +//-------------------------------------------------------------------------------------- +struct DXUTTextureNode +{ + bool bFileSource; // True if this texture is loaded from a file. False if from resource. + HMODULE hResourceModule; + int nResourceID; // Resource ID. If 0, string-based ID is used and stored in strFilename. + WCHAR strFilename[MAX_PATH]; + DWORD dwWidth; + DWORD dwHeight; + ID3D11Texture2D* pTexture11; + ID3D11ShaderResourceView* pTexResView11; +}; + +struct DXUTFontNode +{ + WCHAR strFace[MAX_PATH]; + LONG nHeight; + LONG nWeight; +}; + +struct DXUTSpriteVertex +{ + DirectX::XMFLOAT3 vPos; + DirectX::XMFLOAT4 vColor; + DirectX::XMFLOAT2 vTex; +}; + + +//----------------------------------------------------------------------------- +// Manages shared resources of dialogs +//----------------------------------------------------------------------------- +class CDXUTDialogResourceManager +{ +public: + CDXUTDialogResourceManager(); + ~CDXUTDialogResourceManager(); + + bool MsgProc( _In_ HWND hWnd, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ); + + // D3D11 specific + HRESULT OnD3D11CreateDevice( _In_ ID3D11Device* pd3dDevice, _In_ ID3D11DeviceContext* pd3d11DeviceContext ); + HRESULT OnD3D11ResizedSwapChain( _In_ ID3D11Device* pd3dDevice, _In_ const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc ); + void OnD3D11ReleasingSwapChain(); + void OnD3D11DestroyDevice(); + void StoreD3D11State( _In_ ID3D11DeviceContext* pd3dImmediateContext ); + void RestoreD3D11State( _In_ ID3D11DeviceContext* pd3dImmediateContext ); + void ApplyRenderUI11( _In_ ID3D11DeviceContext* pd3dImmediateContext ); + void ApplyRenderUIUntex11( _In_ ID3D11DeviceContext* pd3dImmediateContext ); + void BeginSprites11( ); + void EndSprites11( _In_ ID3D11Device* pd3dDevice, _In_ ID3D11DeviceContext* pd3dImmediateContext ); + + ID3D11Device* GetD3D11Device() const { return m_pd3d11Device; } + ID3D11DeviceContext* GetD3D11DeviceContext() const { return m_pd3d11DeviceContext; } + + DXUTFontNode* GetFontNode( _In_ size_t iIndex ) const { return m_FontCache[ iIndex ]; } + DXUTTextureNode* GetTextureNode( _In_ size_t iIndex ) const { return m_TextureCache[ iIndex ]; } + + int AddFont( _In_z_ LPCWSTR strFaceName, _In_ LONG height, _In_ LONG weight ); + int AddTexture( _In_z_ LPCWSTR strFilename ); + int AddTexture( _In_z_ LPCWSTR strResourceName, _In_ HMODULE hResourceModule ); + + bool RegisterDialog( _In_ CDXUTDialog* pDialog ); + void UnregisterDialog( _In_ CDXUTDialog* pDialog ); + void EnableKeyboardInputForAllDialogs(); + + // Shared between all dialogs + + // D3D11 + // Shaders + ID3D11VertexShader* m_pVSRenderUI11; + ID3D11PixelShader* m_pPSRenderUI11; + ID3D11PixelShader* m_pPSRenderUIUntex11; + + // States + ID3D11DepthStencilState* m_pDepthStencilStateUI11; + ID3D11RasterizerState* m_pRasterizerStateUI11; + ID3D11BlendState* m_pBlendStateUI11; + ID3D11SamplerState* m_pSamplerStateUI11; + + // Stored states + ID3D11DepthStencilState* m_pDepthStencilStateStored11; + UINT m_StencilRefStored11; + ID3D11RasterizerState* m_pRasterizerStateStored11; + ID3D11BlendState* m_pBlendStateStored11; + float m_BlendFactorStored11[4]; + UINT m_SampleMaskStored11; + ID3D11SamplerState* m_pSamplerStateStored11; + + ID3D11InputLayout* m_pInputLayout11; + ID3D11Buffer* m_pVBScreenQuad11; + + // Sprite workaround + ID3D11Buffer* m_pSpriteBuffer11; + UINT m_SpriteBufferBytes11; + std::vector<DXUTSpriteVertex> m_SpriteVertices; + + UINT m_nBackBufferWidth; + UINT m_nBackBufferHeight; + + std::vector<CDXUTDialog*> m_Dialogs; // Dialogs registered + +protected: + // D3D11 specific + ID3D11Device* m_pd3d11Device; + ID3D11DeviceContext* m_pd3d11DeviceContext; + HRESULT CreateTexture11( _In_ UINT index ); + + std::vector<DXUTTextureNode*> m_TextureCache; // Shared textures + std::vector<DXUTFontNode*> m_FontCache; // Shared fonts +}; + + +//----------------------------------------------------------------------------- +// Base class for controls +//----------------------------------------------------------------------------- +class CDXUTControl +{ +public: + CDXUTControl( _In_opt_ CDXUTDialog* pDialog = nullptr ); + virtual ~CDXUTControl(); + + virtual HRESULT OnInit() { return S_OK; } + virtual void Refresh(); + virtual void Render( _In_ float fElapsedTime ) { UNREFERENCED_PARAMETER(fElapsedTime); } + + // Windows message handler + virtual bool MsgProc( _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ) + { + UNREFERENCED_PARAMETER(uMsg); + UNREFERENCED_PARAMETER(wParam); + UNREFERENCED_PARAMETER(lParam); + return false; + } + + virtual bool HandleKeyboard( _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ) + { + UNREFERENCED_PARAMETER(uMsg); + UNREFERENCED_PARAMETER(wParam); + UNREFERENCED_PARAMETER(lParam); + return false; + } + virtual bool HandleMouse( _In_ UINT uMsg, _In_ const POINT& pt, _In_ WPARAM wParam, _In_ LPARAM lParam ) + { + UNREFERENCED_PARAMETER(uMsg); + UNREFERENCED_PARAMETER(pt); + UNREFERENCED_PARAMETER(wParam); + UNREFERENCED_PARAMETER(lParam); + return false; + } + + virtual bool CanHaveFocus() { return false; } + virtual void OnFocusIn() { m_bHasFocus = true; } + virtual void OnFocusOut() { m_bHasFocus = false; } + virtual void OnMouseEnter() { m_bMouseOver = true; } + virtual void OnMouseLeave() { m_bMouseOver = false; } + virtual void OnHotkey() { } + + virtual bool ContainsPoint( _In_ const POINT& pt ) { return PtInRect( &m_rcBoundingBox, pt ) != 0; } + + virtual void SetEnabled( _In_ bool bEnabled ) { m_bEnabled = bEnabled; } + virtual bool GetEnabled() const { return m_bEnabled; } + virtual void SetVisible( _In_ bool bVisible ) { m_bVisible = bVisible; } + virtual bool GetVisible() const { return m_bVisible; } + + UINT GetType() const { return m_Type; } + + int GetID() const { return m_ID; } + void SetID( _In_ int ID ) { m_ID = ID; } + + void SetLocation( _In_ int x, _In_ int y ) + { + m_x = x; + m_y = y; + UpdateRects(); + } + void SetSize( int width, int height ) + { + m_width = width; + m_height = height; + UpdateRects(); + } + + void SetHotkey( _In_ UINT nHotkey ) { m_nHotkey = nHotkey; } + UINT GetHotkey() const { return m_nHotkey; } + + void SetUserData( _In_opt_ void* pUserData ) { m_pUserData = pUserData; } + void* GetUserData() const { return m_pUserData; } + + virtual void SetTextColor( _In_ DWORD Color ); + CDXUTElement* GetElement( _In_ UINT iElement ) const { return m_Elements[ iElement ]; } + HRESULT SetElement( _In_ UINT iElement, _In_ CDXUTElement* pElement ); + + bool m_bVisible; // Shown/hidden flag + bool m_bMouseOver; // Mouse pointer is above control + bool m_bHasFocus; // Control has input focus + bool m_bIsDefault; // Is the default control + + // Size, scale, and positioning members + int m_x, m_y; + int m_width, m_height; + + // These members are set by the container + CDXUTDialog* m_pDialog; // Parent container + UINT m_Index; // Index within the control list + + std::vector<CDXUTElement*> m_Elements; // All display elements + +protected: + virtual void UpdateRects(); + + int m_ID; // ID number + DXUT_CONTROL_TYPE m_Type; // Control type, set once in constructor + UINT m_nHotkey; // Virtual key code for this control's hotkey + void* m_pUserData; // Data associated with this control that is set by user. + + bool m_bEnabled; // Enabled/disabled flag + + RECT m_rcBoundingBox; // Rectangle defining the active region of the control +}; + + +//----------------------------------------------------------------------------- +// Contains all the display information for a given control type +//----------------------------------------------------------------------------- +struct DXUTElementHolder +{ + UINT nControlType; + UINT iElement; + + CDXUTElement Element; +}; + + +//----------------------------------------------------------------------------- +// Static control +//----------------------------------------------------------------------------- +class CDXUTStatic : public CDXUTControl +{ +public: + CDXUTStatic( _In_opt_ CDXUTDialog* pDialog = nullptr ); + + virtual void Render( _In_ float fElapsedTime ) override; + virtual bool ContainsPoint( _In_ const POINT& pt ) override + { + UNREFERENCED_PARAMETER( pt ); + return false; + } + + HRESULT GetTextCopy( _Out_writes_(bufferCount) LPWSTR strDest, _In_ UINT bufferCount ) const; + LPCWSTR GetText() const { return m_strText; } + HRESULT SetText( _In_z_ LPCWSTR strText ); + +protected: + WCHAR m_strText[MAX_PATH]; // Window text +}; + + +//----------------------------------------------------------------------------- +// Button control +//----------------------------------------------------------------------------- +class CDXUTButton : public CDXUTStatic +{ +public: + CDXUTButton( _In_opt_ CDXUTDialog* pDialog = nullptr ); + + virtual bool HandleKeyboard( _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ) override; + virtual bool HandleMouse( _In_ UINT uMsg, _In_ const POINT& pt, _In_ WPARAM wParam, _In_ LPARAM lParam ) override; + virtual void OnHotkey() override + { + if( m_pDialog->IsKeyboardInputEnabled() ) m_pDialog->RequestFocus( this ); + m_pDialog->SendEvent( EVENT_BUTTON_CLICKED, true, this ); + } + + virtual bool ContainsPoint( _In_ const POINT& pt ) override + { + return PtInRect( &m_rcBoundingBox, pt ) != 0; + } + virtual bool CanHaveFocus() override + { + return ( m_bVisible && m_bEnabled ); + } + + virtual void Render( _In_ float fElapsedTime ) override; + +protected: + bool m_bPressed; +}; + + +//----------------------------------------------------------------------------- +// CheckBox control +//----------------------------------------------------------------------------- +class CDXUTCheckBox : public CDXUTButton +{ +public: + CDXUTCheckBox( _In_opt_ CDXUTDialog* pDialog = nullptr ); + + virtual bool HandleKeyboard( _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ) override; + virtual bool HandleMouse( _In_ UINT uMsg, _In_ const POINT& pt, _In_ WPARAM wParam, _In_ LPARAM lParam ) override; + virtual void OnHotkey() override + { + if( m_pDialog->IsKeyboardInputEnabled() ) m_pDialog->RequestFocus( this ); + SetCheckedInternal( !m_bChecked, true ); + } + + virtual bool ContainsPoint( _In_ const POINT& pt ) override; + virtual void UpdateRects() override; + + virtual void Render( _In_ float fElapsedTime ) override; + + bool GetChecked() const { return m_bChecked; } + void SetChecked( _In_ bool bChecked ) { SetCheckedInternal( bChecked, false ); } + +protected: + virtual void SetCheckedInternal( _In_ bool bChecked, _In_ bool bFromInput ); + + bool m_bChecked; + RECT m_rcButton; + RECT m_rcText; +}; + + +//----------------------------------------------------------------------------- +// RadioButton control +//----------------------------------------------------------------------------- +class CDXUTRadioButton : public CDXUTCheckBox +{ +public: + CDXUTRadioButton( _In_opt_ CDXUTDialog* pDialog = nullptr ); + + virtual bool HandleKeyboard( _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ) override; + virtual bool HandleMouse( _In_ UINT uMsg, _In_ const POINT& pt, _In_ WPARAM wParam, _In_ LPARAM lParam ) override; + virtual void OnHotkey() override + { + if( m_pDialog->IsKeyboardInputEnabled() ) m_pDialog->RequestFocus( this ); + SetCheckedInternal( true, true, true ); + } + + void SetChecked( _In_ bool bChecked, _In_ bool bClearGroup=true ) { SetCheckedInternal( bChecked, bClearGroup, false ); } + void SetButtonGroup( _In_ UINT nButtonGroup ) { m_nButtonGroup = nButtonGroup; } + UINT GetButtonGroup() const { return m_nButtonGroup; } + +protected: + virtual void SetCheckedInternal( _In_ bool bChecked, _In_ bool bClearGroup, _In_ bool bFromInput ); + UINT m_nButtonGroup; +}; + + +//----------------------------------------------------------------------------- +// Scrollbar control +//----------------------------------------------------------------------------- +class CDXUTScrollBar : public CDXUTControl +{ +public: + CDXUTScrollBar( _In_opt_ CDXUTDialog* pDialog = nullptr ); + virtual ~CDXUTScrollBar(); + + virtual bool HandleKeyboard( _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ) override; + virtual bool HandleMouse( _In_ UINT uMsg, _In_ const POINT& pt, _In_ WPARAM wParam, _In_ LPARAM lParam ) override; + virtual bool MsgProc( _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ) override; + + virtual void Render( _In_ float fElapsedTime ) override; + virtual void UpdateRects() override; + + void SetTrackRange( _In_ int nStart, _In_ int nEnd ); + int GetTrackPos() const { return m_nPosition; } + void SetTrackPos( _In_ int nPosition ) + { + m_nPosition = nPosition; + Cap(); + UpdateThumbRect(); + } + int GetPageSize() const { return m_nPageSize; } + void SetPageSize( _In_ int nPageSize ) + { + m_nPageSize = nPageSize; + Cap(); + UpdateThumbRect(); + } + + void Scroll( _In_ int nDelta ); // Scroll by nDelta items (plus or minus) + void ShowItem( _In_ int nIndex ); // Ensure that item nIndex is displayed, scroll if necessary + +protected: + // ARROWSTATE indicates the state of the arrow buttons. + // CLEAR No arrow is down. + // CLICKED_UP Up arrow is clicked. + // CLICKED_DOWN Down arrow is clicked. + // HELD_UP Up arrow is held down for sustained period. + // HELD_DOWN Down arrow is held down for sustained period. + enum ARROWSTATE + { + CLEAR, + CLICKED_UP, + CLICKED_DOWN, + HELD_UP, + HELD_DOWN + }; + + void UpdateThumbRect(); + void Cap(); // Clips position at boundaries. Ensures it stays within legal range. + + bool m_bShowThumb; + bool m_bDrag; + RECT m_rcUpButton; + RECT m_rcDownButton; + RECT m_rcTrack; + RECT m_rcThumb; + int m_nPosition; // Position of the first displayed item + int m_nPageSize; // How many items are displayable in one page + int m_nStart; // First item + int m_nEnd; // The index after the last item + POINT m_LastMouse;// Last mouse position + ARROWSTATE m_Arrow; // State of the arrows + double m_dArrowTS; // Timestamp of last arrow event. +}; + + +//----------------------------------------------------------------------------- +// ListBox control +//----------------------------------------------------------------------------- +struct DXUTListBoxItem +{ + WCHAR strText[256]; + void* pData; + + RECT rcActive; + bool bSelected; +}; + +class CDXUTListBox : public CDXUTControl +{ +public: + CDXUTListBox( _In_opt_ CDXUTDialog* pDialog = nullptr ); + virtual ~CDXUTListBox(); + + virtual HRESULT OnInit() override + { + return m_pDialog->InitControl( &m_ScrollBar ); + } + virtual bool CanHaveFocus() override + { + return ( m_bVisible && m_bEnabled ); + } + virtual bool HandleKeyboard( _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ) override; + virtual bool HandleMouse( _In_ UINT uMsg, _In_ const POINT& pt, _In_ WPARAM wParam, _In_ LPARAM lParam ) override; + virtual bool MsgProc( _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ) override; + + virtual void Render( _In_ float fElapsedTime ) override; + virtual void UpdateRects() override; + + DWORD GetStyle() const { return m_dwStyle; } + size_t GetSize() const { return m_Items.size(); } + void SetStyle( _In_ DWORD dwStyle ) { m_dwStyle = dwStyle; } + int GetScrollBarWidth() const{ return m_nSBWidth; } + void SetScrollBarWidth( _In_ int nWidth ) + { + m_nSBWidth = nWidth; + UpdateRects(); + } + void SetBorder( _In_ int nBorder, _In_ int nMargin ) + { + m_nBorder = nBorder; + m_nMargin = nMargin; + } + HRESULT AddItem( _In_z_ const WCHAR* wszText, _In_opt_ void* pData ); + HRESULT InsertItem( _In_ int nIndex, _In_z_ const WCHAR* wszText, _In_opt_ void* pData ); + void RemoveItem( _In_ int nIndex ); + void RemoveAllItems(); + + DXUTListBoxItem* GetItem( _In_ int nIndex ) const; + int GetSelectedIndex( _In_ int nPreviousSelected = -1 ) const; + DXUTListBoxItem* GetSelectedItem( _In_ int nPreviousSelected = -1 ) const + { + return GetItem( GetSelectedIndex( nPreviousSelected ) ); + } + void SelectItem( _In_ int nNewIndex ); + + enum STYLE + { + MULTISELECTION = 1 + }; + +protected: + RECT m_rcText; // Text rendering bound + RECT m_rcSelection; // Selection box bound + CDXUTScrollBar m_ScrollBar; + int m_nSBWidth; + int m_nBorder; + int m_nMargin; + int m_nTextHeight; // Height of a single line of text + DWORD m_dwStyle; // List box style + int m_nSelected; // Index of the selected item for single selection list box + int m_nSelStart; // Index of the item where selection starts (for handling multi-selection) + bool m_bDrag; // Whether the user is dragging the mouse to select + + std::vector<DXUTListBoxItem*> m_Items; +}; + + +//----------------------------------------------------------------------------- +// ComboBox control +//----------------------------------------------------------------------------- +struct DXUTComboBoxItem +{ + WCHAR strText[256]; + void* pData; + + RECT rcActive; + bool bVisible; +}; + +class CDXUTComboBox : public CDXUTButton +{ +public: + CDXUTComboBox( _In_opt_ CDXUTDialog* pDialog = nullptr ); + virtual ~CDXUTComboBox(); + + virtual void SetTextColor( _In_ DWORD Color ) override; + virtual HRESULT OnInit() override + { + return m_pDialog->InitControl( &m_ScrollBar ); + } + + virtual bool HandleKeyboard( _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ) override; + virtual bool HandleMouse( _In_ UINT uMsg, _In_ const POINT& pt, _In_ WPARAM wParam, _In_ LPARAM lParam ) override; + virtual void OnHotkey() override; + + virtual bool CanHaveFocus() override + { + return ( m_bVisible && m_bEnabled ); + } + virtual void OnFocusOut() override; + virtual void Render( _In_ float fElapsedTime ) override; + + virtual void UpdateRects() override; + + HRESULT AddItem( _In_z_ const WCHAR* strText, _In_opt_ void* pData ); + void RemoveAllItems(); + void RemoveItem( _In_ UINT index ); + bool ContainsItem( _In_z_ const WCHAR* strText, _In_ UINT iStart=0 ); + int FindItem( _In_z_ const WCHAR* strText, _In_ UINT iStart=0 ) const; + void* GetItemData( _In_z_ const WCHAR* strText ) const; + void* GetItemData( _In_ int nIndex ) const; + void SetDropHeight( _In_ UINT nHeight ) + { + m_nDropHeight = nHeight; + UpdateRects(); + } + int GetScrollBarWidth() const { return m_nSBWidth; } + void SetScrollBarWidth( _In_ int nWidth ) + { + m_nSBWidth = nWidth; + UpdateRects(); + } + + int GetSelectedIndex() const { return m_iSelected; } + void* GetSelectedData() const; + DXUTComboBoxItem* GetSelectedItem() const; + + UINT GetNumItems() { return static_cast<UINT>( m_Items.size() ); } + DXUTComboBoxItem* GetItem( _In_ UINT index ) { return m_Items[ index ]; } + + HRESULT SetSelectedByIndex( _In_ UINT index ); + HRESULT SetSelectedByText( _In_z_ const WCHAR* strText ); + HRESULT SetSelectedByData( _In_ void* pData ); + +protected: + int m_iSelected; + int m_iFocused; + int m_nDropHeight; + CDXUTScrollBar m_ScrollBar; + int m_nSBWidth; + + bool m_bOpened; + + RECT m_rcText; + RECT m_rcButton; + RECT m_rcDropdown; + RECT m_rcDropdownText; + + std::vector<DXUTComboBoxItem*> m_Items; +}; + + +//----------------------------------------------------------------------------- +// Slider control +//----------------------------------------------------------------------------- +class CDXUTSlider : public CDXUTControl +{ +public: + CDXUTSlider( _In_opt_ CDXUTDialog* pDialog = nullptr ); + + virtual bool ContainsPoint( _In_ const POINT& pt ) override; + virtual bool CanHaveFocus() override + { + return ( m_bVisible && m_bEnabled ); + } + virtual bool HandleKeyboard( _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ) override; + virtual bool HandleMouse( _In_ UINT uMsg, _In_ const POINT& pt, _In_ WPARAM wParam, _In_ LPARAM lParam ) override; + + virtual void UpdateRects() override; + + virtual void Render( _In_ float fElapsedTime ) override; + + void SetValue( int nValue ) { SetValueInternal( nValue, false ); } + int GetValue() const { return m_nValue; } + + void GetRange( _Out_ int& nMin, _Out_ int& nMax ) const + { + nMin = m_nMin; + nMax = m_nMax; + } + void SetRange( _In_ int nMin, _In_ int nMax ); + +protected: + void SetValueInternal( _In_ int nValue, _In_ bool bFromInput ); + int ValueFromPos( _In_ int x ); + + int m_nValue; + + int m_nMin; + int m_nMax; + + int m_nDragX; // Mouse position at start of drag + int m_nDragOffset; // Drag offset from the center of the button + int m_nButtonX; + + bool m_bPressed; + RECT m_rcButton; +}; + + +//----------------------------------------------------------------------------- +// CUniBuffer class for the edit control +//----------------------------------------------------------------------------- +class CUniBuffer +{ +public: + CUniBuffer( _In_ int nInitialSize = 1 ); + ~CUniBuffer(); + + size_t GetBufferSize() const { return m_nBufferSize; } + bool SetBufferSize( _In_ int nSize ); + int GetTextSize() const { return (int)wcslen( m_pwszBuffer ); } + const WCHAR* GetBuffer() const + { + return m_pwszBuffer; + } + const WCHAR& operator[]( _In_ int n ) const + { + return m_pwszBuffer[n]; + } + WCHAR& operator[]( _In_ int n ); + DXUTFontNode* GetFontNode() const { return m_pFontNode; } + void SetFontNode( _In_opt_ DXUTFontNode* pFontNode ) { m_pFontNode = pFontNode; } + void Clear(); + + bool InsertChar( _In_ int nIndex, _In_ WCHAR wChar ); + // Inserts the char at specified index. If nIndex == -1, insert to the end. + + bool RemoveChar( _In_ int nIndex ); + // Removes the char at specified index. If nIndex == -1, remove the last char. + + bool InsertString( _In_ int nIndex, _In_z_ const WCHAR* pStr, _In_ int nCount = -1 ); + // Inserts the first nCount characters of the string pStr at specified index. If nCount == -1, the entire string is inserted. If nIndex == -1, insert to the end. + + bool SetText( _In_z_ LPCWSTR wszText ); + + // Uniscribe + bool CPtoX( _In_ int nCP, _In_ bool bTrail, _Out_ int* pX ); + bool XtoCP( _In_ int nX, _Out_ int* pCP, _Out_ int* pnTrail ); + void GetPriorItemPos( _In_ int nCP, _Out_ int* pPrior ); + void GetNextItemPos( _In_ int nCP, _Out_ int* pPrior ); + +private: + HRESULT Analyse(); // Uniscribe -- Analyse() analyses the string in the buffer + + WCHAR* m_pwszBuffer; // Buffer to hold text + int m_nBufferSize; // Size of the buffer allocated, in characters + + // Uniscribe-specific + DXUTFontNode* m_pFontNode; // Font node for the font that this buffer uses + bool m_bAnalyseRequired; // True if the string has changed since last analysis. + SCRIPT_STRING_ANALYSIS m_Analysis; // Analysis for the current string +}; + + +//----------------------------------------------------------------------------- +// EditBox control +//----------------------------------------------------------------------------- +class CDXUTEditBox : public CDXUTControl +{ +public: + CDXUTEditBox( _In_opt_ CDXUTDialog* pDialog = nullptr ); + virtual ~CDXUTEditBox(); + + virtual bool HandleKeyboard( _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ) override; + virtual bool HandleMouse( _In_ UINT uMsg, _In_ const POINT& pt, _In_ WPARAM wParam, _In_ LPARAM lParam ) override; + virtual bool MsgProc( _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ) override; + virtual void UpdateRects() override; + virtual bool CanHaveFocus() override + { + return ( m_bVisible && m_bEnabled ); + } + virtual void Render( _In_ float fElapsedTime ) override; + virtual void OnFocusIn() override; + + void SetText( _In_z_ LPCWSTR wszText, _In_ bool bSelected = false ); + LPCWSTR GetText() const { return m_Buffer.GetBuffer(); } + size_t GetTextLength() const { return m_Buffer.GetTextSize(); } // Returns text length in chars excluding nul. + HRESULT GetTextCopy( _Out_writes_(bufferCount) LPWSTR strDest, _In_ UINT bufferCount ) const; + void ClearText(); + + virtual void SetTextColor( _In_ DWORD Color ) override { m_TextColor = Color; } // Text color + void SetSelectedTextColor( _In_ DWORD Color ) { m_SelTextColor = Color; } // Selected text color + void SetSelectedBackColor( _In_ DWORD Color ) { m_SelBkColor = Color; } // Selected background color + void SetCaretColor( _In_ DWORD Color ) { m_CaretColor = Color; } // Caret color + void SetBorderWidth( _In_ int nBorder ) + { + m_nBorder = nBorder; + UpdateRects(); + } // Border of the window + void SetSpacing( _In_ int nSpacing ) + { + m_nSpacing = nSpacing; + UpdateRects(); + } + void ParseFloatArray( _In_reads_(nCount) float* pNumbers, _In_ int nCount ); + void SetTextFloatArray( _In_reads_(nCount) const float* pNumbers, _In_ int nCount ); + +protected: + void PlaceCaret( _In_ int nCP ); + void DeleteSelectionText(); + void ResetCaretBlink(); + void CopyToClipboard(); + void PasteFromClipboard(); + + CUniBuffer m_Buffer; // Buffer to hold text + int m_nBorder; // Border of the window + int m_nSpacing; // Spacing between the text and the edge of border + RECT m_rcText; // Bounding rectangle for the text + RECT m_rcRender[9]; // Convenient rectangles for rendering elements + double m_dfBlink; // Caret blink time in milliseconds + double m_dfLastBlink; // Last timestamp of caret blink + bool m_bCaretOn; // Flag to indicate whether caret is currently visible + int m_nCaret; // Caret position, in characters + bool m_bInsertMode; // If true, control is in insert mode. Else, overwrite mode. + int m_nSelStart; // Starting position of the selection. The caret marks the end. + int m_nFirstVisible;// First visible character in the edit control + DWORD m_TextColor; // Text color + DWORD m_SelTextColor; // Selected text color + DWORD m_SelBkColor; // Selected background color + DWORD m_CaretColor; // Caret color + + // Mouse-specific + bool m_bMouseDrag; // True to indicate drag in progress + + // Static + static bool s_bHideCaret; // If true, we don't render the caret. +}; + + +//----------------------------------------------------------------------------- +void BeginText11(); +void DrawText11DXUT( _In_ ID3D11Device* pd3dDevice, _In_ ID3D11DeviceContext* pd3d11DeviceContext, + _In_z_ LPCWSTR strText, _In_ const RECT& rcScreen, _In_ DirectX::XMFLOAT4 vFontColor, + _In_ float fBBWidth, _In_ float fBBHeight, _In_ bool bCenter ); +void EndText11( _In_ ID3D11Device* pd3dDevice, _In_ ID3D11DeviceContext* pd3d11DeviceContext ); diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/DXUTguiIME.h b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/DXUTguiIME.h new file mode 100644 index 0000000..9ceb59f --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/DXUTguiIME.h @@ -0,0 +1,141 @@ +//-------------------------------------------------------------------------------------- +// File: DXUTguiIME.h +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=320437 +//-------------------------------------------------------------------------------------- +#pragma once + +#include <usp10.h> +#include <dimm.h> +#include "ImeUi.h" + +//-------------------------------------------------------------------------------------- +// Forward declarations +//-------------------------------------------------------------------------------------- +class CDXUTIMEEditBox; + + +//----------------------------------------------------------------------------- +// IME-enabled EditBox control +//----------------------------------------------------------------------------- +#define MAX_COMPSTRING_SIZE 256 + + +class CDXUTIMEEditBox : public CDXUTEditBox +{ +public: + + static HRESULT CreateIMEEditBox( _In_ CDXUTDialog* pDialog, _In_ int ID, _In_z_ LPCWSTR strText, _In_ int x, _In_ int y, _In_ int width, + _In_ int height, _In_ bool bIsDefault=false, _Outptr_opt_ CDXUTIMEEditBox** ppCreated=nullptr ); + + CDXUTIMEEditBox( _In_opt_ CDXUTDialog* pDialog = nullptr ); + virtual ~CDXUTIMEEditBox(); + + static void InitDefaultElements( _In_ CDXUTDialog* pDialog ); + + static void WINAPI Initialize( _In_ HWND hWnd ); + static void WINAPI Uninitialize(); + + static HRESULT WINAPI StaticOnCreateDevice(); + static bool WINAPI StaticMsgProc( _In_ HWND hWnd, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ); + + static void WINAPI SetImeEnableFlag( _In_ bool bFlag ); + + virtual void Render( _In_ float fElapsedTime ) override; + virtual bool MsgProc( _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ) override; + virtual bool HandleMouse( _In_ UINT uMsg, _In_ const POINT& pt, _In_ WPARAM wParam, _In_ LPARAM lParam ) override; + virtual void UpdateRects() override; + virtual void OnFocusIn() override; + virtual void OnFocusOut() override; + + void PumpMessage(); + + virtual void RenderCandidateReadingWindow( _In_ bool bReading ); + virtual void RenderComposition(); + virtual void RenderIndicator( _In_ float fElapsedTime ); + +protected: + static void WINAPI EnableImeSystem( _In_ bool bEnable ); + + static WORD WINAPI GetLanguage() + { + return ImeUi_GetLanguage(); + } + static WORD WINAPI GetPrimaryLanguage() + { + return ImeUi_GetPrimaryLanguage(); + } + static void WINAPI SendKey( _In_ BYTE nVirtKey ); + static DWORD WINAPI GetImeId( _In_ UINT uIndex = 0 ) + { + return ImeUi_GetImeId( uIndex ); + }; + static void WINAPI CheckInputLocale(); + static void WINAPI CheckToggleState(); + static void WINAPI SetupImeApi(); + static void WINAPI ResetCompositionString(); + + + static void SetupImeUiCallback(); + +protected: + enum + { + INDICATOR_NON_IME, + INDICATOR_CHS, + INDICATOR_CHT, + INDICATOR_KOREAN, + INDICATOR_JAPANESE + }; + + struct CCandList + { + CUniBuffer HoriCand; // Candidate list string (for horizontal candidate window) + int nFirstSelected; // First character position of the selected string in HoriCand + int nHoriSelectedLen; // Length of the selected string in HoriCand + RECT rcCandidate; // Candidate rectangle computed and filled each time before rendered + }; + + static POINT s_ptCompString; // Composition string position. Updated every frame. + static int s_nFirstTargetConv; // Index of the first target converted char in comp string. If none, -1. + static CUniBuffer s_CompString; // Buffer to hold the composition string (we fix its length) + static DWORD s_adwCompStringClause[MAX_COMPSTRING_SIZE]; + static CCandList s_CandList; // Data relevant to the candidate list + static WCHAR s_wszReadingString[32];// Used only with horizontal reading window (why?) + static bool s_bImeFlag; // Is ime enabled + + // Color of various IME elements + DWORD m_ReadingColor; // Reading string color + DWORD m_ReadingWinColor; // Reading window color + DWORD m_ReadingSelColor; // Selected character in reading string + DWORD m_ReadingSelBkColor; // Background color for selected char in reading str + DWORD m_CandidateColor; // Candidate string color + DWORD m_CandidateWinColor; // Candidate window color + DWORD m_CandidateSelColor; // Selected candidate string color + DWORD m_CandidateSelBkColor; // Selected candidate background color + DWORD m_CompColor; // Composition string color + DWORD m_CompWinColor; // Composition string window color + DWORD m_CompCaretColor; // Composition string caret color + DWORD m_CompTargetColor; // Composition string target converted color + DWORD m_CompTargetBkColor; // Composition string target converted background + DWORD m_CompTargetNonColor; // Composition string target non-converted color + DWORD m_CompTargetNonBkColor;// Composition string target non-converted background + DWORD m_IndicatorImeColor; // Indicator text color for IME + DWORD m_IndicatorEngColor; // Indicator text color for English + DWORD m_IndicatorBkColor; // Indicator text background color + + // Edit-control-specific data + int m_nIndicatorWidth; // Width of the indicator symbol + RECT m_rcIndicator; // Rectangle for drawing the indicator button + +#if defined(DEBUG) || defined(_DEBUG) + static bool m_bIMEStaticMsgProcCalled; +#endif +}; diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/DXUTres.h b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/DXUTres.h new file mode 100644 index 0000000..ffd1de2 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/DXUTres.h @@ -0,0 +1,17 @@ +//---------------------------------------------------------------------------- +// File: dxutres.h +// +// Functions to create DXUT media from arrays in memory +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=320437 +//----------------------------------------------------------------------------- +#pragma once + +HRESULT WINAPI DXUTCreateGUITextureFromInternalArray( _In_ ID3D11Device* pd3dDevice, _Outptr_ ID3D11Texture2D** ppTexture ); diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/DXUTsettingsdlg.h b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/DXUTsettingsdlg.h new file mode 100644 index 0000000..92d2752 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/DXUTsettingsdlg.h @@ -0,0 +1,173 @@ +//-------------------------------------------------------------------------------------- +// File: DXUTSettingsDlg.h +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=320437 +//-------------------------------------------------------------------------------------- +#pragma once + +//-------------------------------------------------------------------------------------- +// Header Includes +//-------------------------------------------------------------------------------------- +#include "DXUTgui.h" + +//-------------------------------------------------------------------------------------- +// Control IDs +//-------------------------------------------------------------------------------------- +#define DXUTSETTINGSDLG_STATIC -1 +#define DXUTSETTINGSDLG_OK 1 +#define DXUTSETTINGSDLG_CANCEL 2 +#define DXUTSETTINGSDLG_ADAPTER 3 +#define DXUTSETTINGSDLG_DEVICE_TYPE 4 +#define DXUTSETTINGSDLG_WINDOWED 5 +#define DXUTSETTINGSDLG_FULLSCREEN 6 +#define DXUTSETTINGSDLG_RESOLUTION_SHOW_ALL 26 +#define DXUTSETTINGSDLG_D3D11_ADAPTER_OUTPUT 28 +#define DXUTSETTINGSDLG_D3D11_ADAPTER_OUTPUT_LABEL 29 +#define DXUTSETTINGSDLG_D3D11_RESOLUTION 30 +#define DXUTSETTINGSDLG_D3D11_RESOLUTION_LABEL 31 +#define DXUTSETTINGSDLG_D3D11_REFRESH_RATE 32 +#define DXUTSETTINGSDLG_D3D11_REFRESH_RATE_LABEL 33 +#define DXUTSETTINGSDLG_D3D11_BACK_BUFFER_FORMAT 34 +#define DXUTSETTINGSDLG_D3D11_BACK_BUFFER_FORMAT_LABEL 35 +#define DXUTSETTINGSDLG_D3D11_MULTISAMPLE_COUNT 36 +#define DXUTSETTINGSDLG_D3D11_MULTISAMPLE_COUNT_LABEL 37 +#define DXUTSETTINGSDLG_D3D11_MULTISAMPLE_QUALITY 38 +#define DXUTSETTINGSDLG_D3D11_MULTISAMPLE_QUALITY_LABEL 39 +#define DXUTSETTINGSDLG_D3D11_PRESENT_INTERVAL 40 +#define DXUTSETTINGSDLG_D3D11_PRESENT_INTERVAL_LABEL 41 +#define DXUTSETTINGSDLG_D3D11_DEBUG_DEVICE 42 +#define DXUTSETTINGSDLG_D3D11_FEATURE_LEVEL 43 +#define DXUTSETTINGSDLG_D3D11_FEATURE_LEVEL_LABEL 44 + +#define DXUTSETTINGSDLG_MODE_CHANGE_ACCEPT 58 +#define DXUTSETTINGSDLG_MODE_CHANGE_REVERT 59 +#define DXUTSETTINGSDLG_STATIC_MODE_CHANGE_TIMEOUT 60 +#define DXUTSETTINGSDLG_WINDOWED_GROUP 0x0100 + +#ifdef USE_DIRECT3D11_3 +#define TOTAL_FEATURE_LEVELS 9 +#else +#define TOTAL_FEATURE_LEVELS 7 +#endif + +//-------------------------------------------------------------------------------------- +// Dialog for selection of device settings +// Use DXUTGetD3DSettingsDialog() to access global instance +// To control the contents of the dialog, use the CD3D11Enumeration class. +//-------------------------------------------------------------------------------------- +class CD3DSettingsDlg +{ +public: + CD3DSettingsDlg(); + ~CD3DSettingsDlg(); + + void Init( _In_ CDXUTDialogResourceManager* pManager ); + void Init( _In_ CDXUTDialogResourceManager* pManager, _In_z_ LPCWSTR szControlTextureFileName ); + void Init( _In_ CDXUTDialogResourceManager* pManager, _In_z_ LPCWSTR pszControlTextureResourcename, + _In_ HMODULE hModule ); + + HRESULT Refresh(); + void OnRender( _In_ float fElapsedTime ); + + HRESULT OnD3D11CreateDevice( _In_ ID3D11Device* pd3dDevice ); + HRESULT OnD3D11ResizedSwapChain( _In_ ID3D11Device* pd3dDevice, + _In_ const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc ); + void OnD3D11DestroyDevice(); + + CDXUTDialog* GetDialogControl() { return &m_Dialog; } + bool IsActive() const { return m_bActive; } + void SetActive( _In_ bool bActive ) + { + m_bActive = bActive; + if( bActive ) Refresh(); + } + + LRESULT MsgProc( _In_ HWND hWnd, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ); + +protected: + friend CD3DSettingsDlg* WINAPI DXUTGetD3DSettingsDialog(); + + void CreateControls(); + void SetSelectedD3D11RefreshRate( _In_ DXGI_RATIONAL RefreshRate ); + HRESULT UpdateD3D11Resolutions(); + HRESULT UpdateD3D11RefreshRates(); + + void OnEvent( _In_ UINT nEvent, _In_ int nControlID, _In_ CDXUTControl* pControl ); + + static void WINAPI StaticOnEvent( _In_ UINT nEvent, _In_ int nControlID, _In_ CDXUTControl* pControl, _In_opt_ void* pUserData ); + static void WINAPI StaticOnModeChangeTimer( _In_ UINT nIDEvent, _In_opt_ void* pUserContext ); + + CD3D11EnumAdapterInfo* GetCurrentD3D11AdapterInfo() const; + CD3D11EnumDeviceInfo* GetCurrentD3D11DeviceInfo() const; + CD3D11EnumOutputInfo* GetCurrentD3D11OutputInfo() const; + CD3D11EnumDeviceSettingsCombo* GetCurrentD3D11DeviceSettingsCombo() const; + + void AddAdapter( _In_z_ const WCHAR* strDescription, _In_ UINT iAdapter ); + UINT GetSelectedAdapter() const; + + void SetWindowed( _In_ bool bWindowed ); + bool IsWindowed() const; + + // D3D11 + void AddD3D11DeviceType( _In_ D3D_DRIVER_TYPE devType ); + D3D_DRIVER_TYPE GetSelectedD3D11DeviceType() const; + + void AddD3D11AdapterOutput( _In_z_ const WCHAR* strName, _In_ UINT nOutput ); + UINT GetSelectedD3D11AdapterOutput() const; + + void AddD3D11Resolution( _In_ DWORD dwWidth, _In_ DWORD dwHeight ); + void GetSelectedD3D11Resolution( _Out_ DWORD* pdwWidth, _Out_ DWORD* pdwHeight ) const; + + void AddD3D11FeatureLevel( _In_ D3D_FEATURE_LEVEL fl ); + D3D_FEATURE_LEVEL GetSelectedFeatureLevel() const; + + void AddD3D11RefreshRate( _In_ DXGI_RATIONAL RefreshRate ); + DXGI_RATIONAL GetSelectedD3D11RefreshRate() const; + + void AddD3D11BackBufferFormat( _In_ DXGI_FORMAT format ); + DXGI_FORMAT GetSelectedD3D11BackBufferFormat() const; + + void AddD3D11MultisampleCount( _In_ UINT count ); + UINT GetSelectedD3D11MultisampleCount() const; + + void AddD3D11MultisampleQuality( _In_ UINT Quality ); + UINT GetSelectedD3D11MultisampleQuality() const; + + DWORD GetSelectedD3D11PresentInterval() const; + bool GetSelectedDebugDeviceValue() const; + + HRESULT OnD3D11ResolutionChanged (); + HRESULT OnFeatureLevelChanged(); + HRESULT OnAdapterChanged(); + HRESULT OnDeviceTypeChanged(); + HRESULT OnWindowedFullScreenChanged(); + HRESULT OnAdapterOutputChanged(); + HRESULT OnRefreshRateChanged(); + HRESULT OnBackBufferFormatChanged(); + HRESULT OnMultisampleTypeChanged(); + HRESULT OnMultisampleQualityChanged(); + HRESULT OnPresentIntervalChanged(); + HRESULT OnDebugDeviceChanged(); + + void UpdateModeChangeTimeoutText( _In_ int nSecRemaining ); + + CDXUTDialog* m_pActiveDialog; + CDXUTDialog m_Dialog; + CDXUTDialog m_RevertModeDialog; + int m_nRevertModeTimeout; + UINT m_nIDEvent; + bool m_bActive; + + D3D_FEATURE_LEVEL m_Levels[TOTAL_FEATURE_LEVELS]; + +}; + + +CD3DSettingsDlg* WINAPI DXUTGetD3DSettingsDialog(); diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/ImeUi.h b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/ImeUi.h new file mode 100644 index 0000000..fdb33f3 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/ImeUi.h @@ -0,0 +1,126 @@ +//-------------------------------------------------------------------------------------- +// File: ImeUi.h +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=320437 +//-------------------------------------------------------------------------------------- +#pragma once + +#include <windows.h> + +class CImeUiFont_Base +{ +public: + virtual void SetHeight( _In_ UINT uHeight ) + { + UNREFERENCED_PARAMETER(uHeight); + }; // for backward compatibility + virtual void SetColor( _In_ DWORD color ) = 0; + virtual void SetPosition( _In_ int x, _In_ int y ) = 0; + virtual void GetTextExtent( _In_z_ LPCTSTR szText, _Out_ DWORD* puWidth, _Out_ DWORD* puHeight ) = 0; + virtual void DrawText( _In_z_ LPCTSTR pszText ) = 0; +}; + +typedef struct +{ + // symbol (Henkan-kyu) + DWORD symbolColor; + DWORD symbolColorOff; + DWORD symbolColorText; + BYTE symbolHeight; + BYTE symbolTranslucence; + BYTE symbolPlacement; + CImeUiFont_Base* symbolFont; + + // candidate list + DWORD candColorBase; + DWORD candColorBorder; + DWORD candColorText; + + // composition string + DWORD compColorInput; + DWORD compColorTargetConv; + DWORD compColorConverted; + DWORD compColorTargetNotConv; + DWORD compColorInputErr; + BYTE compTranslucence; + DWORD compColorText; + + // caret + BYTE caretWidth; + BYTE caretYMargin; +} IMEUI_APPEARANCE; + +typedef struct // D3DTLVERTEX compatible +{ + float sx; + float sy; + float sz; + float rhw; + DWORD color; + DWORD specular; + float tu; + float tv; +} IMEUI_VERTEX; + +// IME States +#define IMEUI_STATE_OFF 0 +#define IMEUI_STATE_ON 1 +#define IMEUI_STATE_ENGLISH 2 + +// IME const +#define MAX_CANDLIST 10 + +// IME Flags +#define IMEUI_FLAG_SUPPORT_CARET 0x00000001 + +bool ImeUi_Initialize( _In_ HWND hwnd, _In_ bool bDisable = false ); +void ImeUi_Uninitialize(); +void ImeUi_SetAppearance( _In_opt_ const IMEUI_APPEARANCE* pia ); +void ImeUi_GetAppearance( _Out_opt_ IMEUI_APPEARANCE* pia ); +bool ImeUi_IgnoreHotKey( _In_ const MSG* pmsg ); +LPARAM ImeUi_ProcessMessage( _In_ HWND hWnd, _In_ UINT uMsg, _In_ WPARAM wParam, _Inout_ LPARAM& lParam, _Out_ bool* trapped ); +void ImeUi_SetScreenDimension( _In_ UINT width, _In_ UINT height ); +void ImeUi_RenderUI( _In_ bool bDrawCompAttr = true, _In_ bool bDrawOtherUi = true ); +void ImeUi_SetCaretPosition( _In_ UINT x, _In_ UINT y ); +void ImeUi_SetCompStringAppearance( _In_ CImeUiFont_Base* pFont, _In_ DWORD color, _In_ const RECT* prc ); +bool ImeUi_GetCaretStatus(); +void ImeUi_SetInsertMode( _In_ bool bInsert ); +void ImeUi_SetState( _In_ DWORD dwState ); +DWORD ImeUi_GetState(); +void ImeUi_EnableIme( _In_ bool bEnable ); +bool ImeUi_IsEnabled(); +void ImeUi_FinalizeString( _In_ bool bSend = false ); +void ImeUi_ToggleLanguageBar( _In_ BOOL bRestore ); +bool ImeUi_IsSendingKeyMessage(); +void ImeUi_SetWindow( _In_ HWND hwnd ); +UINT ImeUi_GetInputCodePage(); +DWORD ImeUi_GetFlags(); +void ImeUi_SetFlags( _In_ DWORD dwFlags, _In_ bool bSet ); + +WORD ImeUi_GetPrimaryLanguage(); +DWORD ImeUi_GetImeId( _In_ UINT uIndex ); +WORD ImeUi_GetLanguage(); +LPTSTR ImeUi_GetIndicatior(); +bool ImeUi_IsShowReadingWindow(); +bool ImeUi_IsShowCandListWindow(); +bool ImeUi_IsVerticalCand(); +bool ImeUi_IsHorizontalReading(); +TCHAR* ImeUi_GetCandidate( _In_ UINT idx ); +TCHAR* ImeUi_GetCompositionString(); +DWORD ImeUi_GetCandidateSelection(); +DWORD ImeUi_GetCandidateCount(); +BYTE* ImeUi_GetCompStringAttr(); +DWORD ImeUi_GetImeCursorChars(); + +extern void ( CALLBACK*ImeUiCallback_DrawRect )( _In_ int x1, _In_ int y1, _In_ int x2, _In_ int y2, _In_ DWORD color ); +extern void* ( __cdecl*ImeUiCallback_Malloc )( _In_ size_t bytes ); +extern void ( __cdecl*ImeUiCallback_Free )( _In_ void* ptr ); +extern void ( CALLBACK*ImeUiCallback_DrawFans )( _In_ const IMEUI_VERTEX* paVertex, _In_ UINT uNum ); +extern void ( CALLBACK*ImeUiCallback_OnChar )( _In_ WCHAR wc ); diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/SDKmesh.h b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/SDKmesh.h new file mode 100644 index 0000000..499d707 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/SDKmesh.h @@ -0,0 +1,460 @@ +//-------------------------------------------------------------------------------------- +// File: SDKMesh.h +// +// Disclaimer: +// The SDK Mesh format (.sdkmesh) is not a recommended file format for shipping titles. +// It was designed to meet the specific needs of the SDK samples. Any real-world +// applications should avoid this file format in favor of a destination format that +// meets the specific needs of the application. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=320437 +//-------------------------------------------------------------------------------------- +#pragma once + +#undef D3DCOLOR_ARGB +#include <d3d9.h> + +//-------------------------------------------------------------------------------------- +// Hard Defines for the various structures +//-------------------------------------------------------------------------------------- +#define SDKMESH_FILE_VERSION 101 +#define MAX_VERTEX_ELEMENTS 32 +#define MAX_VERTEX_STREAMS 16 +#define MAX_FRAME_NAME 100 +#define MAX_MESH_NAME 100 +#define MAX_SUBSET_NAME 100 +#define MAX_MATERIAL_NAME 100 +#define MAX_TEXTURE_NAME MAX_PATH +#define MAX_MATERIAL_PATH MAX_PATH +#define INVALID_FRAME ((UINT)-1) +#define INVALID_MESH ((UINT)-1) +#define INVALID_MATERIAL ((UINT)-1) +#define INVALID_SUBSET ((UINT)-1) +#define INVALID_ANIMATION_DATA ((UINT)-1) +#define INVALID_SAMPLER_SLOT ((UINT)-1) +#define ERROR_RESOURCE_VALUE 1 + +template<typename TYPE> BOOL IsErrorResource( TYPE data ) +{ + if( ( TYPE )ERROR_RESOURCE_VALUE == data ) + return TRUE; + return FALSE; +} +//-------------------------------------------------------------------------------------- +// Enumerated Types. +//-------------------------------------------------------------------------------------- +enum SDKMESH_PRIMITIVE_TYPE +{ + PT_TRIANGLE_LIST = 0, + PT_TRIANGLE_STRIP, + PT_LINE_LIST, + PT_LINE_STRIP, + PT_POINT_LIST, + PT_TRIANGLE_LIST_ADJ, + PT_TRIANGLE_STRIP_ADJ, + PT_LINE_LIST_ADJ, + PT_LINE_STRIP_ADJ, + PT_QUAD_PATCH_LIST, + PT_TRIANGLE_PATCH_LIST, +}; + +enum SDKMESH_INDEX_TYPE +{ + IT_16BIT = 0, + IT_32BIT, +}; + +enum FRAME_TRANSFORM_TYPE +{ + FTT_RELATIVE = 0, + FTT_ABSOLUTE, //This is not currently used but is here to support absolute transformations in the future +}; + +//-------------------------------------------------------------------------------------- +// Structures. Unions with pointers are forced to 64bit. +//-------------------------------------------------------------------------------------- +#pragma pack(push,8) + +struct SDKMESH_HEADER +{ + //Basic Info and sizes + UINT Version; + BYTE IsBigEndian; + UINT64 HeaderSize; + UINT64 NonBufferDataSize; + UINT64 BufferDataSize; + + //Stats + UINT NumVertexBuffers; + UINT NumIndexBuffers; + UINT NumMeshes; + UINT NumTotalSubsets; + UINT NumFrames; + UINT NumMaterials; + + //Offsets to Data + UINT64 VertexStreamHeadersOffset; + UINT64 IndexStreamHeadersOffset; + UINT64 MeshDataOffset; + UINT64 SubsetDataOffset; + UINT64 FrameDataOffset; + UINT64 MaterialDataOffset; +}; + +struct SDKMESH_VERTEX_BUFFER_HEADER +{ + UINT64 NumVertices; + UINT64 SizeBytes; + UINT64 StrideBytes; + D3DVERTEXELEMENT9 Decl[MAX_VERTEX_ELEMENTS]; + union + { + UINT64 DataOffset; //(This also forces the union to 64bits) + ID3D11Buffer* pVB11; + }; +}; + +struct SDKMESH_INDEX_BUFFER_HEADER +{ + UINT64 NumIndices; + UINT64 SizeBytes; + UINT IndexType; + union + { + UINT64 DataOffset; //(This also forces the union to 64bits) + ID3D11Buffer* pIB11; + }; +}; + +struct SDKMESH_MESH +{ + char Name[MAX_MESH_NAME]; + BYTE NumVertexBuffers; + UINT VertexBuffers[MAX_VERTEX_STREAMS]; + UINT IndexBuffer; + UINT NumSubsets; + UINT NumFrameInfluences; //aka bones + + DirectX::XMFLOAT3 BoundingBoxCenter; + DirectX::XMFLOAT3 BoundingBoxExtents; + + union + { + UINT64 SubsetOffset; //Offset to list of subsets (This also forces the union to 64bits) + UINT* pSubsets; //Pointer to list of subsets + }; + union + { + UINT64 FrameInfluenceOffset; //Offset to list of frame influences (This also forces the union to 64bits) + UINT* pFrameInfluences; //Pointer to list of frame influences + }; +}; + +struct SDKMESH_SUBSET +{ + char Name[MAX_SUBSET_NAME]; + UINT MaterialID; + UINT PrimitiveType; + UINT64 IndexStart; + UINT64 IndexCount; + UINT64 VertexStart; + UINT64 VertexCount; +}; + +struct SDKMESH_FRAME +{ + char Name[MAX_FRAME_NAME]; + UINT Mesh; + UINT ParentFrame; + UINT ChildFrame; + UINT SiblingFrame; + DirectX::XMFLOAT4X4 Matrix; + UINT AnimationDataIndex; //Used to index which set of keyframes transforms this frame +}; + +struct SDKMESH_MATERIAL +{ + char Name[MAX_MATERIAL_NAME]; + + // Use MaterialInstancePath + char MaterialInstancePath[MAX_MATERIAL_PATH]; + + // Or fall back to d3d8-type materials + char DiffuseTexture[MAX_TEXTURE_NAME]; + char NormalTexture[MAX_TEXTURE_NAME]; + char SpecularTexture[MAX_TEXTURE_NAME]; + + DirectX::XMFLOAT4 Diffuse; + DirectX::XMFLOAT4 Ambient; + DirectX::XMFLOAT4 Specular; + DirectX::XMFLOAT4 Emissive; + float Power; + + union + { + UINT64 Force64_1; //Force the union to 64bits + ID3D11Texture2D* pDiffuseTexture11; + }; + union + { + UINT64 Force64_2; //Force the union to 64bits + ID3D11Texture2D* pNormalTexture11; + }; + union + { + UINT64 Force64_3; //Force the union to 64bits + ID3D11Texture2D* pSpecularTexture11; + }; + + union + { + UINT64 Force64_4; //Force the union to 64bits + ID3D11ShaderResourceView* pDiffuseRV11; + }; + union + { + UINT64 Force64_5; //Force the union to 64bits + ID3D11ShaderResourceView* pNormalRV11; + }; + union + { + UINT64 Force64_6; //Force the union to 64bits + ID3D11ShaderResourceView* pSpecularRV11; + }; + +}; + +struct SDKANIMATION_FILE_HEADER +{ + UINT Version; + BYTE IsBigEndian; + UINT FrameTransformType; + UINT NumFrames; + UINT NumAnimationKeys; + UINT AnimationFPS; + UINT64 AnimationDataSize; + UINT64 AnimationDataOffset; +}; + +struct SDKANIMATION_DATA +{ + DirectX::XMFLOAT3 Translation; + DirectX::XMFLOAT4 Orientation; + DirectX::XMFLOAT3 Scaling; +}; + +struct SDKANIMATION_FRAME_DATA +{ + char FrameName[MAX_FRAME_NAME]; + union + { + UINT64 DataOffset; + SDKANIMATION_DATA* pAnimationData; + }; +}; + +#pragma pack(pop) + +static_assert( sizeof(D3DVERTEXELEMENT9) == 8, "Direct3D9 Decl structure size incorrect" ); +static_assert( sizeof(SDKMESH_HEADER)== 104, "SDK Mesh structure size incorrect" ); +static_assert( sizeof(SDKMESH_VERTEX_BUFFER_HEADER) == 288, "SDK Mesh structure size incorrect" ); +static_assert( sizeof(SDKMESH_INDEX_BUFFER_HEADER) == 32, "SDK Mesh structure size incorrect" ); +static_assert( sizeof(SDKMESH_MESH) == 224, "SDK Mesh structure size incorrect" ); +static_assert( sizeof(SDKMESH_SUBSET) == 144, "SDK Mesh structure size incorrect" ); +static_assert( sizeof(SDKMESH_FRAME) == 184, "SDK Mesh structure size incorrect" ); +static_assert( sizeof(SDKMESH_MATERIAL) == 1256, "SDK Mesh structure size incorrect" ); +static_assert( sizeof(SDKANIMATION_FILE_HEADER) == 40, "SDK Mesh structure size incorrect" ); +static_assert( sizeof(SDKANIMATION_DATA) == 40, "SDK Mesh structure size incorrect" ); +static_assert( sizeof(SDKANIMATION_FRAME_DATA) == 112, "SDK Mesh structure size incorrect" ); + +#ifndef _CONVERTER_APP_ + +//-------------------------------------------------------------------------------------- +// AsyncLoading callbacks +//-------------------------------------------------------------------------------------- +typedef void ( CALLBACK*LPCREATETEXTUREFROMFILE11 )( _In_ ID3D11Device* pDev, _In_z_ char* szFileName, + _Outptr_ ID3D11ShaderResourceView** ppRV, _In_opt_ void* pContext ); +typedef void ( CALLBACK*LPCREATEVERTEXBUFFER11 )( _In_ ID3D11Device* pDev, _Outptr_ ID3D11Buffer** ppBuffer, + _In_ D3D11_BUFFER_DESC BufferDesc, _In_ void* pData, _In_opt_ void* pContext ); +typedef void ( CALLBACK*LPCREATEINDEXBUFFER11 )( _In_ ID3D11Device* pDev, _Outptr_ ID3D11Buffer** ppBuffer, + _In_ D3D11_BUFFER_DESC BufferDesc, _In_ void* pData, _In_opt_ void* pContext ); +struct SDKMESH_CALLBACKS11 +{ + LPCREATETEXTUREFROMFILE11 pCreateTextureFromFile; + LPCREATEVERTEXBUFFER11 pCreateVertexBuffer; + LPCREATEINDEXBUFFER11 pCreateIndexBuffer; + void* pContext; +}; + +//-------------------------------------------------------------------------------------- +// CDXUTSDKMesh class. This class reads the sdkmesh file format for use by the samples +//-------------------------------------------------------------------------------------- +class CDXUTSDKMesh +{ +private: + UINT m_NumOutstandingResources; + bool m_bLoading; + //BYTE* m_pBufferData; + HANDLE m_hFile; + HANDLE m_hFileMappingObject; + std::vector<BYTE*> m_MappedPointers; + ID3D11Device* m_pDev11; + ID3D11DeviceContext* m_pDevContext11; + +protected: + //These are the pointers to the two chunks of data loaded in from the mesh file + BYTE* m_pStaticMeshData; + BYTE* m_pHeapData; + BYTE* m_pAnimationData; + BYTE** m_ppVertices; + BYTE** m_ppIndices; + + //Keep track of the path + WCHAR m_strPathW[MAX_PATH]; + char m_strPath[MAX_PATH]; + + //General mesh info + SDKMESH_HEADER* m_pMeshHeader; + SDKMESH_VERTEX_BUFFER_HEADER* m_pVertexBufferArray; + SDKMESH_INDEX_BUFFER_HEADER* m_pIndexBufferArray; + SDKMESH_MESH* m_pMeshArray; + SDKMESH_SUBSET* m_pSubsetArray; + SDKMESH_FRAME* m_pFrameArray; + SDKMESH_MATERIAL* m_pMaterialArray; + + // Adjacency information (not part of the m_pStaticMeshData, so it must be created and destroyed separately ) + SDKMESH_INDEX_BUFFER_HEADER* m_pAdjacencyIndexBufferArray; + + //Animation + SDKANIMATION_FILE_HEADER* m_pAnimationHeader; + SDKANIMATION_FRAME_DATA* m_pAnimationFrameData; + DirectX::XMFLOAT4X4* m_pBindPoseFrameMatrices; + DirectX::XMFLOAT4X4* m_pTransformedFrameMatrices; + DirectX::XMFLOAT4X4* m_pWorldPoseFrameMatrices; + +protected: + void LoadMaterials( _In_ ID3D11Device* pd3dDevice, _In_reads_(NumMaterials) SDKMESH_MATERIAL* pMaterials, + _In_ UINT NumMaterials, _In_opt_ SDKMESH_CALLBACKS11* pLoaderCallbacks = nullptr ); + + HRESULT CreateVertexBuffer( _In_ ID3D11Device* pd3dDevice, + _In_ SDKMESH_VERTEX_BUFFER_HEADER* pHeader, _In_reads_(pHeader->SizeBytes) void* pVertices, + _In_opt_ SDKMESH_CALLBACKS11* pLoaderCallbacks = nullptr ); + + HRESULT CreateIndexBuffer( _In_ ID3D11Device* pd3dDevice, + _In_ SDKMESH_INDEX_BUFFER_HEADER* pHeader, _In_reads_(pHeader->SizeBytes) void* pIndices, + _In_opt_ SDKMESH_CALLBACKS11* pLoaderCallbacks = nullptr ); + + virtual HRESULT CreateFromFile( _In_opt_ ID3D11Device* pDev11, + _In_z_ LPCWSTR szFileName, + _In_opt_ SDKMESH_CALLBACKS11* pLoaderCallbacks11 = nullptr ); + + virtual HRESULT CreateFromMemory( _In_opt_ ID3D11Device* pDev11, + _In_reads_(DataBytes) BYTE* pData, + _In_ size_t DataBytes, + _In_ bool bCopyStatic, + _In_opt_ SDKMESH_CALLBACKS11* pLoaderCallbacks11 = nullptr ); + + //frame manipulation + void TransformBindPoseFrame( _In_ UINT iFrame, _In_ DirectX::CXMMATRIX parentWorld ); + void TransformFrame( _In_ UINT iFrame, _In_ DirectX::CXMMATRIX parentWorld, _In_ double fTime ); + void TransformFrameAbsolute( _In_ UINT iFrame, _In_ double fTime ); + + //Direct3D 11 rendering helpers + void RenderMesh( _In_ UINT iMesh, + _In_ bool bAdjacent, + _In_ ID3D11DeviceContext* pd3dDeviceContext, + _In_ UINT iDiffuseSlot, + _In_ UINT iNormalSlot, + _In_ UINT iSpecularSlot ); + void RenderFrame( _In_ UINT iFrame, + _In_ bool bAdjacent, + _In_ ID3D11DeviceContext* pd3dDeviceContext, + _In_ UINT iDiffuseSlot, + _In_ UINT iNormalSlot, + _In_ UINT iSpecularSlot ); + +public: + CDXUTSDKMesh(); + virtual ~CDXUTSDKMesh(); + + virtual HRESULT Create( _In_ ID3D11Device* pDev11, _In_z_ LPCWSTR szFileName, _In_opt_ SDKMESH_CALLBACKS11* pLoaderCallbacks = nullptr ); + virtual HRESULT Create( _In_ ID3D11Device* pDev11, BYTE* pData, size_t DataBytes, _In_ bool bCopyStatic=false, + _In_opt_ SDKMESH_CALLBACKS11* pLoaderCallbacks = nullptr ); + virtual HRESULT LoadAnimation( _In_z_ const WCHAR* szFileName ); + virtual void Destroy(); + + //Frame manipulation + void TransformBindPose( _In_ DirectX::CXMMATRIX world ) { TransformBindPoseFrame( 0, world ); }; + void TransformMesh( _In_ DirectX::CXMMATRIX world, _In_ double fTime ); + + //Direct3D 11 Rendering + virtual void Render( _In_ ID3D11DeviceContext* pd3dDeviceContext, + _In_ UINT iDiffuseSlot = INVALID_SAMPLER_SLOT, + _In_ UINT iNormalSlot = INVALID_SAMPLER_SLOT, + _In_ UINT iSpecularSlot = INVALID_SAMPLER_SLOT ); + virtual void RenderAdjacent( _In_ ID3D11DeviceContext* pd3dDeviceContext, + _In_ UINT iDiffuseSlot = INVALID_SAMPLER_SLOT, + _In_ UINT iNormalSlot = INVALID_SAMPLER_SLOT, + _In_ UINT iSpecularSlot = INVALID_SAMPLER_SLOT ); + + //Helpers (D3D11 specific) + static D3D11_PRIMITIVE_TOPOLOGY GetPrimitiveType11( _In_ SDKMESH_PRIMITIVE_TYPE PrimType ); + DXGI_FORMAT GetIBFormat11( _In_ UINT iMesh ) const; + ID3D11Buffer* GetVB11( _In_ UINT iMesh, _In_ UINT iVB ) const; + ID3D11Buffer* GetIB11( _In_ UINT iMesh ) const; + SDKMESH_INDEX_TYPE GetIndexType( _In_ UINT iMesh ) const; + + ID3D11Buffer* GetAdjIB11( _In_ UINT iMesh ) const; + + //Helpers (general) + const char* GetMeshPathA() const; + const WCHAR* GetMeshPathW() const; + UINT GetNumMeshes() const; + UINT GetNumMaterials() const; + UINT GetNumVBs() const; + UINT GetNumIBs() const; + + ID3D11Buffer* GetVB11At( _In_ UINT iVB ) const; + ID3D11Buffer* GetIB11At( _In_ UINT iIB ) const; + + BYTE* GetRawVerticesAt( _In_ UINT iVB ) const; + BYTE* GetRawIndicesAt( _In_ UINT iIB ) const; + + SDKMESH_MATERIAL* GetMaterial( _In_ UINT iMaterial ) const; + SDKMESH_MESH* GetMesh( _In_ UINT iMesh ) const; + UINT GetNumSubsets( _In_ UINT iMesh ) const; + SDKMESH_SUBSET* GetSubset( _In_ UINT iMesh, _In_ UINT iSubset ) const; + UINT GetVertexStride( _In_ UINT iMesh, _In_ UINT iVB ) const; + UINT GetNumFrames() const; + SDKMESH_FRAME* GetFrame( _In_ UINT iFrame ) const; + SDKMESH_FRAME* FindFrame( _In_z_ const char* pszName ) const; + UINT64 GetNumVertices( _In_ UINT iMesh, _In_ UINT iVB ) const; + UINT64 GetNumIndices( _In_ UINT iMesh ) const; + DirectX::XMVECTOR GetMeshBBoxCenter( _In_ UINT iMesh ) const; + DirectX::XMVECTOR GetMeshBBoxExtents( _In_ UINT iMesh ) const; + UINT GetOutstandingResources() const; + UINT GetOutstandingBufferResources() const; + bool CheckLoadDone(); + bool IsLoaded() const; + bool IsLoading() const; + void SetLoading( _In_ bool bLoading ); + BOOL HadLoadingError() const; + + //Animation + UINT GetNumInfluences( _In_ UINT iMesh ) const; + DirectX::XMMATRIX GetMeshInfluenceMatrix( _In_ UINT iMesh, _In_ UINT iInfluence ) const; + UINT GetAnimationKeyFromTime( _In_ double fTime ) const; + DirectX::XMMATRIX GetWorldMatrix( _In_ UINT iFrameIndex ) const; + DirectX::XMMATRIX GetInfluenceMatrix( _In_ UINT iFrameIndex ) const; + bool GetAnimationProperties( _Out_ UINT* pNumKeys, _Out_ float* pFrameTime ) const; +}; + +#endif + diff --git a/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/SDKmisc.h b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/SDKmisc.h new file mode 100644 index 0000000..14ee349 --- /dev/null +++ b/NvCloth/samples/external/DXUT/9.15.2016.1/Optional/SDKmisc.h @@ -0,0 +1,134 @@ +//-------------------------------------------------------------------------------------- +// File: SDKMisc.h +// +// Various helper functionality that is shared between SDK samples +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// http://go.microsoft.com/fwlink/?LinkId=320437 +//-------------------------------------------------------------------------------------- +#pragma once + +//----------------------------------------------------------------------------- +// Resource cache for textures, fonts, meshs, and effects. +// Use DXUTGetGlobalResourceCache() to access the global cache +//----------------------------------------------------------------------------- + +struct DXUTCache_Texture +{ + WCHAR wszSource[MAX_PATH]; + bool bSRGB; + ID3D11ShaderResourceView* pSRV11; + + DXUTCache_Texture() : + pSRV11(nullptr) + { + } +}; + + +class CDXUTResourceCache +{ +public: + ~CDXUTResourceCache(); + + HRESULT CreateTextureFromFile( _In_ ID3D11Device* pDevice, _In_ ID3D11DeviceContext *pContext, _In_z_ LPCWSTR pSrcFile, + _Outptr_ ID3D11ShaderResourceView** ppOutputRV, _In_ bool bSRGB=false ); + HRESULT CreateTextureFromFile( _In_ ID3D11Device* pDevice, _In_ ID3D11DeviceContext *pContext, _In_z_ LPCSTR pSrcFile, + _Outptr_ ID3D11ShaderResourceView** ppOutputRV, _In_ bool bSRGB=false ); +public: + HRESULT OnDestroyDevice(); + +protected: + friend CDXUTResourceCache& WINAPI DXUTGetGlobalResourceCache(); + friend HRESULT WINAPI DXUTInitialize3DEnvironment(); + friend HRESULT WINAPI DXUTReset3DEnvironment(); + friend void WINAPI DXUTCleanup3DEnvironment( bool bReleaseSettings ); + + CDXUTResourceCache() { } + + std::vector<DXUTCache_Texture> m_TextureCache; +}; + +CDXUTResourceCache& WINAPI DXUTGetGlobalResourceCache(); + + +//-------------------------------------------------------------------------------------- +// Manages the insertion point when drawing text +//-------------------------------------------------------------------------------------- +class CDXUTDialogResourceManager; +class CDXUTTextHelper +{ +public: + CDXUTTextHelper( _In_ ID3D11Device* pd3d11Device, _In_ ID3D11DeviceContext* pd3dDeviceContext, _In_ CDXUTDialogResourceManager* pManager, _In_ int nLineHeight ); + ~CDXUTTextHelper(); + + void Init( _In_ int nLineHeight = 15 ); + + void SetInsertionPos( _In_ int x, _In_ int y ) + { + m_pt.x = x; + m_pt.y = y; + } + void SetForegroundColor( _In_ DirectX::XMFLOAT4 clr ) { m_clr = clr; } + void SetForegroundColor( _In_ DirectX::FXMVECTOR clr ) { XMStoreFloat4( &m_clr, clr ); } + + void Begin(); + HRESULT DrawFormattedTextLine( _In_z_ const WCHAR* strMsg, ... ); + HRESULT DrawTextLine( _In_z_ const WCHAR* strMsg ); + HRESULT DrawFormattedTextLine( _In_ const RECT& rc, _In_z_ const WCHAR* strMsg, ... ); + HRESULT DrawTextLine( _In_ const RECT& rc, _In_z_ const WCHAR* strMsg ); + void End(); + +protected: + DirectX::XMFLOAT4 m_clr; + POINT m_pt; + int m_nLineHeight; + + // D3D11 font + ID3D11Device* m_pd3d11Device; + ID3D11DeviceContext* m_pd3d11DeviceContext; + CDXUTDialogResourceManager* m_pManager; +}; + + +//-------------------------------------------------------------------------------------- +// Shared code for samples to ask user if they want to use a REF device or quit +//-------------------------------------------------------------------------------------- +void WINAPI DXUTDisplaySwitchingToREFWarning(); + +//-------------------------------------------------------------------------------------- +// Tries to finds a media file by searching in common locations +//-------------------------------------------------------------------------------------- +HRESULT WINAPI DXUTFindDXSDKMediaFileCch( _Out_writes_(cchDest) WCHAR* strDestPath, + _In_ int cchDest, + _In_z_ LPCWSTR strFilename ); +HRESULT WINAPI DXUTSetMediaSearchPath( _In_z_ LPCWSTR strPath ); +LPCWSTR WINAPI DXUTGetMediaSearchPath(); + + +//-------------------------------------------------------------------------------------- +// Compiles HLSL shaders +//-------------------------------------------------------------------------------------- +HRESULT WINAPI DXUTCompileFromFile( _In_z_ LPCWSTR pFileName, + _In_reads_opt_(_Inexpressible_(pDefines->Name != NULL)) const D3D_SHADER_MACRO* pDefines, + _In_z_ LPCSTR pEntrypoint, _In_z_ LPCSTR pTarget, + _In_ UINT Flags1, _In_ UINT Flags2, + _Outptr_ ID3DBlob** ppCode ); + +//-------------------------------------------------------------------------------------- +// Texture utilities +//-------------------------------------------------------------------------------------- +HRESULT WINAPI DXUTCreateShaderResourceViewFromFile( _In_ ID3D11Device* d3dDevice, _In_z_ const wchar_t* szFileName, _Outptr_ ID3D11ShaderResourceView** textureView ); +HRESULT WINAPI DXUTCreateTextureFromFile( _In_ ID3D11Device* d3dDevice, _In_z_ const wchar_t* szFileName, _Outptr_ ID3D11Resource** texture ); +HRESULT WINAPI DXUTSaveTextureToFile( _In_ ID3D11DeviceContext* pContext, _In_ ID3D11Resource* pSource, _In_ bool usedds, _In_z_ const wchar_t* szFileName ); + +//-------------------------------------------------------------------------------------- +// Returns a view matrix for rendering to a face of a cubemap. +//-------------------------------------------------------------------------------------- +DirectX::XMMATRIX WINAPI DXUTGetCubeMapViewMatrix( _In_ DWORD dwFace ); |