2016-08-22 18:26:36 +00:00
|
|
|
//--------------------------------------------------------------------------------------
|
|
|
|
// File: WICTextureLoader.h
|
|
|
|
//
|
2016-09-23 05:34:50 +00:00
|
|
|
// Function for loading a WIC image and creating a Direct3D runtime texture for it
|
2016-08-22 18:26:36 +00:00
|
|
|
// (auto-generating mipmaps if possible)
|
|
|
|
//
|
|
|
|
// Note: Assumes application has already called CoInitializeEx
|
|
|
|
//
|
|
|
|
// Warning: CreateWICTexture* functions are not thread-safe if given a d3dContext instance for
|
|
|
|
// auto-gen mipmap support.
|
|
|
|
//
|
|
|
|
// Note these functions are useful for images created as simple 2D textures. For
|
|
|
|
// more complex resources, DDSTextureLoader is an excellent light-weight runtime loader.
|
|
|
|
// For a full-featured DDS file reader, writer, and texture processing pipeline see
|
|
|
|
// the 'Texconv' sample and the 'DirectXTex' library.
|
|
|
|
//
|
|
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
2018-02-24 06:24:46 +00:00
|
|
|
// Licensed under the MIT License.
|
2016-08-22 18:26:36 +00:00
|
|
|
//
|
|
|
|
// http://go.microsoft.com/fwlink/?LinkId=248926
|
|
|
|
// http://go.microsoft.com/fwlink/?LinkId=248929
|
|
|
|
//--------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <d3d11_1.h>
|
|
|
|
|
2020-03-10 08:05:10 +00:00
|
|
|
#include <cstdint>
|
2016-08-22 18:26:36 +00:00
|
|
|
|
|
|
|
namespace DirectX
|
|
|
|
{
|
2019-12-11 20:04:52 +00:00
|
|
|
#ifndef WIC_LOADER_FLAGS_DEFINED
|
|
|
|
#define WIC_LOADER_FLAGS_DEFINED
|
2020-03-10 08:05:10 +00:00
|
|
|
enum WIC_LOADER_FLAGS : uint32_t
|
2016-09-23 05:34:50 +00:00
|
|
|
{
|
|
|
|
WIC_LOADER_DEFAULT = 0,
|
|
|
|
WIC_LOADER_FORCE_SRGB = 0x1,
|
|
|
|
WIC_LOADER_IGNORE_SRGB = 0x2,
|
2020-05-08 05:27:01 +00:00
|
|
|
WIC_LOADER_FORCE_RGBA32 = 0x10,
|
2016-09-23 05:34:50 +00:00
|
|
|
};
|
2019-12-11 20:04:52 +00:00
|
|
|
#endif
|
2016-09-23 05:34:50 +00:00
|
|
|
|
2016-08-22 18:26:36 +00:00
|
|
|
// Standard version
|
2016-09-09 02:09:46 +00:00
|
|
|
HRESULT CreateWICTextureFromMemory(
|
|
|
|
_In_ ID3D11Device* d3dDevice,
|
|
|
|
_In_reads_bytes_(wicDataSize) const uint8_t* wicData,
|
|
|
|
_In_ size_t wicDataSize,
|
2016-09-23 05:34:50 +00:00
|
|
|
_Outptr_opt_ ID3D11Resource** texture,
|
|
|
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
2020-03-10 08:05:10 +00:00
|
|
|
_In_ size_t maxsize = 0) noexcept;
|
2016-08-22 18:26:36 +00:00
|
|
|
|
2016-09-09 02:09:46 +00:00
|
|
|
HRESULT CreateWICTextureFromFile(
|
|
|
|
_In_ ID3D11Device* d3dDevice,
|
|
|
|
_In_z_ const wchar_t* szFileName,
|
2016-09-23 05:34:50 +00:00
|
|
|
_Outptr_opt_ ID3D11Resource** texture,
|
|
|
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
2020-03-10 08:05:10 +00:00
|
|
|
_In_ size_t maxsize = 0) noexcept;
|
2016-08-22 18:26:36 +00:00
|
|
|
|
|
|
|
// Standard version with optional auto-gen mipmap support
|
2016-09-09 02:09:46 +00:00
|
|
|
HRESULT CreateWICTextureFromMemory(
|
|
|
|
_In_ ID3D11Device* d3dDevice,
|
|
|
|
_In_opt_ ID3D11DeviceContext* d3dContext,
|
|
|
|
_In_reads_bytes_(wicDataSize) const uint8_t* wicData,
|
|
|
|
_In_ size_t wicDataSize,
|
2016-09-23 05:34:50 +00:00
|
|
|
_Outptr_opt_ ID3D11Resource** texture,
|
|
|
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
2020-03-10 08:05:10 +00:00
|
|
|
_In_ size_t maxsize = 0) noexcept;
|
2016-08-22 18:26:36 +00:00
|
|
|
|
2016-09-09 02:09:46 +00:00
|
|
|
HRESULT CreateWICTextureFromFile(
|
|
|
|
_In_ ID3D11Device* d3dDevice,
|
|
|
|
_In_opt_ ID3D11DeviceContext* d3dContext,
|
|
|
|
_In_z_ const wchar_t* szFileName,
|
2016-09-23 05:34:50 +00:00
|
|
|
_Outptr_opt_ ID3D11Resource** texture,
|
|
|
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
2020-03-10 08:05:10 +00:00
|
|
|
_In_ size_t maxsize = 0) noexcept;
|
2016-08-22 18:26:36 +00:00
|
|
|
|
|
|
|
// Extended version
|
2016-09-09 02:09:46 +00:00
|
|
|
HRESULT CreateWICTextureFromMemoryEx(
|
|
|
|
_In_ ID3D11Device* d3dDevice,
|
|
|
|
_In_reads_bytes_(wicDataSize) const uint8_t* wicData,
|
|
|
|
_In_ size_t wicDataSize,
|
|
|
|
_In_ size_t maxsize,
|
2016-09-23 05:34:50 +00:00
|
|
|
_In_ D3D11_USAGE usage,
|
2016-09-09 02:09:46 +00:00
|
|
|
_In_ unsigned int bindFlags,
|
|
|
|
_In_ unsigned int cpuAccessFlags,
|
|
|
|
_In_ unsigned int miscFlags,
|
2016-09-23 05:34:50 +00:00
|
|
|
_In_ unsigned int loadFlags,
|
|
|
|
_Outptr_opt_ ID3D11Resource** texture,
|
2020-03-10 08:05:10 +00:00
|
|
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView) noexcept;
|
2016-08-22 18:26:36 +00:00
|
|
|
|
2016-09-09 02:09:46 +00:00
|
|
|
HRESULT CreateWICTextureFromFileEx(
|
|
|
|
_In_ ID3D11Device* d3dDevice,
|
|
|
|
_In_z_ const wchar_t* szFileName,
|
|
|
|
_In_ size_t maxsize,
|
|
|
|
_In_ D3D11_USAGE usage,
|
|
|
|
_In_ unsigned int bindFlags,
|
|
|
|
_In_ unsigned int cpuAccessFlags,
|
|
|
|
_In_ unsigned int miscFlags,
|
2016-09-23 05:34:50 +00:00
|
|
|
_In_ unsigned int loadFlags,
|
|
|
|
_Outptr_opt_ ID3D11Resource** texture,
|
2020-03-10 08:05:10 +00:00
|
|
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView) noexcept;
|
2016-08-22 18:26:36 +00:00
|
|
|
|
|
|
|
// Extended version with optional auto-gen mipmap support
|
2016-09-09 02:09:46 +00:00
|
|
|
HRESULT CreateWICTextureFromMemoryEx(
|
|
|
|
_In_ ID3D11Device* d3dDevice,
|
|
|
|
_In_opt_ ID3D11DeviceContext* d3dContext,
|
|
|
|
_In_reads_bytes_(wicDataSize) const uint8_t* wicData,
|
|
|
|
_In_ size_t wicDataSize,
|
|
|
|
_In_ size_t maxsize,
|
|
|
|
_In_ D3D11_USAGE usage,
|
|
|
|
_In_ unsigned int bindFlags,
|
|
|
|
_In_ unsigned int cpuAccessFlags,
|
|
|
|
_In_ unsigned int miscFlags,
|
2016-09-23 05:34:50 +00:00
|
|
|
_In_ unsigned int loadFlags,
|
|
|
|
_Outptr_opt_ ID3D11Resource** texture,
|
2020-03-10 08:05:10 +00:00
|
|
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView) noexcept;
|
2016-08-22 18:26:36 +00:00
|
|
|
|
2016-09-09 02:09:46 +00:00
|
|
|
HRESULT CreateWICTextureFromFileEx(
|
|
|
|
_In_ ID3D11Device* d3dDevice,
|
|
|
|
_In_opt_ ID3D11DeviceContext* d3dContext,
|
|
|
|
_In_z_ const wchar_t* szFileName,
|
|
|
|
_In_ size_t maxsize,
|
|
|
|
_In_ D3D11_USAGE usage,
|
|
|
|
_In_ unsigned int bindFlags,
|
|
|
|
_In_ unsigned int cpuAccessFlags,
|
|
|
|
_In_ unsigned int miscFlags,
|
2016-09-23 05:34:50 +00:00
|
|
|
_In_ unsigned int loadFlags,
|
|
|
|
_Outptr_opt_ ID3D11Resource** texture,
|
2020-03-10 08:05:10 +00:00
|
|
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView) noexcept;
|
2019-08-01 00:05:23 +00:00
|
|
|
}
|