Add ClangCl support for CMake (#13)

This commit is contained in:
Chuck Walbourn 2022-05-22 23:52:59 -07:00 коммит произвёл GitHub
Родитель 257d8dd18c
Коммит 3f6cfba8cf
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
19 изменённых файлов: 194 добавлений и 176 удалений

Просмотреть файл

@ -158,12 +158,17 @@ if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /fp:fast)
target_compile_options(${PROJECT_NAME}Opt PRIVATE /fp:fast)
if((${CMAKE_SIZEOF_VOID_P} EQUAL 4) AND (NOT ${DIRECTX_ARCH} MATCHES "arm"))
if((${CMAKE_SIZEOF_VOID_P} EQUAL 4) AND (NOT ${DIRECTX_ARCH} MATCHES "^arm"))
target_compile_options(${PROJECT_NAME} PRIVATE /arch:SSE2)
target_compile_options(${PROJECT_NAME}Opt PRIVATE /arch:SSE2)
endif()
endif()
if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
set(WarningsLib "-Wno-deprecated-declarations" "-Wno-unused-const-variable" "-Wno-switch" "-Wno-ignored-attributes")
target_compile_options(${PROJECT_NAME} PRIVATE ${WarningsLib})
target_compile_options(${PROJECT_NAME}Opt PRIVATE ${WarningsLib})
endif()
if ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
target_compile_options(${PROJECT_NAME} PRIVATE /permissive- /JMC- /Zc:__cplusplus)
target_compile_options(${PROJECT_NAME}Opt PRIVATE /permissive- /JMC- /Zc:__cplusplus)

Просмотреть файл

@ -61,12 +61,28 @@
"strategy": "external"
}
},
{
"name": "Clang",
"hidden": true,
"cacheVariables": {
"CMAKE_CXX_COMPILER": "clang-cl.exe"
},
"toolset": {
"value": "host=x64",
"strategy": "external"
}
},
{ "name": "x64-Debug" , "description": "MSVC for x64 (Debug) for Windows 10", "inherits": [ "base", "x64", "Debug", "MSVC" ] },
{ "name": "x64-Release" , "description": "MSVC for x64 (Release) for Windows 10", "inherits": [ "base", "x64", "Release", "MSVC" ] },
{ "name": "x86-Debug" , "description": "MSVC for x86 (Debug) for Windows 10", "inherits": [ "base", "x86", "Debug", "MSVC" ] },
{ "name": "x86-Release" , "description": "MSVC for x86 (Release) for Windows 10", "inherits": [ "base", "x86", "Release", "MSVC" ] },
{ "name": "arm64-Debug" , "description": "MSVC for ARM64 (Debug) for Windows 10", "inherits": [ "base", "ARM64", "Debug", "MSVC" ] },
{ "name": "arm64-Release" , "description": "MSVC for ARM64 (Release) for Windows 10", "inherits": [ "base", "ARM64", "Release", "MSVC" ] }
{ "name": "x64-Debug" , "description": "MSVC for x64 (Debug)", "inherits": [ "base", "x64", "Debug", "MSVC" ] },
{ "name": "x64-Release" , "description": "MSVC for x64 (Release)", "inherits": [ "base", "x64", "Release", "MSVC" ] },
{ "name": "x86-Debug" , "description": "MSVC for x86 (Debug)", "inherits": [ "base", "x86", "Debug", "MSVC" ] },
{ "name": "x86-Release" , "description": "MSVC for x86 (Release)", "inherits": [ "base", "x86", "Release", "MSVC" ] },
{ "name": "arm64-Debug" , "description": "MSVC for ARM64 (Debug)", "inherits": [ "base", "ARM64", "Debug", "MSVC" ] },
{ "name": "arm64-Release" , "description": "MSVC for ARM64 (Release)", "inherits": [ "base", "ARM64", "Release", "MSVC" ] },
{ "name": "x64-Debug-Clang" , "description": "Clang/LLVM for x64 (Debug)", "inherits": [ "base", "x64", "Debug", "Clang" ] },
{ "name": "x64-Release-Clang" , "description": "Clang/LLVM for x64 (Release)", "inherits": [ "base", "x64", "Release", "Clang" ] },
{ "name": "x86-Debug-Clang" , "description": "Clang/LLVM for x86 (Debug)", "inherits": [ "base", "x86", "Debug", "Clang" ], "environment": { "CXXFLAGS": "-m32" } },
{ "name": "x86-Release-Clang" , "description": "Clang/LLVM for x86 (Release)", "inherits": [ "base", "x86", "Release", "Clang" ], "environment": { "CXXFLAGS": "-m32" } }
]
}

Просмотреть файл

@ -14,7 +14,7 @@
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
#include "dxut.h"
#include "DXUT.h"
#include "DDSTextureLoader.h"
#include <algorithm>

Просмотреть файл

