mirror of
https://github.com/microsoft/DirectXTex.git
synced 2026-02-08 13:56:13 +01:00
CMake support added for building with MinGW (#275)
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#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 <d3d12_xs.h>
|
||||
@@ -36,8 +36,8 @@
|
||||
|
||||
#include <DirectXMath.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef NTDDI_WIN10_FE
|
||||
#ifdef _WIN32
|
||||
#if defined(NTDDI_WIN10_FE) || defined(__MINGW32__)
|
||||
#include <ocidl.h>
|
||||
#else
|
||||
#include <OCIdl.h>
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -19,17 +19,15 @@
|
||||
|
||||
#define D3DX12_NO_STATE_OBJECT_HELPERS
|
||||
#define D3DX12_NO_CHECK_FEATURE_SUPPORT_CLASS
|
||||
#ifdef WIN32
|
||||
#ifdef _GAMING_XBOX_SCARLETT
|
||||
#include <d3dx12_xs.h>
|
||||
#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();
|
||||
|
||||
@@ -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<DWORD>(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<DWORD>(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<DWORD>(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<DWORD>(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<DWORD>(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<DWORD>(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
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
using namespace DirectX;
|
||||
|
||||
#ifndef WIN32
|
||||
#ifndef _WIN32
|
||||
#include <cstdarg>
|
||||
|
||||
#define strncpy_s strncpy
|
||||
@@ -77,7 +77,7 @@ namespace
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
#ifndef _WIN32
|
||||
template<size_t sizeOfBuffer>
|
||||
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<DWORD>(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<const DWORD>(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<DWORD>(strlen(header));
|
||||
|
||||
DWORD bytesWritten;
|
||||
@@ -1221,7 +1221,7 @@ HRESULT DirectX::SaveToHDRFile(const Image& image, const wchar_t* szFile) noexce
|
||||
FloatToRGBE(rgbe, reinterpret_cast<const float*>(sPtr), image.width, fpp);
|
||||
sPtr += image.rowPitch;
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
if (!WriteFile(hFile.get(), rgbe, static_cast<DWORD>(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<DWORD>(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<DWORD>(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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 = {};
|
||||
|
||||
@@ -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 <Windows.h>
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#include <unknwn.h>
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32_WINNT_WIN10
|
||||
#define _WIN32_WINNT_WIN10 0x0A00
|
||||
#endif
|
||||
@@ -133,7 +137,7 @@
|
||||
#include <new>
|
||||
#include <tuple>
|
||||
|
||||
#ifndef WIN32
|
||||
#ifndef _WIN32
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
#include <thread>
|
||||
@@ -151,8 +155,8 @@
|
||||
|
||||
#include <malloc.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef NTDDI_WIN10_FE
|
||||
#ifdef _WIN32
|
||||
#if defined(NTDDI_WIN10_FE) || defined(__MINGW32__)
|
||||
#include <ole2.h>
|
||||
#else
|
||||
#include <Ole2.h>
|
||||
@@ -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<HRESULT>(0x8000000BL)
|
||||
#endif
|
||||
|
||||
// HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW)
|
||||
#define HRESULT_E_ARITHMETIC_OVERFLOW static_cast<HRESULT>(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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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<int>(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<DWORD>(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<DWORD>(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<DWORD>(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<DWORD>(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<int>(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<DWORD>(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<DWORD>(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<DWORD>(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
|
||||
|
||||
|
||||
@@ -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
|
||||
//=====================================================================================
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include <memory>
|
||||
#include <tuple>
|
||||
|
||||
#ifndef WIN32
|
||||
#ifndef _WIN32
|
||||
#include <cstdlib>
|
||||
|
||||
struct aligned_deleter { void operator()(void* p) noexcept { free(p); } };
|
||||
|
||||
Reference in New Issue
Block a user