Some minor cleanup for DDSTextureLoader

This commit is contained in:
walbourn_cp 2013-06-20 21:19:42 -07:00
parent 8c508c9b58
commit 177351faa2

View File

@ -51,7 +51,7 @@ using namespace DirectX;
//--------------------------------------------------------------------------------------
#pragma pack(push,1)
#define DDS_MAGIC 0x20534444 // "DDS "
const uint32_t DDS_MAGIC = 0x20534444; // "DDS "
struct DDS_PIXELFORMAT
{
@ -93,7 +93,7 @@ enum DDS_MISC_FLAGS2
DDS_MISC_FLAGS2_ALPHA_MODE_MASK = 0x7L,
};
typedef struct
struct DDS_HEADER
{
uint32_t size;
uint32_t flags;
@ -109,28 +109,29 @@ typedef struct
uint32_t caps3;
uint32_t caps4;
uint32_t reserved2;
} DDS_HEADER;
};
typedef struct
struct DDS_HEADER_DXT10
{
DXGI_FORMAT dxgiFormat;
uint32_t resourceDimension;
uint32_t miscFlag; // see D3D11_RESOURCE_MISC_FLAG
uint32_t arraySize;
uint32_t miscFlags2;
} DDS_HEADER_DXT10;
};
#pragma pack(pop)
//---------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
namespace
{
struct handle_closer { void operator()(HANDLE h) { if (h) CloseHandle(h); } };
typedef public std::unique_ptr<void, handle_closer> ScopedHandle;
inline HANDLE safe_handle( HANDLE h ) { return (h == INVALID_HANDLE_VALUE) ? 0 : h; }
//--------------------------------------------------------------------------------------
template<UINT TNameLength>
inline void SetDebugObjectName(_In_ ID3D11DeviceChild* resource, _In_ const char (&name)[TNameLength])
{
@ -142,6 +143,8 @@ inline void SetDebugObjectName(_In_ ID3D11DeviceChild* resource, _In_ const char
#endif
}
};
//--------------------------------------------------------------------------------------
static HRESULT LoadTextureDataFromFile( _In_z_ const wchar_t* fileName,
std::unique_ptr<uint8_t[]>& ddsData,