mirror of
https://github.com/microsoft/DirectXTex.git
synced 2025-07-13 13:40:14 +02:00
texassemble/texconv: Code cleanup
This commit is contained in:
parent
dc76cc86eb
commit
2d27b1447e
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
using namespace DirectX;
|
using namespace DirectX;
|
||||||
|
|
||||||
enum OPTIONS // Note: dwOptions below assumes 32 or less options.
|
enum OPTIONS
|
||||||
{
|
{
|
||||||
OPT_CUBE = 1,
|
OPT_CUBE = 1,
|
||||||
OPT_VOLUME,
|
OPT_VOLUME,
|
||||||
@ -49,11 +49,11 @@ enum OPTIONS // Note: dwOptions below assumes 32 or less options.
|
|||||||
OPT_MAX
|
OPT_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert( OPT_MAX <= 32, "dwOptions is a DWORD bitfield" );
|
static_assert(OPT_MAX <= 32, "dwOptions is a DWORD bitfield");
|
||||||
|
|
||||||
struct SConversion
|
struct SConversion
|
||||||
{
|
{
|
||||||
wchar_t szSrc [MAX_PATH];
|
wchar_t szSrc[MAX_PATH];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SValue
|
struct SValue
|
||||||
@ -68,19 +68,19 @@ struct SValue
|
|||||||
|
|
||||||
SValue g_pOptions[] =
|
SValue g_pOptions[] =
|
||||||
{
|
{
|
||||||
{ L"cube", OPT_CUBE },
|
{ L"cube", OPT_CUBE },
|
||||||
{ L"volume", OPT_VOLUME },
|
{ L"volume", OPT_VOLUME },
|
||||||
{ L"array", OPT_ARRAY },
|
{ L"array", OPT_ARRAY },
|
||||||
{ L"cubearray", OPT_CUBEARRAY },
|
{ L"cubearray", OPT_CUBEARRAY },
|
||||||
{ L"w", OPT_WIDTH },
|
{ L"w", OPT_WIDTH },
|
||||||
{ L"h", OPT_HEIGHT },
|
{ L"h", OPT_HEIGHT },
|
||||||
{ L"f", OPT_FORMAT },
|
{ L"f", OPT_FORMAT },
|
||||||
{ L"if", OPT_FILTER },
|
{ L"if", OPT_FILTER },
|
||||||
{ L"o", OPT_OUTPUTFILE },
|
{ L"o", OPT_OUTPUTFILE },
|
||||||
{ L"dx10", OPT_USE_DX10 },
|
{ L"dx10", OPT_USE_DX10 },
|
||||||
{ L"nologo", OPT_NOLOGO },
|
{ L"nologo", OPT_NOLOGO },
|
||||||
{ L"sepalpha", OPT_SEPALPHA },
|
{ L"sepalpha", OPT_SEPALPHA },
|
||||||
{ nullptr, 0 }
|
{ nullptr, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DEFFMT(fmt) { L#fmt, DXGI_FORMAT_ ## fmt }
|
#define DEFFMT(fmt) { L#fmt, DXGI_FORMAT_ ## fmt }
|
||||||
@ -160,17 +160,17 @@ SValue g_pFilters[] =
|
|||||||
{ L"FANT", TEX_FILTER_FANT },
|
{ L"FANT", TEX_FILTER_FANT },
|
||||||
{ L"BOX", TEX_FILTER_BOX },
|
{ L"BOX", TEX_FILTER_BOX },
|
||||||
{ L"TRIANGLE", TEX_FILTER_TRIANGLE },
|
{ L"TRIANGLE", TEX_FILTER_TRIANGLE },
|
||||||
{ L"POINT_DITHER", TEX_FILTER_POINT | TEX_FILTER_DITHER },
|
{ L"POINT_DITHER", TEX_FILTER_POINT | TEX_FILTER_DITHER },
|
||||||
{ L"LINEAR_DITHER", TEX_FILTER_LINEAR | TEX_FILTER_DITHER },
|
{ L"LINEAR_DITHER", TEX_FILTER_LINEAR | TEX_FILTER_DITHER },
|
||||||
{ L"CUBIC_DITHER", TEX_FILTER_CUBIC | TEX_FILTER_DITHER },
|
{ L"CUBIC_DITHER", TEX_FILTER_CUBIC | TEX_FILTER_DITHER },
|
||||||
{ L"FANT_DITHER", TEX_FILTER_FANT | TEX_FILTER_DITHER },
|
{ L"FANT_DITHER", TEX_FILTER_FANT | TEX_FILTER_DITHER },
|
||||||
{ L"BOX_DITHER", TEX_FILTER_BOX | TEX_FILTER_DITHER },
|
{ L"BOX_DITHER", TEX_FILTER_BOX | TEX_FILTER_DITHER },
|
||||||
{ L"TRIANGLE_DITHER", TEX_FILTER_TRIANGLE | TEX_FILTER_DITHER },
|
{ L"TRIANGLE_DITHER", TEX_FILTER_TRIANGLE | TEX_FILTER_DITHER },
|
||||||
{ L"POINT_DITHER_DIFFUSION", TEX_FILTER_POINT | TEX_FILTER_DITHER_DIFFUSION },
|
{ L"POINT_DITHER_DIFFUSION", TEX_FILTER_POINT | TEX_FILTER_DITHER_DIFFUSION },
|
||||||
{ L"LINEAR_DITHER_DIFFUSION", TEX_FILTER_LINEAR | TEX_FILTER_DITHER_DIFFUSION },
|
{ L"LINEAR_DITHER_DIFFUSION", TEX_FILTER_LINEAR | TEX_FILTER_DITHER_DIFFUSION },
|
||||||
{ L"CUBIC_DITHER_DIFFUSION", TEX_FILTER_CUBIC | TEX_FILTER_DITHER_DIFFUSION },
|
{ L"CUBIC_DITHER_DIFFUSION", TEX_FILTER_CUBIC | TEX_FILTER_DITHER_DIFFUSION },
|
||||||
{ L"FANT_DITHER_DIFFUSION", TEX_FILTER_FANT | TEX_FILTER_DITHER_DIFFUSION },
|
{ L"FANT_DITHER_DIFFUSION", TEX_FILTER_FANT | TEX_FILTER_DITHER_DIFFUSION },
|
||||||
{ L"BOX_DITHER_DIFFUSION", TEX_FILTER_BOX | TEX_FILTER_DITHER_DIFFUSION },
|
{ L"BOX_DITHER_DIFFUSION", TEX_FILTER_BOX | TEX_FILTER_DITHER_DIFFUSION },
|
||||||
{ L"TRIANGLE_DITHER_DIFFUSION", TEX_FILTER_TRIANGLE | TEX_FILTER_DITHER_DIFFUSION },
|
{ L"TRIANGLE_DITHER_DIFFUSION", TEX_FILTER_TRIANGLE | TEX_FILTER_DITHER_DIFFUSION },
|
||||||
{ nullptr, TEX_FILTER_DEFAULT }
|
{ nullptr, TEX_FILTER_DEFAULT }
|
||||||
};
|
};
|
||||||
@ -179,143 +179,146 @@ SValue g_pFilters[] =
|
|||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
#pragma prefast(disable : 26018, "Only used with static internal arrays")
|
#pragma prefast(disable : 26018, "Only used with static internal arrays")
|
||||||
|
|
||||||
DWORD LookupByName(const wchar_t *pName, const SValue *pArray)
|
DWORD LookupByName(const wchar_t *pName, const SValue *pArray)
|
||||||
{
|
|
||||||
while(pArray->pName)
|
|
||||||
{
|
{
|
||||||
if(!_wcsicmp(pName, pArray->pName))
|
while (pArray->pName)
|
||||||
return pArray->dwValue;
|
|
||||||
|
|
||||||
pArray++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const wchar_t* LookupByValue(DWORD pValue, const SValue *pArray)
|
|
||||||
{
|
|
||||||
while(pArray->pName)
|
|
||||||
{
|
|
||||||
if(pValue == pArray->dwValue)
|
|
||||||
return pArray->pName;
|
|
||||||
|
|
||||||
pArray++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return L"";
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrintFormat(DXGI_FORMAT Format)
|
|
||||||
{
|
|
||||||
for(SValue *pFormat = g_pFormats; pFormat->pName; pFormat++)
|
|
||||||
{
|
|
||||||
if((DXGI_FORMAT) pFormat->dwValue == Format)
|
|
||||||
{
|
{
|
||||||
wprintf( pFormat->pName );
|
if (!_wcsicmp(pName, pArray->pName))
|
||||||
|
return pArray->dwValue;
|
||||||
|
|
||||||
|
pArray++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const wchar_t* LookupByValue(DWORD pValue, const SValue *pArray)
|
||||||
|
{
|
||||||
|
while (pArray->pName)
|
||||||
|
{
|
||||||
|
if (pValue == pArray->dwValue)
|
||||||
|
return pArray->pName;
|
||||||
|
|
||||||
|
pArray++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return L"";
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintFormat(DXGI_FORMAT Format)
|
||||||
|
{
|
||||||
|
for (SValue *pFormat = g_pFormats; pFormat->pName; pFormat++)
|
||||||
|
{
|
||||||
|
if ((DXGI_FORMAT)pFormat->dwValue == Format)
|
||||||
|
{
|
||||||
|
wprintf(pFormat->pName);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintInfo(const TexMetadata& info)
|
||||||
|
{
|
||||||
|
wprintf(L" (%Iux%Iu", info.width, info.height);
|
||||||
|
|
||||||
|
if (TEX_DIMENSION_TEXTURE3D == info.dimension)
|
||||||
|
wprintf(L"x%Iu", info.depth);
|
||||||
|
|
||||||
|
if (info.mipLevels > 1)
|
||||||
|
wprintf(L",%Iu", info.mipLevels);
|
||||||
|
|
||||||
|
if (info.arraySize > 1)
|
||||||
|
wprintf(L",%Iu", info.arraySize);
|
||||||
|
|
||||||
|
wprintf(L" ");
|
||||||
|
PrintFormat(info.format);
|
||||||
|
|
||||||
|
switch (info.dimension)
|
||||||
|
{
|
||||||
|
case TEX_DIMENSION_TEXTURE1D:
|
||||||
|
wprintf((info.arraySize > 1) ? L" 1DArray" : L" 1D");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TEX_DIMENSION_TEXTURE2D:
|
||||||
|
if (info.IsCubemap())
|
||||||
|
{
|
||||||
|
wprintf((info.arraySize > 6) ? L" CubeArray" : L" Cube");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wprintf((info.arraySize > 1) ? L" 2DArray" : L" 2D");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TEX_DIMENSION_TEXTURE3D:
|
||||||
|
wprintf(L" 3D");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wprintf(L")");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void PrintInfo( const TexMetadata& info )
|
|
||||||
{
|
|
||||||
wprintf( L" (%Iux%Iu", info.width, info.height);
|
|
||||||
|
|
||||||
if ( TEX_DIMENSION_TEXTURE3D == info.dimension )
|
void PrintList(size_t cch, SValue *pValue)
|
||||||
wprintf( L"x%Iu", info.depth);
|
|
||||||
|
|
||||||
if ( info.mipLevels > 1 )
|
|
||||||
wprintf( L",%Iu", info.mipLevels);
|
|
||||||
|
|
||||||
if ( info.arraySize > 1 )
|
|
||||||
wprintf( L",%Iu", info.arraySize);
|
|
||||||
|
|
||||||
wprintf( L" ");
|
|
||||||
PrintFormat( info.format );
|
|
||||||
|
|
||||||
switch ( info.dimension )
|
|
||||||
{
|
{
|
||||||
case TEX_DIMENSION_TEXTURE1D:
|
while (pValue->pName)
|
||||||
wprintf( (info.arraySize > 1) ? L" 1DArray" : L" 1D" );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TEX_DIMENSION_TEXTURE2D:
|
|
||||||
if ( info.IsCubemap() )
|
|
||||||
{
|
{
|
||||||
wprintf( (info.arraySize > 6) ? L" CubeArray" : L" Cube" );
|
size_t cchName = wcslen(pValue->pName);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wprintf( (info.arraySize > 1) ? L" 2DArray" : L" 2D" );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TEX_DIMENSION_TEXTURE3D:
|
if (cch + cchName + 2 >= 80)
|
||||||
wprintf( L" 3D");
|
{
|
||||||
break;
|
wprintf(L"\n ");
|
||||||
|
cch = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
wprintf(L"%ls ", pValue->pName);
|
||||||
|
cch += cchName + 2;
|
||||||
|
pValue++;
|
||||||
|
}
|
||||||
|
|
||||||
|
wprintf(L"\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
wprintf( L")");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
void PrintLogo()
|
||||||
void PrintList(size_t cch, SValue *pValue)
|
|
||||||
{
|
|
||||||
while(pValue->pName)
|
|
||||||
{
|
{
|
||||||
size_t cchName = wcslen(pValue->pName);
|
wprintf(L"Microsoft (R) DirectX Texture Assembler (DirectXTex version)\n");
|
||||||
|
wprintf(L"Copyright (C) Microsoft Corp. All rights reserved.\n");
|
||||||
if(cch + cchName + 2>= 80)
|
wprintf(L"\n");
|
||||||
{
|
|
||||||
wprintf( L"\n ");
|
|
||||||
cch = 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
wprintf( L"%ls ", pValue->pName );
|
|
||||||
cch += cchName + 2;
|
|
||||||
pValue++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wprintf( L"\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
void PrintUsage()
|
||||||
|
{
|
||||||
|
PrintLogo();
|
||||||
|
|
||||||
void PrintLogo()
|
wprintf(L"Usage: texassemble [-cube | - volume | -array | -cubearray] <options> <files>\n");
|
||||||
{
|
wprintf(L"\n");
|
||||||
wprintf( L"Microsoft (R) DirectX Texture Assembler (DirectXTex version)\n");
|
wprintf(L" -cube create cubemap\n");
|
||||||
wprintf( L"Copyright (C) Microsoft Corp. All rights reserved.\n");
|
wprintf(L" -volume create volume map\n");
|
||||||
wprintf( L"\n");
|
wprintf(L" -array create texture array\n");
|
||||||
}
|
wprintf(L" -cubearray create cubemap array\n");
|
||||||
|
wprintf(L" -w <n> width\n");
|
||||||
|
wprintf(L" -h <n> height\n");
|
||||||
|
wprintf(L" -f <format> format\n");
|
||||||
|
wprintf(L" -if <filter> image filtering\n");
|
||||||
|
wprintf(L" -o <filename> output filename\n");
|
||||||
|
wprintf(L" -sepalpha resize alpha channel separately from color channels\n");
|
||||||
|
wprintf(L" -dx10 Force use of 'DX10' extended header\n");
|
||||||
|
wprintf(L" -nologo suppress copyright message\n");
|
||||||
|
|
||||||
|
wprintf(L"\n");
|
||||||
|
wprintf(L" <format>: ");
|
||||||
|
PrintList(13, g_pFormats);
|
||||||
|
|
||||||
void PrintUsage()
|
wprintf(L"\n");
|
||||||
{
|
wprintf(L" <filter>: ");
|
||||||
PrintLogo();
|
PrintList(13, g_pFilters);
|
||||||
|
}
|
||||||
wprintf( L"Usage: texassemble [-cube | - volume | -array | -cubearray] <options> <files>\n");
|
|
||||||
wprintf( L"\n");
|
|
||||||
wprintf( L" -cube create cubemap\n");
|
|
||||||
wprintf( L" -volume create volume map\n");
|
|
||||||
wprintf( L" -array create texture array\n");
|
|
||||||
wprintf( L" -cubearray create cubemap array\n");
|
|
||||||
wprintf( L" -w <n> width\n");
|
|
||||||
wprintf( L" -h <n> height\n");
|
|
||||||
wprintf( L" -f <format> format\n");
|
|
||||||
wprintf( L" -if <filter> image filtering\n");
|
|
||||||
wprintf( L" -o <filename> output filename\n");
|
|
||||||
wprintf( L" -sepalpha resize alpha channel separately from color channels\n");
|
|
||||||
wprintf( L" -dx10 Force use of 'DX10' extended header\n");
|
|
||||||
wprintf( L" -nologo suppress copyright message\n");
|
|
||||||
|
|
||||||
wprintf( L"\n");
|
|
||||||
wprintf( L" <format>: ");
|
|
||||||
PrintList(13, g_pFormats);
|
|
||||||
|
|
||||||
wprintf( L"\n");
|
|
||||||
wprintf( L" <filter>: ");
|
|
||||||
PrintList(13, g_pFilters);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -338,9 +341,9 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
|||||||
|
|
||||||
// Initialize COM (needed for WIC)
|
// Initialize COM (needed for WIC)
|
||||||
HRESULT hr = hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
|
HRESULT hr = hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
|
||||||
if( FAILED(hr) )
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
wprintf( L"Failed to initialize COM (%08X)\n", hr);
|
wprintf(L"Failed to initialize COM (%08X)\n", hr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,23 +351,23 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
|||||||
DWORD dwOptions = 0;
|
DWORD dwOptions = 0;
|
||||||
std::list<SConversion> conversion;
|
std::list<SConversion> conversion;
|
||||||
|
|
||||||
for(int iArg = 1; iArg < argc; iArg++)
|
for (int iArg = 1; iArg < argc; iArg++)
|
||||||
{
|
{
|
||||||
PWSTR pArg = argv[iArg];
|
PWSTR pArg = argv[iArg];
|
||||||
|
|
||||||
if(('-' == pArg[0]) || ('/' == pArg[0]))
|
if (('-' == pArg[0]) || ('/' == pArg[0]))
|
||||||
{
|
{
|
||||||
pArg++;
|
pArg++;
|
||||||
PWSTR pValue;
|
PWSTR pValue;
|
||||||
|
|
||||||
for(pValue = pArg; *pValue && (':' != *pValue); pValue++);
|
for (pValue = pArg; *pValue && (':' != *pValue); pValue++);
|
||||||
|
|
||||||
if(*pValue)
|
if (*pValue)
|
||||||
*pValue++ = 0;
|
*pValue++ = 0;
|
||||||
|
|
||||||
DWORD dwOption = LookupByName(pArg, g_pOptions);
|
DWORD dwOption = LookupByName(pArg, g_pOptions);
|
||||||
|
|
||||||
if(!dwOption || (dwOptions & (1 << dwOption)))
|
if (!dwOption || (dwOptions & (1 << dwOption)))
|
||||||
{
|
{
|
||||||
PrintUsage();
|
PrintUsage();
|
||||||
return 1;
|
return 1;
|
||||||
@ -372,12 +375,17 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
|||||||
|
|
||||||
dwOptions |= 1 << dwOption;
|
dwOptions |= 1 << dwOption;
|
||||||
|
|
||||||
if( (OPT_NOLOGO != dwOption) && (OPT_SEPALPHA != dwOption) && (OPT_USE_DX10 != dwOption)
|
// Handle options with additional value parameter
|
||||||
&& (OPT_CUBE != dwOption) && (OPT_VOLUME != dwOption) && (OPT_ARRAY != dwOption) && (OPT_CUBEARRAY != dwOption) )
|
switch (dwOption)
|
||||||
{
|
{
|
||||||
if(!*pValue)
|
case OPT_WIDTH:
|
||||||
|
case OPT_HEIGHT:
|
||||||
|
case OPT_FORMAT:
|
||||||
|
case OPT_FILTER:
|
||||||
|
case OPT_OUTPUTFILE:
|
||||||
|
if (!*pValue)
|
||||||
{
|
{
|
||||||
if((iArg + 1 >= argc))
|
if ((iArg + 1 >= argc))
|
||||||
{
|
{
|
||||||
PrintUsage();
|
PrintUsage();
|
||||||
return 1;
|
return 1;
|
||||||
@ -388,12 +396,12 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(dwOption)
|
switch (dwOption)
|
||||||
{
|
{
|
||||||
case OPT_WIDTH:
|
case OPT_WIDTH:
|
||||||
if (swscanf_s(pValue, L"%Iu", &width) != 1)
|
if (swscanf_s(pValue, L"%Iu", &width) != 1)
|
||||||
{
|
{
|
||||||
wprintf( L"Invalid value specified with -w (%ls)\n", pValue);
|
wprintf(L"Invalid value specified with -w (%ls)\n", pValue);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -401,25 +409,25 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
|||||||
case OPT_HEIGHT:
|
case OPT_HEIGHT:
|
||||||
if (swscanf_s(pValue, L"%Iu", &height) != 1)
|
if (swscanf_s(pValue, L"%Iu", &height) != 1)
|
||||||
{
|
{
|
||||||
wprintf( L"Invalid value specified with -h (%ls)\n", pValue);
|
wprintf(L"Invalid value specified with -h (%ls)\n", pValue);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OPT_FORMAT:
|
case OPT_FORMAT:
|
||||||
format = (DXGI_FORMAT) LookupByName(pValue, g_pFormats);
|
format = (DXGI_FORMAT)LookupByName(pValue, g_pFormats);
|
||||||
if ( !format )
|
if (!format)
|
||||||
{
|
{
|
||||||
wprintf( L"Invalid value specified with -f (%ls)\n", pValue);
|
wprintf(L"Invalid value specified with -f (%ls)\n", pValue);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OPT_FILTER:
|
case OPT_FILTER:
|
||||||
dwFilter = LookupByName(pValue, g_pFilters);
|
dwFilter = LookupByName(pValue, g_pFilters);
|
||||||
if ( !dwFilter )
|
if (!dwFilter)
|
||||||
{
|
{
|
||||||
wprintf( L"Invalid value specified with -if (%ls)\n", pValue);
|
wprintf(L"Invalid value specified with -if (%ls)\n", pValue);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -442,13 +450,13 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(conversion.empty())
|
if (conversion.empty())
|
||||||
{
|
{
|
||||||
PrintUsage();
|
PrintUsage();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch( dwOptions & ( (1 << OPT_CUBE) | (1 << OPT_VOLUME) | (1 << OPT_ARRAY) | (1 << OPT_CUBEARRAY) ) )
|
switch (dwOptions & ((1 << OPT_CUBE) | (1 << OPT_VOLUME) | (1 << OPT_ARRAY) | (1 << OPT_CUBEARRAY)))
|
||||||
{
|
{
|
||||||
case (1 << OPT_VOLUME):
|
case (1 << OPT_VOLUME):
|
||||||
case (1 << OPT_ARRAY):
|
case (1 << OPT_ARRAY):
|
||||||
@ -457,11 +465,11 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
wprintf( L"Must use one of: -cube, -volume, -array, or -cubearray\n\n" );
|
wprintf(L"Must use one of: -cube, -volume, -array, or -cubearray\n\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(~dwOptions & (1 << OPT_NOLOGO))
|
if (~dwOptions & (1 << OPT_NOLOGO))
|
||||||
PrintLogo();
|
PrintLogo();
|
||||||
|
|
||||||
// Convert images
|
// Convert images
|
||||||
@ -469,113 +477,113 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
|||||||
|
|
||||||
std::vector<std::unique_ptr<ScratchImage>> loadedImages;
|
std::vector<std::unique_ptr<ScratchImage>> loadedImages;
|
||||||
|
|
||||||
for( auto pConv = conversion.begin(); pConv != conversion.end(); ++pConv )
|
for (auto pConv = conversion.begin(); pConv != conversion.end(); ++pConv)
|
||||||
{
|
{
|
||||||
wchar_t ext[_MAX_EXT];
|
wchar_t ext[_MAX_EXT];
|
||||||
wchar_t fname[_MAX_FNAME];
|
wchar_t fname[_MAX_FNAME];
|
||||||
_wsplitpath_s( pConv->szSrc, nullptr, 0, nullptr, 0, fname, _MAX_FNAME, ext, _MAX_EXT );
|
_wsplitpath_s(pConv->szSrc, nullptr, 0, nullptr, 0, fname, _MAX_FNAME, ext, _MAX_EXT);
|
||||||
|
|
||||||
// Load source image
|
// Load source image
|
||||||
if( pConv != conversion.begin() )
|
if (pConv != conversion.begin())
|
||||||
wprintf( L"\n");
|
wprintf(L"\n");
|
||||||
else if ( !*szOutputFile )
|
else if (!*szOutputFile)
|
||||||
{
|
{
|
||||||
if ( _wcsicmp( ext, L".dds" ) == 0 )
|
if (_wcsicmp(ext, L".dds") == 0)
|
||||||
{
|
{
|
||||||
wprintf( L"ERROR: Need to specify output file via -o\n");
|
wprintf(L"ERROR: Need to specify output file via -o\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_wmakepath_s( szOutputFile, nullptr, nullptr, fname, L".dds" );
|
_wmakepath_s(szOutputFile, nullptr, nullptr, fname, L".dds");
|
||||||
}
|
}
|
||||||
|
|
||||||
wprintf( L"reading %ls", pConv->szSrc );
|
wprintf(L"reading %ls", pConv->szSrc);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
TexMetadata info;
|
TexMetadata info;
|
||||||
std::unique_ptr<ScratchImage> image( new (std::nothrow) ScratchImage );
|
std::unique_ptr<ScratchImage> image(new (std::nothrow) ScratchImage);
|
||||||
if ( !image )
|
if (!image)
|
||||||
{
|
{
|
||||||
wprintf( L" ERROR: Memory allocation failed\n" );
|
wprintf(L"\nERROR: Memory allocation failed\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( _wcsicmp( ext, L".dds" ) == 0 )
|
if (_wcsicmp(ext, L".dds") == 0)
|
||||||
{
|
{
|
||||||
hr = LoadFromDDSFile( pConv->szSrc, DDS_FLAGS_NONE, &info, *image.get() );
|
hr = LoadFromDDSFile(pConv->szSrc, DDS_FLAGS_NONE, &info, *image.get());
|
||||||
if ( FAILED(hr) )
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
wprintf( L" FAILED (%x)\n", hr);
|
wprintf(L" FAILED (%x)\n", hr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( info.depth > 1
|
if (info.depth > 1
|
||||||
|| info.mipLevels > 1
|
|| info.mipLevels > 1
|
||||||
|| info.IsCubemap() )
|
|| info.IsCubemap())
|
||||||
{
|
{
|
||||||
wprintf( L" ERROR: Can't assemble complex surfaces\n" );
|
wprintf(L"\nERROR: Can't assemble complex surfaces\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( _wcsicmp( ext, L".tga" ) == 0 )
|
else if (_wcsicmp(ext, L".tga") == 0)
|
||||||
{
|
{
|
||||||
hr = LoadFromTGAFile( pConv->szSrc, &info, *image.get() );
|
hr = LoadFromTGAFile(pConv->szSrc, &info, *image.get());
|
||||||
if ( FAILED(hr) )
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
wprintf( L" FAILED (%x)\n", hr);
|
wprintf(L" FAILED (%x)\n", hr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( _wcsicmp( ext, L".hdr" ) == 0 )
|
else if (_wcsicmp(ext, L".hdr") == 0)
|
||||||
{
|
{
|
||||||
hr = LoadFromHDRFile( pConv->szSrc, &info, *image.get() );
|
hr = LoadFromHDRFile(pConv->szSrc, &info, *image.get());
|
||||||
if ( FAILED(hr) )
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
wprintf( L" FAILED (%x)\n", hr);
|
wprintf(L" FAILED (%x)\n", hr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// WIC shares the same filter values for mode and dither
|
// WIC shares the same filter values for mode and dither
|
||||||
static_assert( WIC_FLAGS_DITHER == TEX_FILTER_DITHER, "WIC_FLAGS_* & TEX_FILTER_* should match" );
|
static_assert(WIC_FLAGS_DITHER == TEX_FILTER_DITHER, "WIC_FLAGS_* & TEX_FILTER_* should match");
|
||||||
static_assert( WIC_FLAGS_DITHER_DIFFUSION == TEX_FILTER_DITHER_DIFFUSION, "WIC_FLAGS_* & TEX_FILTER_* should match" );
|
static_assert(WIC_FLAGS_DITHER_DIFFUSION == TEX_FILTER_DITHER_DIFFUSION, "WIC_FLAGS_* & TEX_FILTER_* should match");
|
||||||
static_assert( WIC_FLAGS_FILTER_POINT == TEX_FILTER_POINT, "WIC_FLAGS_* & TEX_FILTER_* should match" );
|
static_assert(WIC_FLAGS_FILTER_POINT == TEX_FILTER_POINT, "WIC_FLAGS_* & TEX_FILTER_* should match");
|
||||||
static_assert( WIC_FLAGS_FILTER_LINEAR == TEX_FILTER_LINEAR, "WIC_FLAGS_* & TEX_FILTER_* should match" );
|
static_assert(WIC_FLAGS_FILTER_LINEAR == TEX_FILTER_LINEAR, "WIC_FLAGS_* & TEX_FILTER_* should match");
|
||||||
static_assert( WIC_FLAGS_FILTER_CUBIC == TEX_FILTER_CUBIC, "WIC_FLAGS_* & TEX_FILTER_* should match" );
|
static_assert(WIC_FLAGS_FILTER_CUBIC == TEX_FILTER_CUBIC, "WIC_FLAGS_* & TEX_FILTER_* should match");
|
||||||
static_assert( WIC_FLAGS_FILTER_FANT == TEX_FILTER_FANT, "WIC_FLAGS_* & TEX_FILTER_* should match" );
|
static_assert(WIC_FLAGS_FILTER_FANT == TEX_FILTER_FANT, "WIC_FLAGS_* & TEX_FILTER_* should match");
|
||||||
|
|
||||||
hr = LoadFromWICFile( pConv->szSrc, dwFilter | WIC_FLAGS_ALL_FRAMES, &info, *image.get() );
|
hr = LoadFromWICFile(pConv->szSrc, dwFilter | WIC_FLAGS_ALL_FRAMES, &info, *image.get());
|
||||||
if ( FAILED(hr) )
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
wprintf( L" FAILED (%x)\n", hr);
|
wprintf(L" FAILED (%x)\n", hr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintInfo( info );
|
PrintInfo(info);
|
||||||
|
|
||||||
// Convert texture
|
// Convert texture
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
// --- Decompress --------------------------------------------------------------
|
// --- Decompress --------------------------------------------------------------
|
||||||
if ( IsCompressed( info.format ) )
|
if (IsCompressed(info.format))
|
||||||
{
|
{
|
||||||
const Image* img = image->GetImage(0,0,0);
|
const Image* img = image->GetImage(0, 0, 0);
|
||||||
assert( img );
|
assert(img);
|
||||||
size_t nimg = image->GetImageCount();
|
size_t nimg = image->GetImageCount();
|
||||||
|
|
||||||
std::unique_ptr<ScratchImage> timage( new (std::nothrow) ScratchImage );
|
std::unique_ptr<ScratchImage> timage(new (std::nothrow) ScratchImage);
|
||||||
if ( !timage )
|
if (!timage)
|
||||||
{
|
{
|
||||||
wprintf( L" ERROR: Memory allocation failed\n" );
|
wprintf(L"\nERROR: Memory allocation failed\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = Decompress( img, nimg, info, DXGI_FORMAT_UNKNOWN /* picks good default */, *timage.get() );
|
hr = Decompress(img, nimg, info, DXGI_FORMAT_UNKNOWN /* picks good default */, *timage.get());
|
||||||
if ( FAILED(hr) )
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
wprintf( L" FAILED [decompress] (%x)\n", hr);
|
wprintf(L" FAILED [decompress] (%x)\n", hr);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -583,122 +591,122 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
|||||||
|
|
||||||
info.format = tinfo.format;
|
info.format = tinfo.format;
|
||||||
|
|
||||||
assert( info.width == tinfo.width );
|
assert(info.width == tinfo.width);
|
||||||
assert( info.height == tinfo.height );
|
assert(info.height == tinfo.height);
|
||||||
assert( info.depth == tinfo.depth );
|
assert(info.depth == tinfo.depth);
|
||||||
assert( info.arraySize == tinfo.arraySize );
|
assert(info.arraySize == tinfo.arraySize);
|
||||||
assert( info.mipLevels == tinfo.mipLevels );
|
assert(info.mipLevels == tinfo.mipLevels);
|
||||||
assert( info.miscFlags == tinfo.miscFlags );
|
assert(info.miscFlags == tinfo.miscFlags);
|
||||||
assert( info.miscFlags2 == tinfo.miscFlags2 );
|
assert(info.miscFlags2 == tinfo.miscFlags2);
|
||||||
assert( info.dimension == tinfo.dimension );
|
assert(info.dimension == tinfo.dimension);
|
||||||
|
|
||||||
image.swap( timage );
|
image.swap(timage);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Resize ------------------------------------------------------------------
|
// --- Resize ------------------------------------------------------------------
|
||||||
if ( !width )
|
if (!width)
|
||||||
{
|
{
|
||||||
width = info.width;
|
width = info.width;
|
||||||
}
|
}
|
||||||
if ( !height )
|
if (!height)
|
||||||
{
|
{
|
||||||
height = info.height;
|
height = info.height;
|
||||||
}
|
}
|
||||||
if ( info.width != width || info.height != height )
|
if (info.width != width || info.height != height)
|
||||||
{
|
{
|
||||||
std::unique_ptr<ScratchImage> timage( new (std::nothrow) ScratchImage );
|
std::unique_ptr<ScratchImage> timage(new (std::nothrow) ScratchImage);
|
||||||
if ( !timage )
|
if (!timage)
|
||||||
{
|
{
|
||||||
wprintf( L" ERROR: Memory allocation failed\n" );
|
wprintf(L"\nERROR: Memory allocation failed\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = Resize( image->GetImages(), image->GetImageCount(), image->GetMetadata(), width, height, dwFilter | dwFilterOpts, *timage.get() );
|
hr = Resize(image->GetImages(), image->GetImageCount(), image->GetMetadata(), width, height, dwFilter | dwFilterOpts, *timage.get());
|
||||||
if ( FAILED(hr) )
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
wprintf( L" FAILED [resize] (%x)\n", hr);
|
wprintf(L" FAILED [resize] (%x)\n", hr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TexMetadata& tinfo = timage->GetMetadata();
|
const TexMetadata& tinfo = timage->GetMetadata();
|
||||||
|
|
||||||
assert( tinfo.width == width && tinfo.height == height && tinfo.mipLevels == 1 );
|
assert(tinfo.width == width && tinfo.height == height && tinfo.mipLevels == 1);
|
||||||
info.width = tinfo.width;
|
info.width = tinfo.width;
|
||||||
info.height = tinfo.height;
|
info.height = tinfo.height;
|
||||||
info.mipLevels = 1;
|
info.mipLevels = 1;
|
||||||
|
|
||||||
assert( info.depth == tinfo.depth );
|
assert(info.depth == tinfo.depth);
|
||||||
assert( info.arraySize == tinfo.arraySize );
|
assert(info.arraySize == tinfo.arraySize);
|
||||||
assert( info.miscFlags == tinfo.miscFlags );
|
assert(info.miscFlags == tinfo.miscFlags);
|
||||||
assert( info.miscFlags2 == tinfo.miscFlags2 );
|
assert(info.miscFlags2 == tinfo.miscFlags2);
|
||||||
assert( info.format == tinfo.format );
|
assert(info.format == tinfo.format);
|
||||||
assert( info.dimension == tinfo.dimension );
|
assert(info.dimension == tinfo.dimension);
|
||||||
|
|
||||||
image.swap( timage );
|
image.swap(timage);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Convert -----------------------------------------------------------------
|
// --- Convert -----------------------------------------------------------------
|
||||||
if ( format == DXGI_FORMAT_UNKNOWN )
|
if (format == DXGI_FORMAT_UNKNOWN)
|
||||||
{
|
{
|
||||||
format = info.format;
|
format = info.format;
|
||||||
}
|
}
|
||||||
else if ( info.format != format && !IsCompressed( format ) )
|
else if (info.format != format && !IsCompressed(format))
|
||||||
{
|
{
|
||||||
std::unique_ptr<ScratchImage> timage( new (std::nothrow) ScratchImage );
|
std::unique_ptr<ScratchImage> timage(new (std::nothrow) ScratchImage);
|
||||||
if ( !timage )
|
if (!timage)
|
||||||
{
|
{
|
||||||
wprintf( L" ERROR: Memory allocation failed\n" );
|
wprintf(L"\nERROR: Memory allocation failed\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = Convert( image->GetImages(), image->GetImageCount(), image->GetMetadata(), format, dwFilter | dwFilterOpts, 0.5f, *timage.get() );
|
hr = Convert(image->GetImages(), image->GetImageCount(), image->GetMetadata(), format, dwFilter | dwFilterOpts, 0.5f, *timage.get());
|
||||||
if ( FAILED(hr) )
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
wprintf( L" FAILED [convert] (%x)\n", hr);
|
wprintf(L" FAILED [convert] (%x)\n", hr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TexMetadata& tinfo = timage->GetMetadata();
|
const TexMetadata& tinfo = timage->GetMetadata();
|
||||||
|
|
||||||
assert( tinfo.format == format );
|
assert(tinfo.format == format);
|
||||||
info.format = tinfo.format;
|
info.format = tinfo.format;
|
||||||
|
|
||||||
assert( info.width == tinfo.width );
|
assert(info.width == tinfo.width);
|
||||||
assert( info.height == tinfo.height );
|
assert(info.height == tinfo.height);
|
||||||
assert( info.depth == tinfo.depth );
|
assert(info.depth == tinfo.depth);
|
||||||
assert( info.arraySize == tinfo.arraySize );
|
assert(info.arraySize == tinfo.arraySize);
|
||||||
assert( info.mipLevels == tinfo.mipLevels );
|
assert(info.mipLevels == tinfo.mipLevels);
|
||||||
assert( info.miscFlags == tinfo.miscFlags );
|
assert(info.miscFlags == tinfo.miscFlags);
|
||||||
assert( info.miscFlags2 == tinfo.miscFlags2 );
|
assert(info.miscFlags2 == tinfo.miscFlags2);
|
||||||
assert( info.dimension == tinfo.dimension );
|
assert(info.dimension == tinfo.dimension);
|
||||||
|
|
||||||
image.swap( timage );
|
image.swap(timage);
|
||||||
}
|
}
|
||||||
|
|
||||||
images += info.arraySize;
|
images += info.arraySize;
|
||||||
loadedImages.push_back( std::move( image ) );
|
loadedImages.push_back(std::move(image));
|
||||||
}
|
}
|
||||||
|
|
||||||
if( images < 2 )
|
if (images < 2)
|
||||||
{
|
{
|
||||||
wprintf( L" ERROR: Need at least 2 images to assemble\n\n");
|
wprintf(L"\nERROR: Need at least 2 images to assemble\n\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch( dwOptions & ( (1 << OPT_CUBE) | (1 << OPT_VOLUME) | (1 << OPT_ARRAY) | (1 << OPT_CUBEARRAY) ) )
|
switch (dwOptions & ((1 << OPT_CUBE) | (1 << OPT_VOLUME) | (1 << OPT_ARRAY) | (1 << OPT_CUBEARRAY)))
|
||||||
{
|
{
|
||||||
case (1 << OPT_CUBE):
|
case (1 << OPT_CUBE):
|
||||||
if ( images != 6 )
|
if (images != 6)
|
||||||
{
|
{
|
||||||
wprintf( L" ERROR: -cube requires six images to form the faces of the cubemap\n");
|
wprintf(L"\nERROR: -cube requires six images to form the faces of the cubemap\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case (1 << OPT_CUBEARRAY):
|
case (1 << OPT_CUBEARRAY):
|
||||||
if ( ( images < 6) || ( images % 6 ) != 0 )
|
if ((images < 6) || (images % 6) != 0)
|
||||||
{
|
{
|
||||||
wprintf( L"-cubearray requires a multiple of 6 images to form the faces of the cubemaps\n");
|
wprintf(L"-cubearray requires a multiple of 6 images to form the faces of the cubemaps\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -707,58 +715,58 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
|
|||||||
// --- Create result ---------------------------------------------------------------
|
// --- Create result ---------------------------------------------------------------
|
||||||
{
|
{
|
||||||
std::vector<Image> imageArray;
|
std::vector<Image> imageArray;
|
||||||
imageArray.reserve( images );
|
imageArray.reserve(images);
|
||||||
|
|
||||||
for( auto it = loadedImages.cbegin(); it != loadedImages.cend(); ++it )
|
for (auto it = loadedImages.cbegin(); it != loadedImages.cend(); ++it)
|
||||||
{
|
{
|
||||||
const ScratchImage* simage = it->get();
|
const ScratchImage* simage = it->get();
|
||||||
assert( simage != 0 );
|
assert(simage != 0);
|
||||||
for( size_t j = 0; j < simage->GetMetadata().arraySize; ++j )
|
for (size_t j = 0; j < simage->GetMetadata().arraySize; ++j)
|
||||||
{
|
{
|
||||||
const Image* img = simage->GetImage(0,j,0);
|
const Image* img = simage->GetImage(0, j, 0);
|
||||||
assert( img != 0 );
|
assert(img != 0);
|
||||||
imageArray.push_back( *img );
|
imageArray.push_back(*img);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ScratchImage result;
|
ScratchImage result;
|
||||||
switch( dwOptions & ( (1 << OPT_CUBE) | (1 << OPT_VOLUME) | (1 << OPT_ARRAY) | (1 << OPT_CUBEARRAY) ) )
|
switch (dwOptions & ((1 << OPT_CUBE) | (1 << OPT_VOLUME) | (1 << OPT_ARRAY) | (1 << OPT_CUBEARRAY)))
|
||||||
{
|
{
|
||||||
case (1 << OPT_VOLUME):
|
case (1 << OPT_VOLUME):
|
||||||
hr = result.Initialize3DFromImages( &imageArray[0], imageArray.size() );
|
hr = result.Initialize3DFromImages(&imageArray[0], imageArray.size());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case (1 << OPT_ARRAY):
|
case (1 << OPT_ARRAY):
|
||||||
hr = result.InitializeArrayFromImages( &imageArray[0], imageArray.size(), (dwOptions & (1 << OPT_USE_DX10)) != 0 );
|
hr = result.InitializeArrayFromImages(&imageArray[0], imageArray.size(), (dwOptions & (1 << OPT_USE_DX10)) != 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case (1 << OPT_CUBE):
|
case (1 << OPT_CUBE):
|
||||||
case (1 << OPT_CUBEARRAY):
|
case (1 << OPT_CUBEARRAY):
|
||||||
hr = result.InitializeCubeFromImages( &imageArray[0], imageArray.size() );
|
hr = result.InitializeCubeFromImages(&imageArray[0], imageArray.size());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( FAILED(hr ) )
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
wprintf( L"FAILED building result image (%x)\n", hr);
|
wprintf(L"FAILED building result image (%x)\n", hr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write texture
|
// Write texture
|
||||||
wprintf( L"\nWriting %ls ", szOutputFile);
|
wprintf(L"\nWriting %ls ", szOutputFile);
|
||||||
PrintInfo( result.GetMetadata() );
|
PrintInfo(result.GetMetadata());
|
||||||
wprintf( L"\n" );
|
wprintf(L"\n");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
hr = SaveToDDSFile( result.GetImages(), result.GetImageCount(), result.GetMetadata(),
|
hr = SaveToDDSFile(result.GetImages(), result.GetImageCount(), result.GetMetadata(),
|
||||||
(dwOptions & (1 << OPT_USE_DX10) ) ? (DDS_FLAGS_FORCE_DX10_EXT|DDS_FLAGS_FORCE_DX10_EXT_MISC2) : DDS_FLAGS_NONE,
|
(dwOptions & (1 << OPT_USE_DX10)) ? (DDS_FLAGS_FORCE_DX10_EXT | DDS_FLAGS_FORCE_DX10_EXT_MISC2) : DDS_FLAGS_NONE,
|
||||||
szOutputFile );
|
szOutputFile);
|
||||||
if(FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
wprintf( L"\nFAILED (%x)\n", hr);
|
wprintf(L"\nFAILED (%x)\n", hr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
wprintf( L"\n");
|
wprintf(L"\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
1752
Texconv/texconv.cpp
1752
Texconv/texconv.cpp
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user