FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
DirectXTK/Inc/WICTextureLoader.h at main · microsoft/DirectXTK · GitHub
microsoft
/
DirectXTK
Public
Notifications
You must be signed in to change notification settings
Fork
537
Star
2.9k
Code
Issues
34
Pull requests
0
Actions
Projects
Wiki
Security and quality
2
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
DirectXTK
/
Inc
/
WICTextureLoader.h
Copy path
More file actions
More file actions
Latest commit
History
History
History
295 lines (274 loc) · 12.3 KB
Breadcrumbs
DirectXTK
/
Inc
/
WICTextureLoader.h
Copy path
File metadata and controls
295 lines (274 loc) · 12.3 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
//
--------------------------------------------------------------------------------------
//
File: WICTextureLoader.h
//
//
Function for loading a WIC image and creating a Direct3D runtime texture for it
//
(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.
//
Licensed under the MIT License.
//
//
http://go.microsoft.com/fwlink/?LinkId=248926
//
https://go.microsoft.com/fwlink/?LinkId=248929
//
--------------------------------------------------------------------------------------
#
pragma
once
#
if
defined(_XBOX_ONE) && defined(_TITLE)
#
include
<
d3d11_x.h
>
#
else
#
include
<
d3d11_1.h
>
#
endif
#
include
<
cstddef
>
#
include
<
cstdint
>
#
ifdef
_MSC_VER
#
pragma
comment(lib, "uuid.lib")
#
endif
#
ifndef
DIRECTX_TOOLKIT_API
#
ifdef
DIRECTX_TOOLKIT_EXPORT
#
ifdef
__GNUC__
#
define
DIRECTX_TOOLKIT_API
__attribute__
((dllexport))
#
else
#
define
DIRECTX_TOOLKIT_API
__declspec
(dllexport)
#endif
#
elif
defined(DIRECTX_TOOLKIT_IMPORT)
#
ifdef
__GNUC__
#
define
DIRECTX_TOOLKIT_API
__attribute__
((dllimport))
#
else
#
define
DIRECTX_TOOLKIT_API
__declspec
(dllimport)
#endif
#
else
#
define
DIRECTX_TOOLKIT_API
#
endif
#
endif
namespace
DirectX
{
inline
namespace
DX11
{
enum
WIC_LOADER_FLAGS
:
uint32_t
{
WIC_LOADER_DEFAULT
=
0
,
WIC_LOADER_FORCE_SRGB
=
0x1
,
WIC_LOADER_IGNORE_SRGB
=
0x2
,
WIC_LOADER_SRGB_DEFAULT
=
0x4
,
WIC_LOADER_FIT_POW2
=
0x20
,
WIC_LOADER_MAKE_SQUARE
=
0x40
,
WIC_LOADER_FORCE_RGBA32
=
0x80
,
};
}
//
Standard version
DIRECTX_TOOLKIT_API
HRESULT
__cdecl
CreateWICTextureFromMemory
(_In_ ID3D11Device* d3dDevice,
_In_reads_bytes_
(wicDataSize)
const
uint8_t* wicData,
_In_ size_t wicDataSize,
_Outptr_opt_ ID3D11Resource** texture,
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
_In_ size_t maxsize = 0)
noexcept
;
DIRECTX_TOOLKIT_API
HRESULT
__cdecl
CreateWICTextureFromFile
(_In_ ID3D11Device* d3dDevice,
_In_z_
const
wchar_t
* szFileName,
_Outptr_opt_ ID3D11Resource** texture,
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
_In_
size_t
maxsize =
0
)
noexcept
;
//
Standard version with optional auto-gen mipmap support
DIRECTX_TOOLKIT_API
HRESULT
__cdecl
CreateWICTextureFromMemory
(
#
if
defined(_XBOX_ONE) && defined(_TITLE)
_In_ ID3D11DeviceX* d3dDevice,
_In_opt_ ID3D11DeviceContextX* d3dContext,
#
else
_In_ ID3D11Device* d3dDevice,
_In_opt_ ID3D11DeviceContext* d3dContext,
#
endif
_In_reads_bytes_
(wicDataSize)
const
uint8_t* wicData,
_In_ size_t wicDataSize,
_Outptr_opt_ ID3D11Resource** texture,
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
_In_ size_t maxsize = 0)
noexcept
;
DIRECTX_TOOLKIT_API
HRESULT
__cdecl
CreateWICTextureFromFile
(
#
if
defined(_XBOX_ONE) && defined(_TITLE)
_In_ ID3D11DeviceX* d3dDevice,
_In_opt_ ID3D11DeviceContextX* d3dContext,
#
else
_In_ ID3D11Device* d3dDevice,
_In_opt_ ID3D11DeviceContext* d3dContext,
#
endif
_In_z_
const
wchar_t
* szFileName,
_Outptr_opt_ ID3D11Resource** texture,
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
_In_
size_t
maxsize =
0
)
noexcept
;
//
Extended version
DIRECTX_TOOLKIT_API
HRESULT
__cdecl
CreateWICTextureFromMemoryEx
(_In_ ID3D11Device* d3dDevice,
_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,
_In_ WIC_LOADER_FLAGS loadFlags,
_Outptr_opt_ ID3D11Resource** texture,
_Outptr_opt_ ID3D11ShaderResourceView** textureView)
noexcept
;
DIRECTX_TOOLKIT_API
HRESULT
__cdecl
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,
_In_
WIC_LOADER_FLAGS
loadFlags,
_Outptr_opt_ ID3D11Resource** texture,
_Outptr_opt_ ID3D11ShaderResourceView** textureView)
noexcept
;
//
Extended version with optional auto-gen mipmap support
DIRECTX_TOOLKIT_API
HRESULT
__cdecl
CreateWICTextureFromMemoryEx
(
#
if
defined(_XBOX_ONE) && defined(_TITLE)
_In_ ID3D11DeviceX* d3dDevice,
_In_opt_ ID3D11DeviceContextX* d3dContext,
#
else
_In_ ID3D11Device* d3dDevice,
_In_opt_ ID3D11DeviceContext* d3dContext,
#
endif
_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,
_In_ WIC_LOADER_FLAGS loadFlags,
_Outptr_opt_ ID3D11Resource** texture,
_Outptr_opt_ ID3D11ShaderResourceView** textureView)
noexcept
;
DIRECTX_TOOLKIT_API
HRESULT
__cdecl
CreateWICTextureFromFileEx
(
#
if
defined(_XBOX_ONE) && defined(_TITLE)
_In_ ID3D11DeviceX* d3dDevice,
_In_opt_ ID3D11DeviceContextX* d3dContext,
#
else
_In_ ID3D11Device* d3dDevice,
_In_opt_ ID3D11DeviceContext* d3dContext,
#
endif
_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,
_In_
WIC_LOADER_FLAGS
loadFlags,
_Outptr_opt_ ID3D11Resource** texture,
_Outptr_opt_ ID3D11ShaderResourceView** textureView)
noexcept
;
#
ifdef
__cpp_lib_byte
DIRECTX_TOOLKIT_API
inline
HRESULT
__cdecl
CreateWICTextureFromMemory
(_In_ ID3D11Device* d3dDevice,
_In_reads_bytes_
(wicDataSize)
const
std::byte* wicData,
_In_ size_t wicDataSize,
_Outptr_opt_ ID3D11Resource** texture,
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
_In_ size_t maxsize = 0)
noexcept
{
return
CreateWICTextureFromMemory
(d3dDevice,
reinterpret_cast
<
const
uint8_t
*>(wicData), wicDataSize, texture, textureView, maxsize);
}
DIRECTX_TOOLKIT_API
inline
HRESULT
__cdecl
CreateWICTextureFromMemory
(
#
if
defined(_XBOX_ONE) && defined(_TITLE)
_In_ ID3D11DeviceX* d3dDevice,
_In_opt_ ID3D11DeviceContextX* d3dContext,
#
else
_In_ ID3D11Device* d3dDevice,
_In_opt_ ID3D11DeviceContext* d3dContext,
#
endif
_In_reads_bytes_
(wicDataSize)
const
std::byte* wicData,
_In_ size_t wicDataSize,
_Outptr_opt_ ID3D11Resource** texture,
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
_In_ size_t maxsize = 0)
noexcept
{
return
CreateWICTextureFromMemory
(d3dDevice,
d3dContext,
reinterpret_cast
<
const
uint8_t
*>(wicData),
wicDataSize,
texture,
textureView,
maxsize);
}
DIRECTX_TOOLKIT_API
inline
HRESULT
__cdecl
CreateWICTextureFromMemoryEx
(_In_ ID3D11Device* d3dDevice,
_In_reads_bytes_
(wicDataSize)
const
std::byte* 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,
_In_ WIC_LOADER_FLAGS loadFlags,
_Outptr_opt_ ID3D11Resource** texture,
_Outptr_opt_ ID3D11ShaderResourceView** textureView)
noexcept
{
return
CreateWICTextureFromMemoryEx
(d3dDevice,
reinterpret_cast
<
const
uint8_t
*>(wicData),
wicDataSize,
maxsize,
usage,
bindFlags,
cpuAccessFlags,
miscFlags,
loadFlags,
texture,
textureView);
}
DIRECTX_TOOLKIT_API
inline
HRESULT
__cdecl
CreateWICTextureFromMemoryEx
(
#
if
defined(_XBOX_ONE) && defined(_TITLE)
_In_ ID3D11DeviceX* d3dDevice,
_In_opt_ ID3D11DeviceContextX* d3dContext,
#
else
_In_ ID3D11Device* d3dDevice,
_In_opt_ ID3D11DeviceContext* d3dContext,
#
endif
_In_reads_bytes_
(wicDataSize)
const
std::byte* 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,
_In_ WIC_LOADER_FLAGS loadFlags,
_Outptr_opt_ ID3D11Resource** texture,
_Outptr_opt_ ID3D11ShaderResourceView** textureView)
noexcept
{
return
CreateWICTextureFromMemoryEx
(d3dDevice,
d3dContext,
reinterpret_cast
<
const
uint8_t
*>(wicData),
wicDataSize,
maxsize,
usage,
bindFlags,
cpuAccessFlags,
miscFlags,
loadFlags,
texture,
textureView);
}
#endif
//
__cpp_lib_byte
#
ifdef
__clang__
#
pragma
clang diagnostic push
#
pragma
clang diagnostic ignored "-Wdeprecated-dynamic-exception-spec"
#
endif
inline
namespace
DX11
{
DEFINE_ENUM_FLAG_OPERATORS
(
WIC_LOADER_FLAGS
)
}
#
ifdef
__clang__
#
pragma
clang diagnostic pop
#
endif
}
//
namespace DirectX
Back
|
FazBrowse Home
|
New Git URL