@ -30,10 +30,23 @@ bool g_bThreadSafe = true;
class DXUTLock
{
public:
#ifdef _PREFAST_
#pragma prefast(push)
#pragma prefast( suppress:26166, "g_bThreadSafe controls behavior" )
#endif
inline _Acquires_lock_(g_cs) DXUTLock() noexcept { if( g_bThreadSafe ) EnterCriticalSection( &g_cs ); }
#ifdef _PREFAST_
#pragma prefast( suppress:26165, "g_bThreadSafe controls behavior" )
#endif
inline _Releases_lock_(g_cs) ~DXUTLock() { if( g_bThreadSafe ) LeaveCriticalSection( &g_cs ); }
#ifdef _PREFAST_
#pragma prefast(pop)
#endif
};
//--------------------------------------------------------------------------------------
@ -707,7 +720,7 @@ HRESULT WINAPI DXUTInit( bool bParseCommandLine,
memset( &tk, 0, sizeof(tk) );
GetDXUTState().SetStartupToggleKeys( tk );
FILTERKEYS fk = {sizeof(FILTERKEYS), 0};
FILTERKEYS fk = { sizeof(FILTERKEYS), 0, 0, 0, 0, 0 };
if ( !SystemParametersInfo(SPI_GETFILTERKEYS, sizeof(FILTERKEYS), &fk, 0) )
memset( &fk, 0, sizeof(fk) );
GetDXUTState().SetStartupFilterKeys( fk );
@ -1570,11 +1583,11 @@ LRESULT CALLBACK DXUTStaticWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
// Don't allow the F10 key to act as a shortcut to the menu bar
// by not passing these messages to the DefWindowProc only when
// there's no menu present
if( !GetDXUTState().GetCallDefWindowProc() || !GetDXUTState().GetMenu() &&
( uMsg == WM_SYSKEYDOWN || uMsg == WM_SYSKEYUP ) && wParam == VK_F10 )
if (!GetDXUTState().GetCallDefWindowProc() || (!GetDXUTState().GetMenu() &&
(uMsg == WM_SYSKEYDOWN || uMsg == WM_SYSKEYUP) && wParam == VK_F10))
return 0;
else
return DefWindowProc( hWnd, uMsg, wParam, lParam );
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
@ -1722,7 +1735,7 @@ HRESULT WINAPI DXUTCreateDevice(D3D_FEATURE_LEVEL reqFL, bool bWindowed, int nS
memset( &osv, 0, sizeof(osv) );
osv.dwOSVersionInfoSize = sizeof(osv);
#pragma warning( suppress : 4996 28159 )
GetVersionEx( (LPOSVERSIONINFO)&osv );
std::ignore = GetVersionEx( (LPOSVERSIONINFO)&osv );
if ( ( osv.dwMajorVersion > 6 )
|| ( osv.dwMajorVersion == 6 && osv.dwMinorVersion >= 1 )
@ -3527,7 +3540,7 @@ HRESULT WINAPI DXUTToggleFullScreen()
{
static const DXGI_MODE_DESC s_adapterDesktopDisplayMode =
{
800, 600, { 0, 0 }, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
800, 600, { 0, 0 }, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED, DXGI_MODE_SCALING_UNSPECIFIED,
};
memcpy(&adapterDesktopDisplayMode, &s_adapterDesktopDisplayMode, sizeof(DXGI_MODE_DESC));
}

Просмотреть файл

@ -51,16 +51,18 @@
#define NOMINMAX
#endif
#include <windows.h>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <new>
#include <tuple>
#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)

Просмотреть файл

@ -15,8 +15,6 @@
//--------------------------------------------------------------------------------------
extern void DXUTGetCallbackD3D11DeviceAcceptable( LPDXUTCALLBACKISD3D11DEVICEACCEPTABLE* ppCallbackIsDeviceAcceptable, void** ppUserContext );
static int __cdecl SortModesCallback( const void* arg1, const void* arg2 );
CD3D11Enumeration* g_pDXUTD3D11Enumeration = nullptr;
HRESULT WINAPI DXUTCreateD3D11Enumeration()

Просмотреть файл

@ -8,7 +8,7 @@
//
// http://go.microsoft.com/fwlink/?LinkId=320437
//--------------------------------------------------------------------------------------
#include "dxut.h"
#include "DXUT.h"
#include <xinput.h>
#include "ScreenGrab.h"
@ -1246,7 +1246,7 @@ HRESULT DXUTSnapD3D11Screenshot( _In_z_ LPCWSTR szFileName, _In_ bool usedds )
if (!pSwap)
return E_FAIL;
ID3D11Texture2D* pBackBuffer;
ID3D11Texture2D* pBackBuffer = nullptr;
HRESULT hr = pSwap->GetBuffer( 0, __uuidof( *pBackBuffer ), ( LPVOID* )&pBackBuffer );
if (hr != S_OK)
return hr;

Просмотреть файл

@ -15,7 +15,7 @@
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
#include "dxut.h"
#include "DXUT.h"
// Does not capture 1D textures or 3D textures (volume maps)

Просмотреть файл

@ -21,7 +21,7 @@
// http://go.microsoft.com/fwlink/?LinkId=248929
//--------------------------------------------------------------------------------------
#include "dxut.h"
#include "DXUT.h"
// We could load multi-frame images (TIFF/GIF) into a texture array.
// For now, we just load the first frame (note: DirectXTex supports multi-frame images)
@ -167,7 +167,9 @@ namespace
// We don't support n-channel formats
};
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
bool g_WIC2 = false;
#endif
BOOL WINAPI InitializeWICFactory(PINIT_ONCE, PVOID, PVOID *ifactory) noexcept
{

Просмотреть файл

@ -6,7 +6,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//--------------------------------------------------------------------------------------
#include "dxut.h"
#include "DXUT.h"
// This version only supports UNICODE.
@ -151,35 +151,35 @@ const WCHAR* WINAPI DXGetErrorStringW( _In_ HRESULT hr )
CHK_ERRA(DV_E_DVASPECT)
CHK_ERRA(DV_E_DVTARGETDEVICE_SIZE)
CHK_ERRA(DV_E_NOIVIEWOBJECT)
CHK_ERRA(DRAGDROP_E_FIRST)
CHK_ERRA(DRAGDROP_E_LAST)
CHK_ERRA(DRAGDROP_S_FIRST)
CHK_ERRA(DRAGDROP_S_LAST)
CHK_ERRA(_HRESULT_TYPEDEF_(DRAGDROP_E_FIRST))
CHK_ERRA(_HRESULT_TYPEDEF_(DRAGDROP_E_LAST))
CHK_ERRA(_HRESULT_TYPEDEF_(DRAGDROP_S_FIRST))
CHK_ERRA(_HRESULT_TYPEDEF_(DRAGDROP_S_LAST))
// CHK_ERRA(DRAGDROP_E_NOTREGISTERED)
CHK_ERRA(DRAGDROP_E_ALREADYREGISTERED)
CHK_ERRA(DRAGDROP_E_INVALIDHWND)
CHK_ERRA(CLASSFACTORY_E_FIRST)
CHK_ERRA(CLASSFACTORY_E_LAST)
CHK_ERRA(_HRESULT_TYPEDEF_(CLASSFACTORY_E_FIRST))
CHK_ERRA(_HRESULT_TYPEDEF_(CLASSFACTORY_E_LAST))
CHK_ERRA(CLASSFACTORY_S_FIRST)
CHK_ERRA(CLASSFACTORY_S_LAST)
// CHK_ERRA(CLASS_E_NOAGGREGATION)
CHK_ERRA(CLASS_E_CLASSNOTAVAILABLE)
CHK_ERRA(CLASS_E_NOTLICENSED)
CHK_ERRA(MARSHAL_E_FIRST)
CHK_ERRA(MARSHAL_E_LAST)
CHK_ERRA(_HRESULT_TYPEDEF_(MARSHAL_E_FIRST))
CHK_ERRA(_HRESULT_TYPEDEF_(MARSHAL_E_LAST))
CHK_ERRA(MARSHAL_S_FIRST)
CHK_ERRA(MARSHAL_S_LAST)
CHK_ERRA(DATA_E_FIRST)
CHK_ERRA(DATA_E_LAST)
CHK_ERRA(_HRESULT_TYPEDEF_(DATA_E_FIRST))
CHK_ERRA(_HRESULT_TYPEDEF_(DATA_E_LAST))
CHK_ERRA(DATA_S_FIRST)
CHK_ERRA(DATA_S_LAST)
CHK_ERRA(VIEW_E_FIRST)
CHK_ERRA(VIEW_E_LAST)
CHK_ERRA(_HRESULT_TYPEDEF_(VIEW_E_FIRST))
CHK_ERRA(_HRESULT_TYPEDEF_(VIEW_E_LAST))
CHK_ERRA(VIEW_S_FIRST)
CHK_ERRA(VIEW_S_LAST)
// CHK_ERRA(VIEW_E_DRAW)
CHK_ERRA(REGDB_E_FIRST)
CHK_ERRA(REGDB_E_LAST)
CHK_ERRA(_HRESULT_TYPEDEF_(REGDB_E_FIRST))
CHK_ERRA(_HRESULT_TYPEDEF_(REGDB_E_LAST))
CHK_ERRA(REGDB_S_FIRST)
CHK_ERRA(REGDB_S_LAST)
// CHK_ERRA(REGDB_E_READREGDB)
@ -188,12 +188,12 @@ const WCHAR* WINAPI DXGetErrorStringW( _In_ HRESULT hr )
CHK_ERRA(REGDB_E_INVALIDVALUE)
CHK_ERRA(REGDB_E_CLASSNOTREG)
CHK_ERRA(REGDB_E_IIDNOTREG)
CHK_ERRA(CAT_E_FIRST)
CHK_ERRA(CAT_E_LAST)
CHK_ERRA(_HRESULT_TYPEDEF_(CAT_E_FIRST))
CHK_ERRA(_HRESULT_TYPEDEF_(CAT_E_LAST))
// CHK_ERRA(CAT_E_CATIDNOEXIST)
// CHK_ERRA(CAT_E_NODESCRIPTION)
CHK_ERRA(CS_E_FIRST)
CHK_ERRA(CS_E_LAST)
CHK_ERRA(_HRESULT_TYPEDEF_(CS_E_FIRST))
CHK_ERRA(_HRESULT_TYPEDEF_(CS_E_LAST))
// CHK_ERRA(CS_E_PACKAGE_NOTFOUND)
CHK_ERRA(CS_E_NOT_DELETABLE)
CHK_ERRA(CS_E_CLASS_NOTFOUND)
@ -206,33 +206,33 @@ const WCHAR* WINAPI DXGetErrorStringW( _In_ HRESULT hr )
CHK_ERRA(CS_E_ADMIN_LIMIT_EXCEEDED)
CHK_ERRA(CS_E_SCHEMA_MISMATCH)
// CHK_ERRA(CS_E_INTERNAL_ERROR)
CHK_ERRA(CACHE_E_FIRST)
CHK_ERRA(CACHE_E_LAST)
CHK_ERRA(_HRESULT_TYPEDEF_(CACHE_E_FIRST))
CHK_ERRA(_HRESULT_TYPEDEF_(CACHE_E_LAST))
CHK_ERRA(CACHE_S_FIRST)
CHK_ERRA(CACHE_S_LAST)
// CHK_ERRA(CACHE_E_NOCACHE_UPDATED)
CHK_ERRA(OLEOBJ_E_FIRST)
CHK_ERRA(OLEOBJ_E_LAST)
CHK_ERRA(_HRESULT_TYPEDEF_(OLEOBJ_E_FIRST))
CHK_ERRA(_HRESULT_TYPEDEF_(OLEOBJ_E_LAST))
CHK_ERRA(OLEOBJ_S_FIRST)
CHK_ERRA(OLEOBJ_S_LAST)
// CHK_ERRA(OLEOBJ_E_NOVERBS)
CHK_ERRA(OLEOBJ_E_INVALIDVERB)
CHK_ERRA(CLIENTSITE_E_FIRST)
CHK_ERRA(CLIENTSITE_E_LAST)
CHK_ERRA(_HRESULT_TYPEDEF_(CLIENTSITE_E_FIRST))
CHK_ERRA(_HRESULT_TYPEDEF_(CLIENTSITE_E_LAST))
CHK_ERRA(CLIENTSITE_S_FIRST)
CHK_ERRA(CLIENTSITE_S_LAST)
CHK_ERRA(INPLACE_E_NOTUNDOABLE)
CHK_ERRA(INPLACE_E_NOTOOLSPACE)
// CHK_ERRA(INPLACE_E_FIRST)
CHK_ERRA(INPLACE_E_LAST)
CHK_ERRA(_HRESULT_TYPEDEF_(INPLACE_E_LAST))
CHK_ERRA(INPLACE_S_FIRST)
CHK_ERRA(INPLACE_S_LAST)
CHK_ERRA(ENUM_E_FIRST)
CHK_ERRA(ENUM_E_LAST)
CHK_ERRA(_HRESULT_TYPEDEF_(ENUM_E_FIRST))
CHK_ERRA(_HRESULT_TYPEDEF_(ENUM_E_LAST))
CHK_ERRA(ENUM_S_FIRST)
CHK_ERRA(ENUM_S_LAST)
CHK_ERRA(CONVERT10_E_FIRST)
CHK_ERRA(CONVERT10_E_LAST)
CHK_ERRA(_HRESULT_TYPEDEF_(CONVERT10_E_FIRST))
CHK_ERRA(_HRESULT_TYPEDEF_(CONVERT10_E_LAST))
CHK_ERRA(CONVERT10_S_FIRST)
CHK_ERRA(CONVERT10_S_LAST)
// CHK_ERRA(CONVERT10_E_OLESTREAM_GET)
@ -242,8 +242,8 @@ const WCHAR* WINAPI DXGetErrorStringW( _In_ HRESULT hr )
CHK_ERRA(CONVERT10_E_STG_FMT)
CHK_ERRA(CONVERT10_E_STG_NO_STD_STREAM)
CHK_ERRA(CONVERT10_E_STG_DIB_TO_BITMAP)
CHK_ERRA(CLIPBRD_E_FIRST)
CHK_ERRA(CLIPBRD_E_LAST)
CHK_ERRA(_HRESULT_TYPEDEF_(CLIPBRD_E_FIRST))
CHK_ERRA(_HRESULT_TYPEDEF_(CLIPBRD_E_LAST))
CHK_ERRA(CLIPBRD_S_FIRST)
CHK_ERRA(CLIPBRD_S_LAST)
// CHK_ERRA(CLIPBRD_E_CANT_OPEN)
@ -251,8 +251,8 @@ const WCHAR* WINAPI DXGetErrorStringW( _In_ HRESULT hr )
CHK_ERRA(CLIPBRD_E_CANT_SET)
CHK_ERRA(CLIPBRD_E_BAD_DATA)
CHK_ERRA(CLIPBRD_E_CANT_CLOSE)
CHK_ERRA(MK_E_FIRST)
CHK_ERRA(MK_E_LAST)
CHK_ERRA(_HRESULT_TYPEDEF_(MK_E_FIRST))
CHK_ERRA(_HRESULT_TYPEDEF_(MK_E_LAST))
CHK_ERRA(MK_S_FIRST)
CHK_ERRA(MK_S_LAST)
// CHK_ERRA(MK_E_CONNECTMANUALLY)
@ -2113,8 +2113,8 @@ const WCHAR* WINAPI DXGetErrorStringW( _In_ HRESULT hr )
// CHK_ERRA(EVENT_E_CANT_MODIFY_OR_DELETE_CONFIGURED_OBJECT)
// CHK_ERRA(EVENT_E_INVALID_EVENT_CLASS_PARTITION)
// CHK_ERRA(EVENT_E_PER_USER_SID_NOT_LOGGED_ON)
CHK_ERRA(CONTEXT_E_FIRST)
CHK_ERRA(CONTEXT_E_LAST)
CHK_ERRA(_HRESULT_TYPEDEF_(CONTEXT_E_FIRST))
CHK_ERRA(_HRESULT_TYPEDEF_(CONTEXT_E_LAST))
CHK_ERRA(CONTEXT_S_FIRST)
CHK_ERRA(CONTEXT_S_LAST)
CHK_ERRA(CONTEXT_E_ABORTED)
@ -3262,10 +3262,10 @@ const WCHAR* WINAPI DXGetErrorStringW( _In_ HRESULT hr )
// -------------------------------------------------------------
// xaudio2.h error codes
// -------------------------------------------------------------
CHK_ERRA(XAUDIO2_E_INVALID_CALL)
CHK_ERRA(XAUDIO2_E_XMA_DECODER_ERROR)
CHK_ERRA(XAUDIO2_E_XAPO_CREATION_FAILED)
CHK_ERRA(XAUDIO2_E_DEVICE_INVALIDATED)
CHK_ERRA(_HRESULT_TYPEDEF_(XAUDIO2_E_INVALID_CALL))
CHK_ERRA(_HRESULT_TYPEDEF_(XAUDIO2_E_XMA_DECODER_ERROR))
CHK_ERRA(_HRESULT_TYPEDEF_(XAUDIO2_E_XAPO_CREATION_FAILED))
CHK_ERRA(_HRESULT_TYPEDEF_(XAUDIO2_E_DEVICE_INVALIDATED))
// -------------------------------------------------------------
// xapo.h error codes
@ -3590,10 +3590,10 @@ void WINAPI DXGetErrorDescriptionW( _In_ HRESULT hr, _Out_cap_(count) WCHAR* des
// -------------------------------------------------------------
// xaudio2.h error codes
// -------------------------------------------------------------
CHK_ERR(XAUDIO2_E_INVALID_CALL, "Invalid XAudio2 API call or arguments")
CHK_ERR(XAUDIO2_E_XMA_DECODER_ERROR, "Hardware XMA decoder error")
CHK_ERR(XAUDIO2_E_XAPO_CREATION_FAILED, "Failed to create an audio effect")
CHK_ERR(XAUDIO2_E_DEVICE_INVALIDATED, "Device invalidated (unplugged, disabled, etc)")
CHK_ERR(_HRESULT_TYPEDEF_(XAUDIO2_E_INVALID_CALL), "Invalid XAudio2 API call or arguments")
CHK_ERR(_HRESULT_TYPEDEF_(XAUDIO2_E_XMA_DECODER_ERROR), "Hardware XMA decoder error")
CHK_ERR(_HRESULT_TYPEDEF_(XAUDIO2_E_XAPO_CREATION_FAILED), "Failed to create an audio effect")
CHK_ERR(_HRESULT_TYPEDEF_(XAUDIO2_E_DEVICE_INVALIDATED), "Device invalidated (unplugged, disabled, etc)")
// -------------------------------------------------------------
// xapo.h error codes

Просмотреть файл

@ -8,10 +8,10 @@
//--------------------------------------------------------------------------------------
#include "DXUT.h"
#include "DXUTgui.h"
#include "DXUTsettingsDlg.h"
#include "DXUTsettingsdlg.h"
#include "DXUTres.h"
#include "SDKMisc.h"
#include "SDKmisc.h"
#include "DDSTextureLoader.h"
@ -609,10 +609,10 @@ HRESULT CDXUTDialog::OnRender( _In_ float fElapsedTime )
DXUT_SCREEN_VERTEX_10 vertices[4] =
{
Left, Top, 0.5f, D3DCOLOR_TO_D3DCOLORVALUE( m_colorTopLeft ), 0.0f, 0.0f,
Right, Top, 0.5f, D3DCOLOR_TO_D3DCOLORVALUE( m_colorTopRight ), 1.0f, 0.0f,
Left, Bottom, 0.5f, D3DCOLOR_TO_D3DCOLORVALUE( m_colorBottomLeft ), 0.0f, 1.0f,
Right, Bottom, 0.5f, D3DCOLOR_TO_D3DCOLORVALUE( m_colorBottomRight ), 1.0f, 1.0f,
{ Left, Top, 0.5f, D3DCOLOR_TO_D3DCOLORVALUE(m_colorTopLeft), 0.0f, 0.0f },
{ Right, Top, 0.5f, D3DCOLOR_TO_D3DCOLORVALUE(m_colorTopRight), 1.0f, 0.0f },
{ Left, Bottom, 0.5f, D3DCOLOR_TO_D3DCOLORVALUE(m_colorBottomLeft), 0.0f, 1.0f },
{ Right, Bottom, 0.5f, D3DCOLOR_TO_D3DCOLORVALUE(m_colorBottomRight), 1.0f, 1.0f },
};
//DXUT_SCREEN_VERTEX_10 *pVB;
@ -4398,9 +4398,6 @@ void CDXUTSlider::Render( _In_ float fElapsedTime )
if( m_bVisible == false )
return;
int nOffsetX = 0;
int nOffsetY = 0;
DXUT_CONTROL_STATE iState = DXUT_STATE_NORMAL;
if( m_bVisible == false )
@ -4414,16 +4411,10 @@ void CDXUTSlider::Render( _In_ float fElapsedTime )
else if( m_bPressed )
{
iState = DXUT_STATE_PRESSED;
nOffsetX = 1;
nOffsetY = 2;
}
else if( m_bMouseOver )
{
iState = DXUT_STATE_MOUSEOVER;
nOffsetX = -1;
nOffsetY = -2;
}
else if( m_bHasFocus )
{
@ -6000,7 +5991,7 @@ bool CDXUTEditBox::MsgProc( UINT uMsg, WPARAM wParam, LPARAM lParam )
case 16: // Ctrl P
case 27: // Ctrl [
case 29: // Ctrl ]
case 28: // Ctrl \
case 28: // Ctrl \ (backslash)
break;
default:

Просмотреть файл

@ -664,7 +664,7 @@ public:
void SetChecked( _In_ bool bChecked ) { SetCheckedInternal( bChecked, false ); }
protected:
virtual void SetCheckedInternal( _In_ bool bChecked, _In_ bool bFromInput );
void SetCheckedInternal( _In_ bool bChecked, _In_ bool bFromInput );
bool m_bChecked;
RECT m_rcButton;
@ -693,7 +693,7 @@ public:
UINT GetButtonGroup() const { return m_nButtonGroup; }
protected:
virtual void SetCheckedInternal( _In_ bool bChecked, _In_ bool bClearGroup, _In_ bool bFromInput );
void SetCheckedInternal( _In_ bool bChecked, _In_ bool bClearGroup, _In_ bool bFromInput );
UINT m_nButtonGroup;
};

Просмотреть файл

@ -8,7 +8,7 @@
//--------------------------------------------------------------------------------------
#include "DXUT.h"
#include "DXUTgui.h"
#include "DXUTsettingsDlg.h"
#include "DXUTsettingsdlg.h"
#include "DXUTres.h"
#include "DXUTgui.h"
#include "DXUTguiIME.h"
@ -249,11 +249,8 @@ void CDXUTIMEEditBox::OnFocusOut()
//--------------------------------------------------------------------------------------
_Use_decl_annotations_
bool CDXUTIMEEditBox::StaticMsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
bool CDXUTIMEEditBox::StaticMsgProc( HWND, UINT uMsg, WPARAM, LPARAM)
{
UNREFERENCED_PARAMETER(hWnd);
UNREFERENCED_PARAMETER(wParam);
if( !ImeUi_IsEnabled() )
return false;
@ -274,7 +271,6 @@ bool CDXUTIMEEditBox::StaticMsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
//
// We don't want anything to display, so we have to clear this
//
lParam = 0;
return false;
// Handle WM_IME_STARTCOMPOSITION here since

Просмотреть файл

@ -8211,7 +8211,7 @@ static const DWORD g_DXUTGUITextureSrcData[] =
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000
};
static const UINT g_DXUTGUITextureSrcDataSizeInBytes = 262272;
static constexpr UINT g_DXUTGUITextureSrcDataSizeInBytes = 262272;
static const DWORD g_DXUTArrowMeshSrcData[] =
{
@ -8286,7 +8286,7 @@ static const DWORD g_DXUTArrowMeshSrcData[] =
0x156e5c3f, 0xc4db201f, 0x7b8fc5c7, 0xf7e2221b, 0x0000001f
};
static const UINT g_DXUTArrowMeshSrcDataSizeInBytes = 2193;
static constexpr UINT g_DXUTArrowMeshSrcDataSizeInBytes = 2193;
//--------------------------------------------------------------------------------------
_Use_decl_annotations_

Просмотреть файл

@ -10,7 +10,7 @@
//--------------------------------------------------------------------------------------
#include "DXUT.h"
#include "DXUTgui.h"
#include "DXUTsettingsDlg.h"
#include "DXUTsettingsdlg.h"
//--------------------------------------------------------------------------------------
// Internal functions forward declarations

Просмотреть файл

@ -6,7 +6,7 @@
//
// http://go.microsoft.com/fwlink/?LinkId=320437
//--------------------------------------------------------------------------------------
#include "dxut.h"
#include "DXUT.h"
#include "ImeUi.h"
#include <math.h>
#include <msctf.h>
@ -17,7 +17,9 @@
#pragma warning( disable : 4244 )
#pragma warning( disable : 4311 )
#ifdef _PREFAST_
#pragma prefast( disable : 28159, "GetTickCount() is fine for a blinking cursor" )
#endif
#define MAX_CANDIDATE_LENGTH 256
#define COUNTOF(a) ( sizeof( a ) / sizeof( ( a )[0] ) )
@ -54,7 +56,7 @@
#define IMEID_CHS_VER42 ( LANG_CHS | MAKEIMEVERSION( 4, 2 ) ) // MSPY2 // Win2k/WinME
#define IMEID_CHS_VER53 ( LANG_CHS | MAKEIMEVERSION( 5, 3 ) ) // MSPY3 // WinXP
static CHAR signature[] = "%%%IMEUILIB:070111%%%";
static const CHAR signature[] = "%%%IMEUILIB:070111%%%";
static IMEUI_APPEARANCE gSkinIME =
{
@ -458,7 +460,7 @@ static void ComposeCandidateLine( int index, LPCTSTR pszCandidate )
{
*psz++ = TEXT( ' ' );
}
while( *pszCandidate && ( COUNTOF(g_szCandidate[index]) > ( psz - g_szCandidate[index] ) ) )
while (*pszCandidate && (static_cast<ptrdiff_t>(COUNTOF(g_szCandidate[index])) > (psz - g_szCandidate[index])))
{
*psz++ = *pszCandidate++;
}
@ -855,8 +857,8 @@ static void DrawCompositionString( _In_ bool bDrawCompAttr )
{
// make sure enough buffer space (possible space, NUL for current line, possible DBCS, 2 more NUL)
// are available in multiline composition string buffer
bool bWrite = ( pszMlcs - g_szMultiLineCompString <
COUNTOF( g_szMultiLineCompString ) - 5 * ( 3 - sizeof( TCHAR ) ) );
bool bWrite = (pszMlcs - g_szMultiLineCompString <
static_cast<ptrdiff_t>(COUNTOF(g_szMultiLineCompString) - 5 * (3 - sizeof(TCHAR))));
if( ( LONG )( bgX + wCompChar ) >= g_CaretInfo.margins.right )
{
@ -883,7 +885,7 @@ static void DrawCompositionString( _In_ bool bDrawCompAttr )
}
}
if( ( saveCandPos && candX == POSITION_UNINITIALIZED ) ||
( IMEID_LANG( GetImeId() ) == LANG_CHS && i / ( 3 - sizeof( TCHAR ) ) == ( int )g_IMECursorChars ) )
( IMEID_LANG( GetImeId() ) == LANG_CHS && static_cast<int>(i / ( 3 - sizeof( TCHAR ) )) == ( int )g_IMECursorChars ) )
{
candX = bgX;
candY = bgY;
@ -910,13 +912,12 @@ static void DrawCompositionString( _In_ bool bDrawCompAttr )
x = g_CaretInfo.caretX;
y = g_CaretInfo.caretY;
pszMlcs = g_szMultiLineCompString;
while( *pszMlcs &&
pszMlcs - g_szMultiLineCompString < sizeof( g_szMultiLineCompString ) / sizeof
( g_szMultiLineCompString[0] ) )
while (*pszMlcs &&
pszMlcs - g_szMultiLineCompString < static_cast<ptrdiff_t>(COUNTOF(g_szMultiLineCompString)))
{
g_CaretInfo.pFont->SetPosition( x, y );
g_CaretInfo.pFont->DrawText( pszMlcs );
pszMlcs += wcslen( pszMlcs ) + 1;
g_CaretInfo.pFont->SetPosition(x, y);
g_CaretInfo.pFont->DrawText(pszMlcs);
pszMlcs += wcslen(pszMlcs) + 1;
x = g_CaretInfo.margins.left;
y += hCompChar;
}
@ -1461,8 +1462,8 @@ LPARAM ImeUi_ProcessMessage( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM& lParam
_ImmReleaseContext( hWnd, himc );
// don't display selection in candidate list in case of Korean and old Chinese IME.
if( GETPRIMLANG() == LANG_KOREAN ||
GETLANG() == LANG_CHT && !GetImeId() )
if( (GETPRIMLANG() == LANG_KOREAN ||
GETLANG() == LANG_CHT) && !GetImeId() )
g_dwSelection = ( DWORD )-1;
}
break;
@ -1663,8 +1664,7 @@ void ImeUi_EnableIme( _In_ bool bEnable )
if( g_hwndCurr == g_hwndMain )
{
HIMC himcDbg;
himcDbg = _ImmAssociateContext( g_hwndCurr, bEnable? g_himcOrg : nullptr );
std::ignore = _ImmAssociateContext(g_hwndCurr, bEnable ? g_himcOrg : nullptr);
}
g_bImeEnabled = bEnable;
if( bEnable )
@ -1882,19 +1882,20 @@ static DWORD GetImeId( _In_ UINT uIndex )
DWORD dwVer = pVerFixedInfo->dwFileVersionMS;
dwVer = ( dwVer & 0x00ff0000 ) << 8 | ( dwVer & 0x000000ff ) << 16;
if( _GetReadingString ||
dwLang == LANG_CHT && (
(dwLang == LANG_CHT && (
dwVer == MAKEIMEVERSION(4, 2) ||
dwVer == MAKEIMEVERSION(4, 3) ||
dwVer == MAKEIMEVERSION(4, 4) ||
dwVer == MAKEIMEVERSION(5, 0) ||
dwVer == MAKEIMEVERSION(5, 1) ||
dwVer == MAKEIMEVERSION(5, 2) ||
dwVer == MAKEIMEVERSION(6, 0) )
dwVer == MAKEIMEVERSION(6, 0) ))
||
dwLang == LANG_CHS && (
(dwLang == LANG_CHS && (
dwVer == MAKEIMEVERSION(4, 1) ||
dwVer == MAKEIMEVERSION(4, 2) ||
dwVer == MAKEIMEVERSION(5, 3) ) )
dwVer == MAKEIMEVERSION(5, 3) ))
)
{
dwRet[0] = dwVer | dwLang;
dwRet[1] = pVerFixedInfo->dwFileVersionLS;
@ -2109,29 +2110,29 @@ static struct
}
aHotKeys[] =
{
false, false, false, VK_APPS,
true, false, false, '8',
true, false, false, 'Y',
true, false, false, VK_DELETE,
true, false, false, VK_F7,
true, false, false, VK_F9,
true, false, false, VK_F10,
true, false, false, VK_F11,
true, false, false, VK_F12,
false, false, false, VK_F2,
false, false, false, VK_F3,
false, false, false, VK_F4,
false, false, false, VK_F5,
false, false, false, VK_F10,
false, true, false, VK_F6,
false, true, false, VK_F7,
false, true, false, VK_F8,
true, true, false, VK_F10,
true, true, false, VK_F11,
true, false, false, VK_CONVERT,
true, false, false, VK_SPACE,
true, false, true, 0xbc, // Alt + Ctrl + ',': SW keyboard for Trad. Chinese IME
true, false, false, VK_TAB, // ATOK2005's Ctrl+TAB
{ false, false, false, VK_APPS },
{ true, false, false, '8' },
{ true, false, false, 'Y' },
{ true, false, false, VK_DELETE },
{ true, false, false, VK_F7 },
{ true, false, false, VK_F9 },
{ true, false, false, VK_F10 },
{ true, false, false, VK_F11 },
{ true, false, false, VK_F12 },
{ false, false, false, VK_F2 },
{ false, false, false, VK_F3 },
{ false, false, false, VK_F4 },
{ false, false, false, VK_F5 },
{ false, false, false, VK_F10 },
{ false, true, false, VK_F6 },
{ false, true, false, VK_F7 },
{ false, true, false, VK_F8 },
{ true, true, false, VK_F10 },
{ true, true, false, VK_F11 },
{ true, false, false, VK_CONVERT },
{ true, false, false, VK_SPACE },
{ true, false, true, 0xbc }, // Alt + Ctrl + ',': SW keyboard for Trad. Chinese IME
{ true, false, false, VK_TAB }, // ATOK2005's Ctrl+TAB
};
//
@ -2169,7 +2170,7 @@ bool ImeUi_IgnoreHotKey( _In_ const MSG* pmsg )
bCtrl = ( GetKeyState( VK_CONTROL ) & 0x8000 ) ? true : false;
bShift = ( GetKeyState( VK_SHIFT ) & 0x8000 ) ? true : false;
bAlt = ( GetKeyState( VK_MENU ) & 0x8000 ) ? true : false;
for( int i = 0; i < COUNTOF(aHotKeys); i++ )
for( size_t i = 0; i < COUNTOF(aHotKeys); i++ )
{
if( aHotKeys[i].m_bCtrl == bCtrl &&
aHotKeys[i].m_bShift == bShift &&
@ -2423,7 +2424,6 @@ void ImeUi_ToggleLanguageBar( _In_ BOOL bRestore )
if( SUCCEEDED( hr ) && plbm )
{
DWORD dwCur;
ULONG uRc;
if( SUCCEEDED( hr ) )
{
if( bRestore )
@ -2442,7 +2442,7 @@ void ImeUi_ToggleLanguageBar( _In_ BOOL bRestore )
}
}
}
uRc = plbm->Release();
plbm->Release();
}
CoUninitialize();
}
@ -2659,14 +2659,13 @@ BOOL CTsfUiLessMode::SetupSinks()
void CTsfUiLessMode::ReleaseSinks()
{
HRESULT hr;
ITfSource* source;
ITfSource* source = nullptr;
// Remove all sinks
if( m_tm && SUCCEEDED( m_tm->QueryInterface( __uuidof( ITfSource ), ( void** )&source ) ) )
{
hr = source->UnadviseSink( m_dwUIElementSinkCookie );
hr = source->UnadviseSink( m_dwAlpnSinkCookie );
std::ignore = source->UnadviseSink( m_dwUIElementSinkCookie );
std::ignore = source->UnadviseSink( m_dwAlpnSinkCookie );
source->Release();
SetupCompartmentSinks( TRUE ); // Remove all compartment sinks
m_tm->Deactivate();
@ -2863,7 +2862,7 @@ STDAPI CTsfUiLessMode::CUIElementSink::OnActivated( DWORD dwProfileType, LANGID
static GUID s_TF_PROFILE_DAYI =
{
0x037B2C25, 0x480C, 0x4D7F, 0xB0, 0x27, 0xD6, 0xCA, 0x6B, 0x69, 0x78, 0x8A
0x037B2C25, 0x480C, 0x4D7F, { 0xB0, 0x27, 0xD6, 0xCA, 0x6B, 0x69, 0x78, 0x8A }
};
g_iCandListIndexBase = IsEqualGUID( s_TF_PROFILE_DAYI, guidProfile ) ? 0 : 1;
if( IsEqualIID( catid, GUID_TFCAT_TIP_KEYBOARD ) && ( dwFlags & TF_IPSINK_FLAG_ACTIVE ) )
@ -3080,7 +3079,7 @@ BOOL CTsfUiLessMode::GetCompartments( ITfCompartmentMgr** ppcm, ITfCompartment**
static GUID _GUID_COMPARTMENT_KEYBOARD_INPUTMODE_CONVERSION =
{
0xCCF05DD8, 0x4A87, 0x11D7, 0xA6, 0xE2, 0x00, 0x06, 0x5B, 0x84, 0x43, 0x5C
0xCCF05DD8, 0x4A87, 0x11D7, { 0xA6, 0xE2, 0x00, 0x06, 0x5B, 0x84, 0x43, 0x5C }
};
HRESULT hr;

Просмотреть файл

@ -12,8 +12,8 @@
// http://go.microsoft.com/fwlink/?LinkId=320437
//--------------------------------------------------------------------------------------
#include "DXUT.h"
#include "SDKMesh.h"
#include "SDKMisc.h"
#include "SDKmesh.h"
#include "SDKmisc.h"
using namespace DirectX;
@ -704,9 +704,7 @@ CDXUTSDKMesh::CDXUTSDKMesh() noexcept :
m_NumOutstandingResources(0),
m_bLoading(false),
m_hFile(0),
m_hFileMappingObject(0),
m_pDev11(nullptr),
m_pDevContext11(nullptr),
m_pStaticMeshData(nullptr),
m_pHeapData(nullptr),
m_pAnimationData(nullptr),

Просмотреть файл

@ -299,10 +299,8 @@ private:
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

Просмотреть файл

@ -8,11 +8,11 @@
//
// http://go.microsoft.com/fwlink/?LinkId=320437
//--------------------------------------------------------------------------------------
#include "dxut.h"
#include "DXUT.h"
#include "SDKmisc.h"
#include "DXUTres.h"
#include "DXUTGui.h"
#include "DXUTgui.h"
#include "DDSTextureLoader.h"
#include "WICTextureLoader.h"
@ -355,37 +355,37 @@ bool DXUTFindMediaSearchTypicalDirs( WCHAR* strSearchPath, int cchSearch, LPCWST
// %EXE_DIR%\..\..\%EXE_NAME%
// DXSDK media path
// Search in .\
// Search in ".\"
wcscpy_s( strSearchPath, cchSearch, strLeaf );
if( GetFileAttributes( strSearchPath ) != 0xFFFFFFFF )
return true;
// Search in ..\
// Search in "..\"
swprintf_s( strSearchPath, cchSearch, L"..\\%ls", strLeaf );
if( GetFileAttributes( strSearchPath ) != 0xFFFFFFFF )
return true;
// Search in ..\..\
// Search in "..\..\"
swprintf_s( strSearchPath, cchSearch, L"..\\..\\%ls", strLeaf );
if( GetFileAttributes( strSearchPath ) != 0xFFFFFFFF )
return true;
// Search in ..\..\
// Search in "..\..\"
swprintf_s( strSearchPath, cchSearch, L"..\\..\\%ls", strLeaf );
if( GetFileAttributes( strSearchPath ) != 0xFFFFFFFF )
return true;
// Search in the %EXE_DIR%\
// Search in the "%EXE_DIR%\"
swprintf_s( strSearchPath, cchSearch, L"%ls\\%ls", strExePath, strLeaf );
if( GetFileAttributes( strSearchPath ) != 0xFFFFFFFF )
return true;
// Search in the %EXE_DIR%\..\
// Search in the "%EXE_DIR%\..\"
swprintf_s( strSearchPath, cchSearch, L"%ls\\..\\%ls", strExePath, strLeaf );
if( GetFileAttributes( strSearchPath ) != 0xFFFFFFFF )
return true;
// Search in the %EXE_DIR%\..\..\
// Search in the "%EXE_DIR%\..\..\"
swprintf_s( strSearchPath, cchSearch, L"%ls\\..\\..\\%ls", strExePath, strLeaf );
if( GetFileAttributes( strSearchPath ) != 0xFFFFFFFF )
return true;
@ -768,22 +768,22 @@ XMMATRIX WINAPI DXUTGetCubeMapViewMatrix( _In_ DWORD dwFace )
{
static const XMVECTORF32 s_vLookDir[] =
{
{ 1.0f, 0.0f, 0.0f, 0.0f },
{ -1.0f, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f, 0.0f, 0.0f },
{ 0.0f, -1.0f, 0.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, -1.0f, 0.0f },
{ { { 1.0f, 0.0f, 0.0f, 0.0f } } },
{ { { -1.0f, 0.0f, 0.0f, 0.0f } } },
{ { { 0.0f, 1.0f, 0.0f, 0.0f } } },
{ { { 0.0f, -1.0f, 0.0f, 0.0f } } },
{ { { 0.0f, 0.0f, 1.0f, 0.0f } } },
{ { { 0.0f, 0.0f, -1.0f, 0.0f } } },
};
static const XMVECTORF32 s_vUpDir[] =
{
{ 0.0f, 1.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f, 0.0f, 0.0f },
{ 0.0f, 0.0f, -1.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f, 0.0f },
{ 0.0f, 1.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f, 0.0f, 0.0f },
{ { { 0.0f, 1.0f, 0.0f, 0.0f } } },
{ { { 0.0f, 1.0f, 0.0f, 0.0f } } },
{ { { 0.0f, 0.0f, -1.0f, 0.0f } } },
{ { { 0.0f, 0.0f, 1.0f, 0.0f } } },
{ { { 0.0f, 1.0f, 0.0f, 0.0f } } },
{ { { 0.0f, 1.0f, 0.0f, 0.0f } } },
};
static_assert( _countof(s_vLookDir) == _countof(s_vUpDir), "arrays mismatch" );