Skip to content

Commit 0faf9d8

Browse files
Asteroids: fix c++17 build issues
1 parent 4b76bda commit 0faf9d8

File tree

4 files changed

+9
-21
lines changed

4 files changed

+9
-21
lines changed

Samples/Asteroids/src/DDSTextureLoader.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ DXGI_FORMAT MAKE_SRGB( _In_ DXGI_FORMAT format )
6363

6464

6565
//--------------------------------------------------------------------------------------
66-
HRESULT LoadTextureDataFromFile( __in_z const WCHAR* szFileName, BYTE** ppHeapData,
66+
HRESULT LoadTextureDataFromFile( __in_z const CHAR* szFileName, BYTE** ppHeapData,
6767
DDS_HEADER** ppHeader,
6868
BYTE** ppBitData, UINT* pBitSize )
6969
{
7070
// open the file
71-
HANDLE hFile = CreateFileW(szFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
71+
HANDLE hFile = CreateFileA(szFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
7272
FILE_FLAG_SEQUENTIAL_SCAN, NULL );
7373
if( INVALID_HANDLE_VALUE == hFile )
7474
return HRESULT_FROM_WIN32( GetLastError() );
@@ -1064,7 +1064,7 @@ static HRESULT CreateTextureFromDDS( ID3D11Device* pDev, DDS_HEADER* pHeader, __
10641064

10651065

10661066
//--------------------------------------------------------------------------------------
1067-
HRESULT CreateDDSTextureFromFile( __in ID3D11Device* pDev, __in_z const WCHAR* szFileName, __out_opt ID3D11ShaderResourceView** ppSRV, bool sRGB )
1067+
HRESULT CreateDDSTextureFromFile( __in ID3D11Device* pDev, __in_z const CHAR* szFileName, __out_opt ID3D11ShaderResourceView** ppSRV, bool sRGB )
10681068
{
10691069
if ( !pDev || !szFileName || !ppSRV )
10701070
return E_INVALIDARG;
@@ -1087,15 +1087,7 @@ HRESULT CreateDDSTextureFromFile( __in ID3D11Device* pDev, __in_z const WCHAR* s
10871087
#if defined(DEBUG) || defined(PROFILE)
10881088
if ( *ppSRV )
10891089
{
1090-
CHAR strFileA[MAX_PATH];
1091-
WideCharToMultiByte( CP_ACP, 0, szFileName, -1, strFileA, MAX_PATH, NULL, FALSE );
1092-
CHAR* pstrName = strrchr( strFileA, '\\' );
1093-
if( pstrName == NULL )
1094-
pstrName = strFileA;
1095-
else
1096-
pstrName++;
1097-
1098-
(*ppSRV)->SetPrivateData( WKPDID_D3DDebugObjectName, lstrlenA(pstrName), pstrName );
1090+
(*ppSRV)->SetPrivateData( WKPDID_D3DDebugObjectName, lstrlenA(szFileName), szFileName );
10991091
}
11001092
#endif
11011093

Samples/Asteroids/src/DDSTextureLoader.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
#include "DDS.h"
1010
#include <d3d11.h>
1111

12-
HRESULT CreateDDSTextureFromFile( __in ID3D11Device* pDev, __in_z const WCHAR* szFileName, __out_opt ID3D11ShaderResourceView** ppSRV, bool sRGB = false );
12+
HRESULT CreateDDSTextureFromFile( __in ID3D11Device* pDev, __in_z const CHAR* szFileName, __out_opt ID3D11ShaderResourceView** ppSRV, bool sRGB = false );
1313

1414
// INTEL: Exposed this from the internals so we can load the data into D3D12, etc.
1515
DXGI_FORMAT GetDXGIFormat( const DDS_PIXELFORMAT& ddpf );
16-
HRESULT LoadTextureDataFromFile(__in_z const WCHAR* szFileName, BYTE** ppHeapData,
16+
HRESULT LoadTextureDataFromFile(__in_z const CHAR* szFileName, BYTE** ppHeapData,
1717
DDS_HEADER** ppHeader,
1818
BYTE** ppBitData, UINT* pBitSize);

Samples/Asteroids/src/asteroids_d3d11.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ Asteroids::Asteroids(AsteroidsSimulation* asteroids, GUI* gui, bool warp)
191191
CreateGUIResources();
192192

193193
// Load textures
194-
ThrowIfFailed(CreateDDSTextureFromFile(mDevice, L"media/starbox_1024.dds", &mSkyboxSRV, true));
194+
ThrowIfFailed(CreateDDSTextureFromFile(mDevice, "media/starbox_1024.dds", &mSkyboxSRV, true));
195195
}
196196

197197
Asteroids::~Asteroids()
@@ -426,9 +426,8 @@ void Asteroids::CreateGUIResources()
426426
for (int i = -1; i < (int)mGUI->size(); ++i) {
427427
auto control = i >= 0 ? (*mGUI)[i] : mD3D11Sprite;
428428
if (control->TextureFile().length() > 0 && mSpriteTextures.find(control->TextureFile()) == mSpriteTextures.end()) {
429-
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
430429
ID3D11ShaderResourceView* textureSRV = nullptr;
431-
ThrowIfFailed(CreateDDSTextureFromFile(mDevice, converter.from_bytes(control->TextureFile()).c_str(), &textureSRV, true));
430+
ThrowIfFailed(CreateDDSTextureFromFile(mDevice, control->TextureFile().c_str(), &textureSRV, true));
432431
mSpriteTextures[control->TextureFile()] = textureSRV;
433432
}
434433
}

Samples/Asteroids/src/texture.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,7 @@ HRESULT CreateTexture2DFromDDS_XXXX8(
220220
BYTE* bitData = nullptr;
221221
UINT bitSize = 0;
222222

223-
std::wostringstream wfileName;
224-
wfileName << fileName;
225-
226-
HRESULT hr = LoadTextureDataFromFile(wfileName.str().c_str(), &heapData, &header, &bitData, &bitSize);
223+
HRESULT hr = LoadTextureDataFromFile(fileName, &heapData, &header, &bitData, &bitSize);
227224
if (FAILED(hr)) {
228225
delete[] heapData;
229226
return hr;

0 commit comments

Comments
 (0)