Added a utility application to generate c headers from dds textures.

Change-Id: Idb4c2ca318c84433f2b06bd4f0c66045f43e56de
Reviewed-on: https://chromium-review.googlesource.com/182191
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Tested-by: Geoff Lang <geofflang@chromium.org>
This commit is contained in:
Geoff Lang 2014-01-10 15:52:18 -05:00
Родитель 2c254d8f0e
Коммит a50232fd52
8 изменённых файлов: 399 добавлений и 1 удалений

5
.gitignore поставляемый
Просмотреть файл

@ -4,16 +4,19 @@ Debug_x64
Release
Release_Win32
Release_x64
*.sln
*.sdf
*.ncb
*.suo
src/*.sln
src/*.vcxproj
src/*.vcxproj.filters
samples/*.sln
samples/*.vcxproj
samples/*.vcxproj.filters
tests/*.sln
tests/*.vcxproj
tests/*.vcxproj.filters
build/*.sln
build/*.vcxproj
build/*.vcxproj.filters
*.vcxproj.user

Просмотреть файл

@ -145,6 +145,10 @@
<Project>{B4D06330-EED1-6F99-BCA4-2F913908C38A}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\samples\dds_to_header.vcxproj">
<Project>{6BC75FF2-C11A-C393-F9BB-BF29FF29D736}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\samples\es_util.vcxproj">
<Project>{80E5C3D9-93C2-943E-176F-C9A903E27BC9}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>

Просмотреть файл

@ -11,6 +11,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "All", "All.vcxproj", "{D048
{FBAEE4F6-562A-588F-01F9-72DCABB3B061} = {FBAEE4F6-562A-588F-01F9-72DCABB3B061}
{293E74D1-544C-D368-02A0-52F61A4D0679} = {293E74D1-544C-D368-02A0-52F61A4D0679}
{B4D06330-EED1-6F99-BCA4-2F913908C38A} = {B4D06330-EED1-6F99-BCA4-2F913908C38A}
{6BC75FF2-C11A-C393-F9BB-BF29FF29D736} = {6BC75FF2-C11A-C393-F9BB-BF29FF29D736}
{80E5C3D9-93C2-943E-176F-C9A903E27BC9} = {80E5C3D9-93C2-943E-176F-C9A903E27BC9}
{3F4D97A9-0809-E0E4-5A3F-B6ACB6EABB46} = {3F4D97A9-0809-E0E4-5A3F-B6ACB6EABB46}
{A6E86EB3-561F-9FAB-670F-EF23556344BE} = {A6E86EB3-561F-9FAB-670F-EF23556344BE}
@ -28,6 +29,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "commit_id", "..\src\commit_
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "copy_compiler_dll", "..\src\copy_compiler_dll.vcxproj", "{22DC02D5-1598-943C-13E1-82185B469F81}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dds_to_header", "..\samples\dds_to_header.vcxproj", "{6BC75FF2-C11A-C393-F9BB-BF29FF29D736}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "es_util", "..\samples\es_util.vcxproj", "{80E5C3D9-93C2-943E-176F-C9A903E27BC9}"
ProjectSection(ProjectDependencies) = postProject
{FBAEE4F6-562A-588F-01F9-72DCABB3B061} = {FBAEE4F6-562A-588F-01F9-72DCABB3B061}
@ -182,6 +185,10 @@ Global
{46160987-0221-9E14-3B88-80F9FCFCFFBF}.Debug|Win32.Build.0 = Debug|Win32
{46160987-0221-9E14-3B88-80F9FCFCFFBF}.Release|Win32.ActiveCfg = Release|Win32
{46160987-0221-9E14-3B88-80F9FCFCFFBF}.Release|Win32.Build.0 = Release|Win32
{6BC75FF2-C11A-C393-F9BB-BF29FF29D736}.Debug|Win32.ActiveCfg = Debug|Win32
{6BC75FF2-C11A-C393-F9BB-BF29FF29D736}.Debug|Win32.Build.0 = Debug|Win32
{6BC75FF2-C11A-C393-F9BB-BF29FF29D736}.Release|Win32.ActiveCfg = Release|Win32
{6BC75FF2-C11A-C393-F9BB-BF29FF29D736}.Release|Win32.Build.0 = Release|Win32
{7FBD6F69-B9A4-69F1-A12B-8DACB3F8CD81}.Debug|Win32.ActiveCfg = Debug|Win32
{7FBD6F69-B9A4-69F1-A12B-8DACB3F8CD81}.Debug|Win32.Build.0 = Debug|Win32
{7FBD6F69-B9A4-69F1-A12B-8DACB3F8CD81}.Release|Win32.ActiveCfg = Release|Win32

Просмотреть файл

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{6BC75FF2-C11A-C393-F9BB-BF29FF29D736}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>dds_to_header</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props"/>
<PropertyGroup Label="Configuration">
<CharacterSet>Unicode</CharacterSet>
<ConfigurationType>Application</ConfigurationType>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
<ImportGroup Label="ExtensionSettings"/>
<ImportGroup Label="PropertySheets">
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<PropertyGroup Label="UserMacros"/>
<PropertyGroup>
<ExecutablePath>$(ExecutablePath);$(MSBuildProjectDirectory)\..\..\third_party\cygwin\bin\;$(MSBuildProjectDirectory)\..\..\third_party\python_26\</ExecutablePath>
<OutDir>$(SolutionDir)$(Configuration)_$(Platform)\</OutDir>
<IntDir>$(OutDir)obj\$(ProjectName)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<TargetName>$(ProjectName)</TargetName>
<TargetPath>$(OutDir)\$(ProjectName)$(TargetExt)</TargetPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>C:\Program Files (x86)\Windows Kits\8.0\Include\shared;C:\Program Files (x86)\Windows Kits\8.0\Include\um;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<BufferSecurityCheck>true</BufferSecurityCheck>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;4530;4718;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<FunctionLevelLinking>true</FunctionLevelLinking>
<MinimalRebuild>false</MinimalRebuild>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;_SCL_SECURE_NO_WARNINGS;_HAS_EXCEPTIONS=0;_WIN32_WINNT=0x0600;_WINDOWS;NOMINMAX;WIN32;WIN32_LEAN_AND_MEAN;WINVER=0x0600;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<TreatWarningAsError>true</TreatWarningAsError>
<WarningLevel>Level4</WarningLevel>
</ClCompile>
<Lib>
<AdditionalLibraryDirectories>C:/Program Files (x86)/Windows Kits/8.0/Lib/win8/um/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Lib>
<Link>
<AdditionalDependencies>kernel32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;user32.lib;uuid.lib;odbc32.lib;odbccp32.lib;delayimp.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>C:/Program Files (x86)/Windows Kits/8.0/Lib/win8/um/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<FixedBaseAddress>false</FixedBaseAddress>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ImportLibrary>$(OutDir)lib\$(TargetName).lib</ImportLibrary>
<MapFileName>$(OutDir)$(TargetName).map</MapFileName>
<OutputFile>$(OutDir)$(ProjectName)$(TargetExt)</OutputFile>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
<ResourceCompile>
<AdditionalIncludeDirectories>C:\Program Files (x86)\Windows Kits\8.0\Include\shared;C:\Program Files (x86)\Windows Kits\8.0\Include\um;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<Culture>0x0409</Culture>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>C:\Program Files (x86)\Windows Kits\8.0\Include\shared;C:\Program Files (x86)\Windows Kits\8.0\Include\um;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
<BufferSecurityCheck>true</BufferSecurityCheck>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;4530;4718;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<FunctionLevelLinking>true</FunctionLevelLinking>
<MinimalRebuild>false</MinimalRebuild>
<Optimization>MaxSpeed</Optimization>
<PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;_SCL_SECURE_NO_WARNINGS;_HAS_EXCEPTIONS=0;_WIN32_WINNT=0x0600;_WINDOWS;NOMINMAX;WIN32;WIN32_LEAN_AND_MEAN;WINVER=0x0600;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<TreatWarningAsError>true</TreatWarningAsError>
<WarningLevel>Level4</WarningLevel>
</ClCompile>
<Lib>
<AdditionalLibraryDirectories>C:/Program Files (x86)/Windows Kits/8.0/Lib/win8/um/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Lib>
<Link>
<AdditionalDependencies>kernel32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;user32.lib;uuid.lib;odbc32.lib;odbccp32.lib;delayimp.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>C:/Program Files (x86)/Windows Kits/8.0/Lib/win8/um/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<FixedBaseAddress>false</FixedBaseAddress>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ImportLibrary>$(OutDir)lib\$(TargetName).lib</ImportLibrary>
<MapFileName>$(OutDir)$(TargetName).map</MapFileName>
<OutputFile>$(OutDir)$(ProjectName)$(TargetExt)</OutputFile>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
<ResourceCompile>
<AdditionalIncludeDirectories>C:\Program Files (x86)\Windows Kits\8.0\Include\shared;C:\Program Files (x86)\Windows Kits\8.0\Include\um;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<Culture>0x0409</Culture>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="..\..\samples\samples.gyp"/>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\samples\dds_to_header\main.cpp"/>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/>
<ImportGroup Label="ExtensionTargets"/>
</Project>

Просмотреть файл

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="dds_to_header">
<UniqueIdentifier>{6F557D24-D36F-34F5-20A1-E400ED0EC3BE}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="..\..\samples\samples.gyp"/>
<ClCompile Include="..\..\samples\dds_to_header\main.cpp">
<Filter>dds_to_header</Filter>
</ClCompile>
</ItemGroup>
</Project>

Просмотреть файл

@ -4,6 +4,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "commit_id", "..\src\commit_
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "copy_compiler_dll", "..\src\copy_compiler_dll.vcxproj", "{22DC02D5-1598-943C-13E1-82185B469F81}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dds_to_header", "dds_to_header.vcxproj", "{6BC75FF2-C11A-C393-F9BB-BF29FF29D736}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "es_util", "es_util.vcxproj", "{80E5C3D9-93C2-943E-176F-C9A903E27BC9}"
ProjectSection(ProjectDependencies) = postProject
{FBAEE4F6-562A-588F-01F9-72DCABB3B061} = {FBAEE4F6-562A-588F-01F9-72DCABB3B061}
@ -156,6 +158,10 @@ Global
{46160987-0221-9E14-3B88-80F9FCFCFFBF}.Debug|Win32.Build.0 = Debug|Win32
{46160987-0221-9E14-3B88-80F9FCFCFFBF}.Release|Win32.ActiveCfg = Release|Win32
{46160987-0221-9E14-3B88-80F9FCFCFFBF}.Release|Win32.Build.0 = Release|Win32
{6BC75FF2-C11A-C393-F9BB-BF29FF29D736}.Debug|Win32.ActiveCfg = Debug|Win32
{6BC75FF2-C11A-C393-F9BB-BF29FF29D736}.Debug|Win32.Build.0 = Debug|Win32
{6BC75FF2-C11A-C393-F9BB-BF29FF29D736}.Release|Win32.ActiveCfg = Release|Win32
{6BC75FF2-C11A-C393-F9BB-BF29FF29D736}.Release|Win32.Build.0 = Release|Win32
{7FBD6F69-B9A4-69F1-A12B-8DACB3F8CD81}.Debug|Win32.ActiveCfg = Debug|Win32
{7FBD6F69-B9A4-69F1-A12B-8DACB3F8CD81}.Debug|Win32.Build.0 = Debug|Win32
{7FBD6F69-B9A4-69F1-A12B-8DACB3F8CD81}.Release|Win32.ActiveCfg = Release|Win32

Просмотреть файл

@ -0,0 +1,238 @@
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#include <ddraw.h>
#include <d3d9types.h>
#include <stdio.h>
#include <fstream>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <array>
int main(int argc, char **argv)
{
std::string programName(argv[0]);
if (argc < 4)
{
std::cout << "usage:\n";
std::cout << programName << "INPUT_FILE OUTPUT_C_ARRAY_NAME OUTPUT_FILE\n";
return -1;
}
std::string inputFile(argv[1]);
std::string outputName(argv[2]);
std::string outputFile(argv[3]);
std::ifstream readFile(inputFile, std::ios::binary | std::ios::in);
readFile.seekg(0, std::ios::end);
std::streamoff fileSize = readFile.tellg();
readFile.seekg(0, std::ios::beg);
const std::size_t minSize = sizeof(DDSURFACEDESC2) + sizeof(DWORD);
if (fileSize < minSize)
{
std::cout << inputFile << " is only " << fileSize << " bytes, must be at greater than " << minSize
<< " bytes to be a correct DDS image file.\n";
return -2;
}
DWORD magicWord;
readFile.read(reinterpret_cast<char*>(&magicWord), sizeof(DWORD));
if (magicWord != MAKEFOURCC('D','D','S',' '))
{
std::cout << "Magic word must be " << MAKEFOURCC('D','D','S',' ') << ".\n";
return -3;
}
DDSURFACEDESC2 header;
readFile.read(reinterpret_cast<char*>(&header), sizeof(DDSURFACEDESC2));
std::string formatName;
std::size_t blockSize = 0;
std::size_t blockWidth = 0;
std::size_t blockHeight = 0;
if (header.ddpfPixelFormat.dwFlags & DDPF_RGB)
{
blockSize = header.ddpfPixelFormat.dwRGBBitCount / 8;
blockWidth = 1;
blockHeight = 1;
if (blockSize == 4)
{
if (header.ddpfPixelFormat.dwRBitMask == 0x000000FF &&
header.ddpfPixelFormat.dwGBitMask == 0x0000FF00 &&
header.ddpfPixelFormat.dwBBitMask == 0x00FF0000 &&
header.ddpfPixelFormat.dwRGBAlphaBitMask == 0xFF000000)
{
formatName = "RGBA8";
}
else if (header.ddpfPixelFormat.dwRBitMask == 0x000000FF &&
header.ddpfPixelFormat.dwGBitMask == 0x0000FF00 &&
header.ddpfPixelFormat.dwBBitMask == 0x00FF0000 &&
header.ddpfPixelFormat.dwRGBAlphaBitMask == 0x00000000)
{
formatName = "RGBX8";
}
else if (header.ddpfPixelFormat.dwRBitMask == 0x000003FF &&
header.ddpfPixelFormat.dwGBitMask == 0x000FFC00 &&
header.ddpfPixelFormat.dwBBitMask == 0x3FF00000 &&
header.ddpfPixelFormat.dwRGBAlphaBitMask == 0xC0000000)
{
formatName = "RGB10A2";
}
else if (header.ddpfPixelFormat.dwRBitMask == 0x0000FFFF &&
header.ddpfPixelFormat.dwGBitMask == 0xFFFF0000 &&
header.ddpfPixelFormat.dwBBitMask == 0x00000000 &&
header.ddpfPixelFormat.dwRGBAlphaBitMask == 0x00000000)
{
formatName = "RG16";
}
else if (header.ddpfPixelFormat.dwRBitMask == 0xFFFFFFFF &&
header.ddpfPixelFormat.dwGBitMask == 0x00000000 &&
header.ddpfPixelFormat.dwBBitMask == 0x00000000 &&
header.ddpfPixelFormat.dwRGBAlphaBitMask == 0x00000000)
{
formatName = "R32";
}
else
{
formatName = "UKNOWN";
}
}
}
else if (header.ddpfPixelFormat.dwFlags & DDPF_FOURCC)
{
switch (header.ddpfPixelFormat.dwFourCC)
{
case MAKEFOURCC('D','X','T','1'):
formatName = "DXT1";
blockSize = 8;
blockWidth = 4;
blockHeight = 4;
break;
case MAKEFOURCC('D','X','T','3'):
formatName = "DXT3";
blockSize = 16;
blockWidth = 4;
blockHeight = 4;
break;
case MAKEFOURCC('D','X','T','5'):
formatName = "DXT5";
blockSize = 16;
blockWidth = 4;
blockHeight = 4;
break;
case D3DFMT_R32F:
formatName = "R32F";
blockSize = 4;
blockWidth = 1;
blockHeight = 1;
case D3DFMT_G32R32F:
formatName = "RG32F";
blockSize = 8;
blockWidth = 1;
blockHeight = 1;
case D3DFMT_A32B32G32R32F:
formatName = "RGBA32F";
blockSize = 16;
blockWidth = 1;
blockHeight = 1;
case D3DFMT_R16F:
formatName = "R16F";
blockSize = 2;
blockWidth = 1;
blockHeight = 1;
case D3DFMT_G16R16F:
formatName = "RG16F";
blockSize = 4;
blockWidth = 1;
blockHeight = 1;
case D3DFMT_A16B16G16R16F:
formatName = "RGBA16F";
blockSize = 8;
blockWidth = 1;
blockHeight = 1;
default:
std::cout << "Unsupported FourCC format.\n";
return -5;
}
}
else
{
std::cout << "Unsupported DDS format.\n";
return -6;
}
std::size_t height = header.dwHeight;
std::size_t width = header.dwWidth;
std::size_t levels = std::max(1U, static_cast<std::size_t>(header.dwMipMapCount));
std::ofstream oss(outputFile);
oss << "// Automatically generated header from " << inputFile << ", a " << width << "x" << height;
if (levels > 1)
{
oss << " (" << levels << " mip levels)";
}
oss << "\n// " << formatName << " texture using " << programName << ".\n";
oss << "static const size_t " << outputName << "_width = " << width << ";\n";
oss << "static const size_t " << outputName << "_height = " << height << ";\n";
oss << "static const size_t " << outputName << "_levels = " << levels << ";\n";
oss << "\n";
for (std::size_t i = 0; i < levels; ++i)
{
std::size_t widthAtLevel = std::max(width >> i, 1U);
std::size_t heightAtLevel = std::max(height >> i, 1U);
std::size_t sizeAtLevel = static_cast<std::size_t>(std::ceil(widthAtLevel / static_cast<float>(blockWidth)) *
std::ceil(heightAtLevel / static_cast<float>(blockHeight))) *
blockSize;
std::vector<unsigned char> data(sizeAtLevel);
readFile.read(reinterpret_cast<char*>(data.data()), sizeAtLevel);
oss << "static const size_t " << outputName << "_" << i << "_width = " << widthAtLevel << ";\n";
oss << "static const size_t " << outputName << "_" << i << "_height = " << heightAtLevel << ";\n";
oss << "static const size_t " << outputName << "_" << i << "_size = " << sizeAtLevel << ";\n";
oss << "static const unsigned char " << outputName << "_" << i << "_data[" << sizeAtLevel << "] =\n";
oss << "{";
for (std::size_t j = 0; j < sizeAtLevel; j++)
{
if (j % 16 == 0)
{
oss << "\n ";
}
char buffer[32];
sprintf_s(buffer, "0x%02X,", data[j]);
oss << std::string(buffer);
}
oss << "\n";
oss << "};\n";
if (i + 1 < levels)
{
oss << "\n";
}
}
oss.close();
readFile.close();
return 0;
}

Просмотреть файл

@ -44,6 +44,15 @@
}
},
{
'target_name': 'dds_to_header',
'type': 'executable',
'sources':
[
'<!@(python enumerate_files.py dds_to_header -types *.cpp)',
],
},
{
'target_name': 'es_util',
'type': 'static_library',