diff --git a/.nuget/DirectXTex-config.cmake.in b/.nuget/DirectXTex-config.cmake.in index ccb9250..2538e16 100644 --- a/.nuget/DirectXTex-config.cmake.in +++ b/.nuget/DirectXTex-config.cmake.in @@ -8,7 +8,7 @@ if(ENABLE_OPENEXR_SUPPORT) find_dependency(OpenEXR) endif() -if((NOT WIN32) OR VCPKG_TOOLCHAIN) +if(MINGW OR (NOT WIN32) OR VCPKG_TOOLCHAIN) find_dependency(directx-headers CONFIG) find_dependency(directxmath CONFIG) endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index 796d6d5..56c395e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -156,7 +156,7 @@ if(ENABLE_OPENEXR_SUPPORT) target_include_directories(${PROJECT_NAME} PRIVATE ${OPENEXR_INCLUDE_DIRS}/OpenEXR) endif() -if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16") +if ((${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16") AND (NOT MINGW)) target_precompile_headers(${PROJECT_NAME} PRIVATE DirectXTex/DirectXTexP.h) endif() @@ -172,7 +172,7 @@ if(MSVC) string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}) endif() -if ((NOT WIN32) OR VCPKG_TOOLCHAIN) +if (MINGW OR (NOT WIN32) OR VCPKG_TOOLCHAIN) message("INFO: Using VCPKG for DirectX-Headers and DirectXMath.") find_package(directx-headers CONFIG REQUIRED) find_package(directxmath CONFIG REQUIRED) @@ -268,7 +268,7 @@ if(BUILD_SAMPLE AND BUILD_DX11 AND WIN32 AND (NOT WINDOWS_STORE)) endif() endif() -if ((NOT WIN32) OR VCPKG_TOOLCHAIN) +if (MINGW OR (NOT WIN32) OR VCPKG_TOOLCHAIN) foreach(t IN LISTS TOOL_EXES) target_link_libraries(${t} Microsoft::DirectXMath) endforeach() @@ -282,12 +282,23 @@ if(MSVC) if((${CMAKE_SIZEOF_VOID_P} EQUAL 4) AND (NOT ${DIRECTX_ARCH} MATCHES "^arm")) foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME}) - target_compile_options(${t} PRIVATE /arch:SSE2) target_link_options(${t} PRIVATE /SAFESEH) endforeach() endif() endif() +if(NOT ${DIRECTX_ARCH} MATCHES "^arm") + if (${CMAKE_SIZEOF_VOID_P} EQUAL "4") + set(ARCH_SSE2 $<$:/arch:SSE2> $<$>:-msse2>) + else() + set(ARCH_SSE2 $<$>:-msse2>) + endif() + + foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME}) + target_compile_options(${t} PRIVATE ${ARCH_SSE2}) + endforeach() +endif() + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(WarningsLib "-Wpedantic" "-Wextra") target_compile_options(${PROJECT_NAME} PRIVATE ${WarningsLib}) @@ -299,6 +310,12 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") target_compile_options(${t} PRIVATE ${WarningsEXE}) endforeach() endif() +if(MINGW) + foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME}) + target_compile_options(${t} PRIVATE -Wno-ignored-attributes) + target_link_options(${t} PRIVATE -municode) + endforeach() +endif() if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME}) target_compile_options(${t} PRIVATE /sdl /permissive- /JMC- /Zc:__cplusplus) diff --git a/CMakePresets.json b/CMakePresets.json index d77c18e..16e821e 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -81,6 +81,17 @@ "strategy": "external" } }, + { + "name": "GNUC", + "hidden": true, + "cacheVariables": { + "CMAKE_CXX_COMPILER": "g++.exe" + }, + "toolset": { + "value": "host=x64", + "strategy": "external" + } + }, { "name": "Win7", @@ -151,9 +162,14 @@ { "name": "arm64-Debug-UWP-Clang" , "description": "Clang/LLVM for AArch64 (Debug) for UWP", "inherits": [ "base", "ARM64", "Debug", "Clang", "UWP" ], "environment": { "CXXFLAGS": "--target=arm64-pc-windows-msvc" } }, { "name": "arm64-Release-UWP-Clang", "description": "Clang/LLVM for AArch64 (Release) for UWP", "inherits": [ "base", "ARM64", "Release", "Clang", "UWP" ], "environment": { "CXXFLAGS": "--target=arm64-pc-windows-msvc" } }, - { "name": "x64-Debug-Win7-Clang" , "description": "Clang/LLVM for x64 (Debug) for Windows 7", "inherits": [ "base", "x64", "Debug", "Clang", "Win7" ] }, - { "name": "x64-Release-Win7-Clang" , "description": "Clang/LLVM for x64 (Release) for Windows 7", "inherits": [ "base", "x64", "Release", "Clang", "Win7" ] }, - { "name": "x86-Debug-Win7-Clang" , "description": "Clang/LLVM for x86 (Debug) for Windows 7", "inherits": [ "base", "x86", "Debug", "Clang", "Win7" ], "environment": { "CXXFLAGS": "-m32" } }, - { "name": "x86-Release-Win7-Clang" , "description": "Clang/LLVM for x86 (Release) for Windows 7", "inherits": [ "base", "x86", "Release", "Clang", "Win7" ], "environment": { "CXXFLAGS": "-m32" } } + { "name": "x64-Debug-Win7-Clang" , "description": "Clang/LLVM for x64 (Debug) for Windows 7", "inherits": [ "base", "x64", "Debug", "Clang", "Win7" ] }, + { "name": "x64-Release-Win7-Clang", "description": "Clang/LLVM for x64 (Release) for Windows 7", "inherits": [ "base", "x64", "Release", "Clang", "Win7" ] }, + { "name": "x86-Debug-Win7-Clang" , "description": "Clang/LLVM for x86 (Debug) for Windows 7", "inherits": [ "base", "x86", "Debug", "Clang", "Win7" ], "environment": { "CXXFLAGS": "-m32" } }, + { "name": "x86-Release-Win7-Clang", "description": "Clang/LLVM for x86 (Release) for Windows 7", "inherits": [ "base", "x86", "Release", "Clang", "Win7" ], "environment": { "CXXFLAGS": "-m32" } }, + + { "name": "x64-Debug-MinGW" , "description": "MinG-W64 (Debug)", "inherits": [ "base", "x64", "Debug", "GNUC", "VCPKG" ], "environment": { "PATH": "$penv{PATH};c:/mingw64/bin" } }, + { "name": "x64-Release-MinGW", "description": "MinG-W64 (Release)", "inherits": [ "base", "x64", "Release", "GNUC", "VCPKG" ], "environment": { "PATH": "$penv{PATH};c:/mingw64/bin" } }, + { "name": "x86-Debug-MinGW" , "description": "MinG-W32 (Debug)", "inherits": [ "base", "x86", "Debug", "GNUC", "VCPKG" ], "environment": { "PATH": "$penv{PATH};c:/mingw32/bin" } }, + { "name": "x86-Release-MinGW", "description": "MinG-W32 (Release)", "inherits": [ "base", "x86", "Release", "GNUC", "VCPKG" ], "environment": { "PATH": "$penv{PATH};c:/mingw32/bin" } } ] } \ No newline at end of file diff --git a/DDSTextureLoader/DDSTextureLoader11.cpp b/DDSTextureLoader/DDSTextureLoader11.cpp index 1cc1026..3bff94a 100644 --- a/DDSTextureLoader/DDSTextureLoader11.cpp +++ b/DDSTextureLoader/DDSTextureLoader11.cpp @@ -135,16 +135,18 @@ namespace inline HANDLE safe_handle(HANDLE h) noexcept { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; } + #if defined(_DEBUG) || defined(PROFILE) template inline void SetDebugObjectName(_In_ ID3D11DeviceChild* resource, _In_ const char(&name)[TNameLength]) noexcept { - #if defined(_DEBUG) || defined(PROFILE) resource->SetPrivateData(WKPDID_D3DDebugObjectName, TNameLength - 1, name); - #else - UNREFERENCED_PARAMETER(resource); - UNREFERENCED_PARAMETER(name); - #endif } + #else + template + inline void SetDebugObjectName(_In_ ID3D11DeviceChild*, _In_ const char(&)[TNameLength]) noexcept + { + } + #endif //-------------------------------------------------------------------------------------- HRESULT LoadTextureDataFromMemory( diff --git a/DDSTextureLoader/DDSTextureLoader12.cpp b/DDSTextureLoader/DDSTextureLoader12.cpp index f82fdf1..f7af781 100644 --- a/DDSTextureLoader/DDSTextureLoader12.cpp +++ b/DDSTextureLoader/DDSTextureLoader12.cpp @@ -21,7 +21,7 @@ #include #include -#ifndef WIN32 +#ifndef _WIN32 #include #include #endif @@ -47,10 +47,10 @@ #define D3DX12_NO_STATE_OBJECT_HELPERS #define D3DX12_NO_CHECK_FEATURE_SUPPORT_CLASS -#ifdef WIN32 -#include "d3dx12.h" -#else +#if !defined(_WIN32) || defined(USING_DIRECTX_HEADERS) #include "directx/d3dx12.h" +#else +#include "d3dx12.h" #endif using namespace DirectX; @@ -157,7 +157,7 @@ struct DDS_HEADER_DXT10 //-------------------------------------------------------------------------------------- namespace { -#ifdef WIN32 +#ifdef _WIN32 struct handle_closer { void operator()(HANDLE h) noexcept { if (h) CloseHandle(h); } }; using ScopedHandle = std::unique_ptr; @@ -165,16 +165,18 @@ namespace inline HANDLE safe_handle(HANDLE h) noexcept { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; } #endif + #if !defined(NO_D3D12_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) ) template inline void SetDebugObjectName(_In_ ID3D12DeviceChild* resource, _In_z_ const wchar_t(&name)[TNameLength]) noexcept { - #if !defined(NO_D3D12_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) ) resource->SetName(name); - #else - UNREFERENCED_PARAMETER(resource); - UNREFERENCED_PARAMETER(name); - #endif } + #else + template + inline void SetDebugObjectName(_In_ ID3D12DeviceChild*, _In_z_ const wchar_t(&)[TNameLength]) noexcept + { + } + #endif inline uint32_t CountMips(uint32_t width, uint32_t height) noexcept { @@ -274,7 +276,7 @@ namespace *bitSize = 0; - #ifdef WIN32 + #ifdef _WIN32 // open the file ScopedHandle hFile(safe_handle(CreateFile2(fileName, GENERIC_READ, diff --git a/DDSTextureLoader/DDSTextureLoader12.h b/DDSTextureLoader/DDSTextureLoader12.h index 4806277..d6c5dc9 100644 --- a/DDSTextureLoader/DDSTextureLoader12.h +++ b/DDSTextureLoader/DDSTextureLoader12.h @@ -16,13 +16,21 @@ #pragma once -#if defined(WIN32) || defined(_WIN32) -#include -#pragma comment(lib,"dxguid.lib") -#else +#ifdef __MINGW32__ +#include +#endif + +#ifndef _WIN32 #include #include +#endif + +#if !defined(_WIN32) || defined(USING_DIRECTX_HEADERS) #include +#include +#else +#include +#pragma comment(lib,"dxguid.lib") #endif #include diff --git a/DDSView/ddsview.cpp b/DDSView/ddsview.cpp index 49f5a45..7a1755b 100644 --- a/DDSView/ddsview.cpp +++ b/DDSView/ddsview.cpp @@ -448,12 +448,7 @@ HRESULT InitDevice(const TexMetadata& mdata) g_pImmediateContext->OMSetRenderTargets(1, &g_pRenderTargetView, g_pDepthStencilView); // Setup the viewport - D3D11_VIEWPORT vp = {}; - vp.TopLeftX = vp.TopLeftY = 0.f; - vp.Width = static_cast(width); - vp.Height = static_cast(height); - vp.MinDepth = D3D11_MIN_DEPTH; - vp.MaxDepth = D3D11_MAX_DEPTH; + const D3D11_VIEWPORT vp = { 0.f, 0.f, static_cast(width), static_cast(height), 0.f, 1.f }; g_pImmediateContext->RSSetViewports(1, &vp); // Create the vertex shader diff --git a/DirectXTex/DirectXTex.h b/DirectXTex/DirectXTex.h index d9205e7..5d8a160 100644 --- a/DirectXTex/DirectXTex.h +++ b/DirectXTex/DirectXTex.h @@ -17,7 +17,7 @@ #include #include -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 #if !defined(__d3d11_h__) && !defined(__d3d11_x_h__) && !defined(__d3d12_h__) && !defined(__d3d12_x_h__) && !defined(__XBOX_D3D12_X__) #ifdef _GAMING_XBOX_SCARLETT #include @@ -36,8 +36,8 @@ #include -#ifdef WIN32 -#ifdef NTDDI_WIN10_FE +#ifdef _WIN32 +#if defined(NTDDI_WIN10_FE) || defined(__MINGW32__) #include #else #include @@ -315,7 +315,7 @@ namespace DirectX _In_ TGA_FLAGS flags, _Out_ TexMetadata& metadata) noexcept; -#ifdef WIN32 +#ifdef _WIN32 HRESULT __cdecl GetMetadataFromWICMemory( _In_reads_bytes_(size) const void* pSource, _In_ size_t size, _In_ WIC_FLAGS flags, @@ -486,7 +486,7 @@ namespace DirectX _In_z_ const wchar_t* szFile, _In_opt_ const TexMetadata* metadata = nullptr) noexcept; // WIC operations -#ifdef WIN32 +#ifdef _WIN32 HRESULT __cdecl LoadFromWICMemory( _In_reads_bytes_(size) const void* pSource, _In_ size_t size, _In_ WIC_FLAGS flags, @@ -542,7 +542,7 @@ namespace DirectX TEX_FR_FLIP_VERTICAL = 0x10, }; -#ifdef WIN32 +#ifdef _WIN32 HRESULT __cdecl FlipRotate(_In_ const Image& srcImage, _In_ TEX_FR_FLAGS flags, _Out_ ScratchImage& image) noexcept; HRESULT __cdecl FlipRotate( _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, @@ -828,7 +828,7 @@ namespace DirectX //--------------------------------------------------------------------------------- // WIC utility code -#ifdef WIN32 +#ifdef _WIN32 enum WICCodecs { WIC_CODEC_BMP = 1, // Windows Bitmap (.bmp) diff --git a/DirectXTex/DirectXTexConvert.cpp b/DirectXTex/DirectXTexConvert.cpp index d39e6a1..4e1069f 100644 --- a/DirectXTex/DirectXTexConvert.cpp +++ b/DirectXTex/DirectXTexConvert.cpp @@ -4394,7 +4394,7 @@ namespace _Out_ WICPixelFormatGUID& pfGUID, _Out_ WICPixelFormatGUID& targetGUID) noexcept { - #ifndef WIN32 + #ifndef _WIN32 UNREFERENCED_PARAMETER(filter); UNREFERENCED_PARAMETER(sformat); UNREFERENCED_PARAMETER(tformat); @@ -4557,7 +4557,7 @@ namespace _In_ float threshold, _In_ const Image& destImage) { - #ifndef WIN32 + #ifndef _WIN32 UNREFERENCED_PARAMETER(srcImage); UNREFERENCED_PARAMETER(pfGUID); UNREFERENCED_PARAMETER(targetGUID); diff --git a/DirectXTex/DirectXTexD3D12.cpp b/DirectXTex/DirectXTexD3D12.cpp index 81a0eeb..9ebbee5 100644 --- a/DirectXTex/DirectXTexD3D12.cpp +++ b/DirectXTex/DirectXTexD3D12.cpp @@ -19,17 +19,15 @@ #define D3DX12_NO_STATE_OBJECT_HELPERS #define D3DX12_NO_CHECK_FEATURE_SUPPORT_CLASS -#ifdef WIN32 #ifdef _GAMING_XBOX_SCARLETT #include #elif (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX) #include "d3dx12_x.h" -#else -#include "d3dx12.h" -#endif -#else +#elif !defined(_WIN32) || defined(USING_DIRECTX_HEADERS) #include "directx/d3dx12.h" #include "dxguids/dxguids.h" +#else +#include "d3dx12.h" #endif #ifdef __clang__ @@ -304,7 +302,7 @@ namespace // Block until the copy is complete while (fence->GetCompletedValue() < 1) { - #ifdef WIN32 + #ifdef _WIN32 SwitchToThread(); #else std::this_thread::yield(); diff --git a/DirectXTex/DirectXTexDDS.cpp b/DirectXTex/DirectXTexDDS.cpp index e62ccd7..ca7fe7e 100644 --- a/DirectXTex/DirectXTexDDS.cpp +++ b/DirectXTex/DirectXTexDDS.cpp @@ -1583,7 +1583,7 @@ HRESULT DirectX::GetMetadataFromDDSFile( if (!szFile) return E_INVALIDARG; -#ifdef WIN32 +#ifdef _WIN32 #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); #else @@ -1637,7 +1637,7 @@ HRESULT DirectX::GetMetadataFromDDSFile( // Read the header in (including extended header if present) uint8_t header[MAX_HEADER_SIZE] = {}; -#ifdef WIN32 +#ifdef _WIN32 DWORD bytesRead = 0; if (!ReadFile(hFile.get(), header, MAX_HEADER_SIZE, &bytesRead, nullptr)) { @@ -1746,7 +1746,7 @@ HRESULT DirectX::LoadFromDDSFile( image.Release(); -#ifdef WIN32 +#ifdef _WIN32 #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); #else @@ -1798,7 +1798,7 @@ HRESULT DirectX::LoadFromDDSFile( // Read the header in (including extended header if present) uint8_t header[MAX_HEADER_SIZE] = {}; -#ifdef WIN32 +#ifdef _WIN32 DWORD bytesRead = 0; if (!ReadFile(hFile.get(), header, MAX_HEADER_SIZE, &bytesRead, nullptr)) { @@ -1824,7 +1824,7 @@ HRESULT DirectX::LoadFromDDSFile( if (!(convFlags & CONV_FLAGS_DX10)) { - #ifdef WIN32 + #ifdef _WIN32 // Must reset file position since we read more than the standard header above const LARGE_INTEGER filePos = { { sizeof(uint32_t) + sizeof(DDS_HEADER), 0 } }; if (!SetFilePointerEx(hFile.get(), filePos, nullptr, FILE_BEGIN)) @@ -1849,7 +1849,7 @@ HRESULT DirectX::LoadFromDDSFile( return E_OUTOFMEMORY; } - #ifdef WIN32 + #ifdef _WIN32 if (!ReadFile(hFile.get(), pal8.get(), 256 * sizeof(uint32_t), &bytesRead, nullptr)) { return HRESULT_FROM_WIN32(GetLastError()); @@ -1885,7 +1885,7 @@ HRESULT DirectX::LoadFromDDSFile( return E_OUTOFMEMORY; } - #ifdef WIN32 + #ifdef _WIN32 if (!ReadFile(hFile.get(), temp.get(), static_cast(remaining), &bytesRead, nullptr)) { image.Release(); @@ -1943,7 +1943,7 @@ HRESULT DirectX::LoadFromDDSFile( return HRESULT_E_ARITHMETIC_OVERFLOW; } - #ifdef WIN32 + #ifdef _WIN32 auto pixelBytes = static_cast(image.GetPixelsSize()); if (!ReadFile(hFile.get(), image.GetPixels(), pixelBytes, &bytesRead, nullptr)) { @@ -2230,7 +2230,7 @@ HRESULT DirectX::SaveToDDSFile( return hr; // Create file and write header -#ifdef WIN32 +#ifdef _WIN32 #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_WRITE | DELETE, 0, CREATE_ALWAYS, nullptr))); @@ -2292,7 +2292,7 @@ HRESULT DirectX::SaveToDDSFile( if ((images[index].slicePitch == ddsSlicePitch) && (ddsSlicePitch <= UINT32_MAX)) { - #ifdef WIN32 + #ifdef _WIN32 if (!WriteFile(hFile.get(), images[index].pixels, static_cast(ddsSlicePitch), &bytesWritten, nullptr)) { return HRESULT_FROM_WIN32(GetLastError()); @@ -2325,7 +2325,7 @@ HRESULT DirectX::SaveToDDSFile( const size_t lines = ComputeScanlines(metadata.format, images[index].height); for (size_t j = 0; j < lines; ++j) { - #ifdef WIN32 + #ifdef _WIN32 if (!WriteFile(hFile.get(), sPtr, static_cast(ddsRowPitch), &bytesWritten, nullptr)) { return HRESULT_FROM_WIN32(GetLastError()); @@ -2377,7 +2377,7 @@ HRESULT DirectX::SaveToDDSFile( if ((images[index].slicePitch == ddsSlicePitch) && (ddsSlicePitch <= UINT32_MAX)) { - #ifdef WIN32 + #ifdef _WIN32 if (!WriteFile(hFile.get(), images[index].pixels, static_cast(ddsSlicePitch), &bytesWritten, nullptr)) { return HRESULT_FROM_WIN32(GetLastError()); @@ -2410,7 +2410,7 @@ HRESULT DirectX::SaveToDDSFile( const size_t lines = ComputeScanlines(metadata.format, images[index].height); for (size_t j = 0; j < lines; ++j) { - #ifdef WIN32 + #ifdef _WIN32 if (!WriteFile(hFile.get(), sPtr, static_cast(ddsRowPitch), &bytesWritten, nullptr)) { return HRESULT_FROM_WIN32(GetLastError()); @@ -2440,7 +2440,7 @@ HRESULT DirectX::SaveToDDSFile( return E_FAIL; } -#ifdef WIN32 +#ifdef _WIN32 delonfail.clear(); #endif diff --git a/DirectXTex/DirectXTexHDR.cpp b/DirectXTex/DirectXTexHDR.cpp index c4a76a2..d0a41a7 100644 --- a/DirectXTex/DirectXTexHDR.cpp +++ b/DirectXTex/DirectXTexHDR.cpp @@ -34,7 +34,7 @@ using namespace DirectX; -#ifndef WIN32 +#ifndef _WIN32 #include #define strncpy_s strncpy @@ -77,7 +77,7 @@ namespace return 0; } -#ifndef WIN32 +#ifndef _WIN32 template inline int sprintf_s(char(&buffer)[sizeOfBuffer], const char* format, ...) { @@ -598,7 +598,7 @@ HRESULT DirectX::GetMetadataFromHDRFile(const wchar_t* szFile, TexMetadata& meta if (!szFile) return E_INVALIDARG; -#ifdef WIN32 +#ifdef _WIN32 #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); #else @@ -652,7 +652,7 @@ HRESULT DirectX::GetMetadataFromHDRFile(const wchar_t* szFile, TexMetadata& meta // Read the first part of the file to find the header uint8_t header[8192] = {}; -#ifdef WIN32 +#ifdef _WIN32 DWORD bytesRead = 0; if (!ReadFile(hFile.get(), header, std::min(sizeof(header), fileInfo.EndOfFile.LowPart), &bytesRead, nullptr)) { @@ -902,7 +902,7 @@ HRESULT DirectX::LoadFromHDRFile(const wchar_t* szFile, TexMetadata* metadata, S image.Release(); -#ifdef WIN32 +#ifdef _WIN32 #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); #else @@ -960,7 +960,7 @@ HRESULT DirectX::LoadFromHDRFile(const wchar_t* szFile, TexMetadata* metadata, S return E_OUTOFMEMORY; } -#ifdef WIN32 +#ifdef _WIN32 DWORD bytesRead = 0; if (!ReadFile(hFile.get(), temp.get(), fileInfo.EndOfFile.LowPart, &bytesRead, nullptr)) { @@ -1125,7 +1125,7 @@ HRESULT DirectX::SaveToHDRFile(const Image& image, const wchar_t* szFile) noexce } // Create file and write header -#ifdef WIN32 +#ifdef _WIN32 #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_WRITE, 0, CREATE_ALWAYS, nullptr))); @@ -1163,7 +1163,7 @@ HRESULT DirectX::SaveToHDRFile(const Image& image, const wchar_t* szFile) noexce return hr; // Write blob - #ifdef WIN32 + #ifdef _WIN32 auto const bytesToWrite = static_cast(blob.GetBufferSize()); DWORD bytesWritten; if (!WriteFile(hFile.get(), blob.GetBufferPointer(), bytesToWrite, &bytesWritten, nullptr)) @@ -1196,7 +1196,7 @@ HRESULT DirectX::SaveToHDRFile(const Image& image, const wchar_t* szFile) noexce char header[256] = {}; sprintf_s(header, g_Header, image.height, image.width); - #ifdef WIN32 + #ifdef _WIN32 auto const headerLen = static_cast(strlen(header)); DWORD bytesWritten; @@ -1221,7 +1221,7 @@ HRESULT DirectX::SaveToHDRFile(const Image& image, const wchar_t* szFile) noexce FloatToRGBE(rgbe, reinterpret_cast(sPtr), image.width, fpp); sPtr += image.rowPitch; - #ifdef WIN32 + #ifdef _WIN32 if (!WriteFile(hFile.get(), rgbe, static_cast(rowPitch), &bytesWritten, nullptr)) { return HRESULT_FROM_WIN32(GetLastError()); @@ -1258,7 +1258,7 @@ HRESULT DirectX::SaveToHDRFile(const Image& image, const wchar_t* szFile) noexce if (encSize > UINT32_MAX) return HRESULT_E_ARITHMETIC_OVERFLOW; - #ifdef WIN32 + #ifdef _WIN32 if (!WriteFile(hFile.get(), enc, static_cast(encSize), &bytesWritten, nullptr)) { return HRESULT_FROM_WIN32(GetLastError()); @@ -1274,7 +1274,7 @@ HRESULT DirectX::SaveToHDRFile(const Image& image, const wchar_t* szFile) noexce } else { - #ifdef WIN32 + #ifdef _WIN32 if (!WriteFile(hFile.get(), rgbe, static_cast(rowPitch), &bytesWritten, nullptr)) { return HRESULT_FROM_WIN32(GetLastError()); @@ -1292,7 +1292,7 @@ HRESULT DirectX::SaveToHDRFile(const Image& image, const wchar_t* szFile) noexce #endif } -#ifdef WIN32 +#ifdef _WIN32 delonfail.clear(); #endif diff --git a/DirectXTex/DirectXTexImage.cpp b/DirectXTex/DirectXTexImage.cpp index 497b282..4083a2c 100644 --- a/DirectXTex/DirectXTexImage.cpp +++ b/DirectXTex/DirectXTexImage.cpp @@ -14,7 +14,7 @@ using namespace DirectX; using namespace DirectX::Internal; -#ifndef WIN32 +#ifndef _WIN32 namespace { inline void * _aligned_malloc(size_t size, size_t alignment) diff --git a/DirectXTex/DirectXTexMipmaps.cpp b/DirectXTex/DirectXTexMipmaps.cpp index c1d9ce8..03c30c0 100644 --- a/DirectXTex/DirectXTexMipmaps.cpp +++ b/DirectXTex/DirectXTexMipmaps.cpp @@ -65,7 +65,7 @@ namespace return mipLevels; } -#ifdef WIN32 +#ifdef _WIN32 HRESULT EnsureWicBitmapPixelFormat( _In_ IWICImagingFactory* pWIC, _In_ IWICBitmap* src, @@ -399,7 +399,7 @@ bool DirectX::Internal::CalculateMipLevels3D( return true; } -#ifdef WIN32 +#ifdef _WIN32 //--- Resizing color and alpha channels separately using WIC --- _Use_decl_annotations_ HRESULT DirectX::Internal::ResizeSeparateColorAndAlpha( @@ -543,7 +543,7 @@ HRESULT DirectX::Internal::ResizeSeparateColorAndAlpha( if (SUCCEEDED(hr)) { - WICInProcPointer colorWithAlphaData = nullptr; + BYTE* colorWithAlphaData = nullptr; UINT colorWithAlphaSizeInBytes = 0; UINT colorWithAlphaStride = 0; @@ -560,7 +560,7 @@ HRESULT DirectX::Internal::ResizeSeparateColorAndAlpha( } } - WICInProcPointer colorData = nullptr; + BYTE* colorData = nullptr; UINT colorSizeInBytes = 0; UINT colorStride = 0; if (SUCCEEDED(hr)) @@ -620,7 +620,7 @@ HRESULT DirectX::Internal::ResizeSeparateColorAndAlpha( namespace { -#ifdef WIN32 +#ifdef _WIN32 //--- determine when to use WIC vs. non-WIC paths --- bool UseWICFiltering(_In_ DXGI_FORMAT format, _In_ TEX_FILTER_FLAGS filter) noexcept { @@ -2836,7 +2836,7 @@ HRESULT DirectX::GenerateMipMaps( static_assert(TEX_FILTER_POINT == 0x100000, "TEX_FILTER_ flag values don't match TEX_FILTER_MODE_MASK"); -#ifdef WIN32 +#ifdef _WIN32 bool usewic = UseWICFiltering(baseImage.format, filter); WICPixelFormatGUID pfGUID = {}; @@ -3051,7 +3051,7 @@ HRESULT DirectX::GenerateMipMaps( static_assert(TEX_FILTER_POINT == 0x100000, "TEX_FILTER_ flag values don't match TEX_FILTER_MODE_MASK"); -#ifdef WIN32 +#ifdef _WIN32 bool usewic = !metadata.IsPMAlpha() && UseWICFiltering(metadata.format, filter); WICPixelFormatGUID pfGUID = {}; diff --git a/DirectXTex/DirectXTexP.h b/DirectXTex/DirectXTexP.h index 146d8c7..7a55e0d 100644 --- a/DirectXTex/DirectXTexP.h +++ b/DirectXTex/DirectXTexP.h @@ -71,14 +71,14 @@ #pragma clang diagnostic ignored "-Wunknown-pragmas" #endif -#if defined(WIN32) || defined(_WIN32) +#ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #pragma warning(push) #pragma warning(disable : 4005) -#define NOMINMAX +#define NOMINMAX 1 #define NODRAWTEXT #define NOGDI #define NOBITMAP @@ -89,6 +89,10 @@ #include +#ifdef __MINGW32__ +#include +#endif + #ifndef _WIN32_WINNT_WIN10 #define _WIN32_WINNT_WIN10 0x0A00 #endif @@ -133,7 +137,7 @@ #include #include -#ifndef WIN32 +#ifndef _WIN32 #include #include #include @@ -151,8 +155,8 @@ #include -#ifdef WIN32 -#ifdef NTDDI_WIN10_FE +#ifdef _WIN32 +#if defined(NTDDI_WIN10_FE) || defined(__MINGW32__) #include #else #include @@ -181,6 +185,10 @@ using WICPixelFormatGUID = GUID; #define XBOX_DXGI_FORMAT_R4G4_UNORM DXGI_FORMAT(190) +#if defined(__MINGW32__) && !defined(E_BOUNDS) +#define E_BOUNDS static_cast(0x8000000BL) +#endif + // HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW) #define HRESULT_E_ARITHMETIC_OVERFLOW static_cast(0x80070216L) @@ -211,7 +219,7 @@ namespace DirectX { //----------------------------------------------------------------------------- // WIC helper functions - #ifdef WIN32 + #ifdef _WIN32 DXGI_FORMAT __cdecl WICToDXGI(_In_ const GUID& guid) noexcept; bool __cdecl DXGIToWIC(_In_ DXGI_FORMAT format, _Out_ GUID& guid, _In_ bool ignoreRGBvsBGR = false) noexcept; @@ -418,7 +426,7 @@ namespace DirectX bool __cdecl CalculateMipLevels3D(_In_ size_t width, _In_ size_t height, _In_ size_t depth, _Inout_ size_t& mipLevels) noexcept; - #ifdef WIN32 + #ifdef _WIN32 HRESULT __cdecl ResizeSeparateColorAndAlpha(_In_ IWICImagingFactory* pWIC, _In_ bool iswic2, _In_ IWICBitmap* original, diff --git a/DirectXTex/DirectXTexResize.cpp b/DirectXTex/DirectXTexResize.cpp index 0723a08..831235b 100644 --- a/DirectXTex/DirectXTexResize.cpp +++ b/DirectXTex/DirectXTexResize.cpp @@ -19,7 +19,7 @@ using Microsoft::WRL::ComPtr; namespace { -#ifdef WIN32 +#ifdef _WIN32 //--- Do image resize using WIC --- HRESULT PerformResizeUsingWIC( const Image& srcImage, @@ -876,7 +876,7 @@ HRESULT DirectX::Resize( return HRESULT_E_NOT_SUPPORTED; } -#ifdef WIN32 +#ifdef _WIN32 bool usewic = UseWICFiltering(srcImage.format, filter); WICPixelFormatGUID pfGUID = {}; @@ -905,7 +905,7 @@ HRESULT DirectX::Resize( if (!rimage) return E_POINTER; -#ifdef WIN32 +#ifdef _WIN32 if (usewic) { if (wicpf) @@ -963,7 +963,7 @@ HRESULT DirectX::Resize( if (FAILED(hr)) return hr; -#ifdef WIN32 +#ifdef _WIN32 bool usewic = !metadata.IsPMAlpha() && UseWICFiltering(metadata.format, filter); WICPixelFormatGUID pfGUID = {}; @@ -1019,7 +1019,7 @@ HRESULT DirectX::Resize( return E_FAIL; } - #ifdef WIN32 + #ifdef _WIN32 if (usewic) { if (wicpf) @@ -1080,7 +1080,7 @@ HRESULT DirectX::Resize( return E_FAIL; } - #ifdef WIN32 + #ifdef _WIN32 if (usewic) { if (wicpf) diff --git a/DirectXTex/DirectXTexTGA.cpp b/DirectXTex/DirectXTexTGA.cpp index 029d109..7926035 100644 --- a/DirectXTex/DirectXTexTGA.cpp +++ b/DirectXTex/DirectXTexTGA.cpp @@ -1224,7 +1224,7 @@ namespace time_t now = {}; time(&now); - #ifdef WIN32 + #ifdef _WIN32 tm info; auto pinfo = &info; if (!gmtime_s(pinfo, &now)) @@ -1343,7 +1343,7 @@ HRESULT DirectX::GetMetadataFromTGAFile(const wchar_t* szFile, TGA_FLAGS flags, if (!szFile) return E_INVALIDARG; -#ifdef WIN32 +#ifdef _WIN32 #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); #else @@ -1397,7 +1397,7 @@ HRESULT DirectX::GetMetadataFromTGAFile(const wchar_t* szFile, TGA_FLAGS flags, // Read the standard header (we don't need the file footer to parse the file) uint8_t header[sizeof(TGA_HEADER)] = {}; -#ifdef WIN32 +#ifdef _WIN32 DWORD bytesRead = 0; if (!ReadFile(hFile.get(), header, sizeof(TGA_HEADER), &bytesRead, nullptr)) { @@ -1424,7 +1424,7 @@ HRESULT DirectX::GetMetadataFromTGAFile(const wchar_t* szFile, TGA_FLAGS flags, { TGA_FOOTER footer = {}; - #ifdef WIN32 + #ifdef _WIN32 if (SetFilePointer(hFile.get(), -static_cast(sizeof(TGA_FOOTER)), nullptr, FILE_END) != INVALID_SET_FILE_POINTER) { if (!ReadFile(hFile.get(), &footer, sizeof(TGA_FOOTER), &bytesRead, nullptr)) @@ -1452,7 +1452,7 @@ HRESULT DirectX::GetMetadataFromTGAFile(const wchar_t* szFile, TGA_FLAGS flags, if (footer.dwExtensionOffset != 0 && ((footer.dwExtensionOffset + sizeof(TGA_EXTENSION)) <= len)) { - #ifdef WIN32 + #ifdef _WIN32 const LARGE_INTEGER filePos = { { static_cast(footer.dwExtensionOffset), 0 } }; if (SetFilePointerEx(hFile.get(), filePos, nullptr, FILE_BEGIN)) { @@ -1592,7 +1592,7 @@ HRESULT DirectX::LoadFromTGAFile( image.Release(); -#ifdef WIN32 +#ifdef _WIN32 #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); #else @@ -1646,7 +1646,7 @@ HRESULT DirectX::LoadFromTGAFile( // Read the header uint8_t header[sizeof(TGA_HEADER)] = {}; -#ifdef WIN32 +#ifdef _WIN32 DWORD bytesRead = 0; if (!ReadFile(hFile.get(), header, sizeof(TGA_HEADER), &bytesRead, nullptr)) { @@ -1676,7 +1676,7 @@ HRESULT DirectX::LoadFromTGAFile( if (offset > sizeof(TGA_HEADER)) { - #ifdef WIN32 + #ifdef _WIN32 // Skip past the id string const LARGE_INTEGER filePos = { { static_cast(offset), 0 } }; if (!SetFilePointerEx(hFile.get(), filePos, nullptr, FILE_BEGIN)) @@ -1713,7 +1713,7 @@ HRESULT DirectX::LoadFromTGAFile( return HRESULT_E_ARITHMETIC_OVERFLOW; } - #ifdef WIN32 + #ifdef _WIN32 if (!ReadFile(hFile.get(), image.GetPixels(), static_cast(image.GetPixelsSize()), &bytesRead, nullptr)) { image.Release(); @@ -1932,7 +1932,7 @@ HRESULT DirectX::LoadFromTGAFile( return E_OUTOFMEMORY; } - #ifdef WIN32 + #ifdef _WIN32 if (!ReadFile(hFile.get(), temp.get(), static_cast(remaining), &bytesRead, nullptr)) { image.Release(); @@ -1978,7 +1978,7 @@ HRESULT DirectX::LoadFromTGAFile( { TGA_FOOTER footer = {}; - #ifdef WIN32 + #ifdef _WIN32 if (SetFilePointer(hFile.get(), -static_cast(sizeof(TGA_FOOTER)), nullptr, FILE_END) != INVALID_SET_FILE_POINTER) { if (!ReadFile(hFile.get(), &footer, sizeof(TGA_FOOTER), &bytesRead, nullptr)) @@ -2011,7 +2011,7 @@ HRESULT DirectX::LoadFromTGAFile( if (footer.dwExtensionOffset != 0 && ((footer.dwExtensionOffset + sizeof(TGA_EXTENSION)) <= len)) { - #ifdef WIN32 + #ifdef _WIN32 const LARGE_INTEGER filePos = { { static_cast(footer.dwExtensionOffset), 0 } }; if (SetFilePointerEx(hFile.get(), filePos, nullptr, FILE_BEGIN)) { @@ -2174,7 +2174,7 @@ HRESULT DirectX::SaveToTGAFile( return hr; // Create file and write header -#ifdef WIN32 +#ifdef _WIN32 #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_WRITE, 0, CREATE_ALWAYS, nullptr))); @@ -2211,7 +2211,7 @@ HRESULT DirectX::SaveToTGAFile( return hr; // Write blob - #ifdef WIN32 + #ifdef _WIN32 const DWORD bytesToWrite = static_cast(blob.GetBufferSize()); DWORD bytesWritten; if (!WriteFile(hFile.get(), blob.GetBufferPointer(), bytesToWrite, &bytesWritten, nullptr)) @@ -2239,7 +2239,7 @@ HRESULT DirectX::SaveToTGAFile( return E_OUTOFMEMORY; // Write header - #ifdef WIN32 + #ifdef _WIN32 DWORD bytesWritten; if (!WriteFile(hFile.get(), &tga_header, sizeof(TGA_HEADER), &bytesWritten, nullptr)) { @@ -2278,7 +2278,7 @@ HRESULT DirectX::SaveToTGAFile( pPixels += image.rowPitch; - #ifdef WIN32 + #ifdef _WIN32 if (!WriteFile(hFile.get(), temp.get(), static_cast(rowPitch), &bytesWritten, nullptr)) { return HRESULT_FROM_WIN32(GetLastError()); @@ -2300,7 +2300,7 @@ HRESULT DirectX::SaveToTGAFile( TGA_EXTENSION ext = {}; SetExtension(&ext, flags, *metadata); - #ifdef WIN32 + #ifdef _WIN32 extOffset = SetFilePointer(hFile.get(), 0, nullptr, FILE_CURRENT); if (extOffset == INVALID_SET_FILE_POINTER) { @@ -2330,7 +2330,7 @@ HRESULT DirectX::SaveToTGAFile( footer.dwExtensionOffset = extOffset; memcpy(footer.Signature, g_Signature, sizeof(g_Signature)); - #ifdef WIN32 + #ifdef _WIN32 if (!WriteFile(hFile.get(), &footer, sizeof(TGA_FOOTER), &bytesWritten, nullptr)) { return HRESULT_FROM_WIN32(GetLastError()); @@ -2345,7 +2345,7 @@ HRESULT DirectX::SaveToTGAFile( #endif } -#ifdef WIN32 +#ifdef _WIN32 delonfail.clear(); #endif diff --git a/DirectXTex/DirectXTexUtil.cpp b/DirectXTex/DirectXTexUtil.cpp index a399851..02a00fd 100644 --- a/DirectXTex/DirectXTexUtil.cpp +++ b/DirectXTex/DirectXTexUtil.cpp @@ -32,7 +32,7 @@ using Microsoft::WRL::ComPtr; namespace { -#ifdef WIN32 +#ifdef _WIN32 //------------------------------------------------------------------------------------- // WIC Pixel Format Translation Data //------------------------------------------------------------------------------------- @@ -127,7 +127,7 @@ namespace } -#ifdef WIN32 +#ifdef _WIN32 //===================================================================================== // WIC Utilities //===================================================================================== diff --git a/DirectXTex/scoped.h b/DirectXTex/scoped.h index 1114e2c..363c393 100644 --- a/DirectXTex/scoped.h +++ b/DirectXTex/scoped.h @@ -15,7 +15,7 @@ #include #include -#ifndef WIN32 +#ifndef _WIN32 #include struct aligned_deleter { void operator()(void* p) noexcept { free(p); } }; diff --git a/ScreenGrab/ScreenGrab11.h b/ScreenGrab/ScreenGrab11.h index da1a300..0c44887 100644 --- a/ScreenGrab/ScreenGrab11.h +++ b/ScreenGrab/ScreenGrab11.h @@ -19,7 +19,7 @@ #include -#ifdef NTDDI_WIN10_FE +#if defined(NTDDI_WIN10_FE) || defined(__MINGW32__) #include #else #include diff --git a/ScreenGrab/ScreenGrab12.cpp b/ScreenGrab/ScreenGrab12.cpp index f68bc77..14ee491 100644 --- a/ScreenGrab/ScreenGrab12.cpp +++ b/ScreenGrab/ScreenGrab12.cpp @@ -31,7 +31,7 @@ #include #include -#ifdef WIN32 +#ifdef _WIN32 #include #include #else @@ -61,10 +61,10 @@ #define D3DX12_NO_STATE_OBJECT_HELPERS #define D3DX12_NO_CHECK_FEATURE_SUPPORT_CLASS -#ifdef WIN32 -#include "d3dx12.h" -#else +#if !defined(_WIN32) || defined(USING_DIRECTX_HEADERS) #include "directx/d3dx12.h" +#else +#include "d3dx12.h" #endif using Microsoft::WRL::ComPtr; @@ -230,7 +230,7 @@ namespace { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','1','0'), 0, 0, 0, 0, 0 }; //----------------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 struct handle_closer { void operator()(HANDLE h) noexcept { if (h) CloseHandle(h); } }; using ScopedHandle = std::unique_ptr; @@ -842,7 +842,7 @@ namespace // Block until the copy is complete while (fence->GetCompletedValue() < 1) { - #ifdef WIN32 + #ifdef _WIN32 SwitchToThread(); #else std::this_thread::yield(); @@ -852,7 +852,7 @@ namespace return S_OK; } -#ifdef WIN32 +#ifdef _WIN32 BOOL WINAPI InitializeWICFactory(PINIT_ONCE, PVOID, PVOID* ifactory) noexcept { return SUCCEEDED(CoCreateInstance( @@ -929,7 +929,7 @@ HRESULT DirectX::SaveDDSTextureToFile( return hr; // Create file -#ifdef WIN32 +#ifdef _WIN32 ScopedHandle hFile(safe_handle(CreateFile2(fileName, GENERIC_WRITE, 0, CREATE_ALWAYS, nullptr))); if (!hFile) return HRESULT_FROM_WIN32(GetLastError()); @@ -1070,7 +1070,7 @@ HRESULT DirectX::SaveDDSTextureToFile( pStaging->Unmap(0, &writeRange); // Write header & pixels -#ifdef WIN32 +#ifdef _WIN32 DWORD bytesWritten; if (!WriteFile(hFile.get(), fileHeader, static_cast(headerSize), &bytesWritten, nullptr)) return HRESULT_FROM_WIN32(GetLastError()); @@ -1101,7 +1101,7 @@ HRESULT DirectX::SaveDDSTextureToFile( } //-------------------------------------------------------------------------------------- -#ifdef WIN32 +#ifdef _WIN32 _Use_decl_annotations_ HRESULT DirectX::SaveWICTextureToFile( ID3D12CommandQueue* pCommandQ, diff --git a/ScreenGrab/ScreenGrab12.h b/ScreenGrab/ScreenGrab12.h index c57a052..c023481 100644 --- a/ScreenGrab/ScreenGrab12.h +++ b/ScreenGrab/ScreenGrab12.h @@ -17,20 +17,31 @@ #pragma once -#ifdef WIN32 -#include +#ifdef __MINGW32__ +#include +#endif -#ifdef NTDDI_WIN10_FE +#ifndef _WIN32 +#include +#include +#endif + +#if !defined(_WIN32) || defined(USING_DIRECTX_HEADERS) +#include +#include +#else +#include +#pragma comment(lib,"dxguid.lib") +#endif + +#ifdef _WIN32 +#if defined(NTDDI_WIN10_FE) || defined(__MINGW32__) #include #else #include #endif #include -#else -#include -#include -#include #endif @@ -43,7 +54,7 @@ namespace DirectX D3D12_RESOURCE_STATES beforeState = D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATES afterState = D3D12_RESOURCE_STATE_RENDER_TARGET) noexcept; -#ifdef WIN32 +#ifdef _WIN32 HRESULT __cdecl SaveWICTextureToFile( _In_ ID3D12CommandQueue* pCommandQ, _In_ ID3D12Resource* pSource, diff --git a/ScreenGrab/ScreenGrab9.h b/ScreenGrab/ScreenGrab9.h index 8a33654..f2f5563 100644 --- a/ScreenGrab/ScreenGrab9.h +++ b/ScreenGrab/ScreenGrab9.h @@ -23,7 +23,7 @@ #include -#ifdef NTDDI_WIN10_FE +#if defined(NTDDI_WIN10_FE) || defined(__MINGW32__) #include #else #include diff --git a/WICTextureLoader/WICTextureLoader11.cpp b/WICTextureLoader/WICTextureLoader11.cpp index 6b45bfd..ec81ec1 100644 --- a/WICTextureLoader/WICTextureLoader11.cpp +++ b/WICTextureLoader/WICTextureLoader11.cpp @@ -64,16 +64,18 @@ using Microsoft::WRL::ComPtr; namespace { //-------------------------------------------------------------------------------------- + #if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) ) template inline void SetDebugObjectName(_In_ ID3D11DeviceChild* resource, _In_ const char(&name)[TNameLength]) noexcept { - #if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) ) resource->SetPrivateData(WKPDID_D3DDebugObjectName, TNameLength - 1, name); - #else - UNREFERENCED_PARAMETER(resource); - UNREFERENCED_PARAMETER(name); - #endif } + #else + template + inline void SetDebugObjectName(_In_ ID3D11DeviceChild*, _In_ const char(&)[TNameLength]) noexcept + { + } + #endif //------------------------------------------------------------------------------------- // WIC Pixel Format Translation Data diff --git a/WICTextureLoader/WICTextureLoader12.cpp b/WICTextureLoader/WICTextureLoader12.cpp index a570f5e..42dec1a 100644 --- a/WICTextureLoader/WICTextureLoader12.cpp +++ b/WICTextureLoader/WICTextureLoader12.cpp @@ -57,7 +57,11 @@ #define D3DX12_NO_STATE_OBJECT_HELPERS #define D3DX12_NO_CHECK_FEATURE_SUPPORT_CLASS +#ifdef USING_DIRECTX_HEADERS +#include "directx/d3dx12.h" +#else #include "d3dx12.h" +#endif using namespace DirectX; using Microsoft::WRL::ComPtr; @@ -197,16 +201,18 @@ namespace } //--------------------------------------------------------------------------------- + #if !defined(NO_D3D12_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) ) template inline void SetDebugObjectName(_In_ ID3D12DeviceChild* resource, _In_z_ const wchar_t(&name)[TNameLength]) noexcept { - #if !defined(NO_D3D12_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) ) resource->SetName(name); - #else - UNREFERENCED_PARAMETER(resource); - UNREFERENCED_PARAMETER(name); - #endif } + #else + template + inline void SetDebugObjectName(_In_ ID3D12DeviceChild*, _In_z_ const wchar_t(&)[TNameLength]) noexcept + { + } + #endif inline uint32_t CountMips(uint32_t width, uint32_t height) noexcept { diff --git a/WICTextureLoader/WICTextureLoader12.h b/WICTextureLoader/WICTextureLoader12.h index 6960edd..54d8b8a 100644 --- a/WICTextureLoader/WICTextureLoader12.h +++ b/WICTextureLoader/WICTextureLoader12.h @@ -20,9 +20,22 @@ #pragma once -#include +#ifndef _WIN32 +#error This module only supports Windows +#endif +#ifdef __MINGW32__ +#include +#endif + +#ifdef USING_DIRECTX_HEADERS +#include +#include +#else +#include #pragma comment(lib,"dxguid.lib") +#endif + #pragma comment(lib,"windowscodecs.lib") #include