Skip to content

Commit

Permalink
Create texture converter project.
Browse files Browse the repository at this point in the history
  • Loading branch information
exjam authored and brett19 committed Oct 28, 2015
1 parent b4f40e7 commit f4fe207
Show file tree
Hide file tree
Showing 9 changed files with 978 additions and 0 deletions.
104 changes: 104 additions & 0 deletions build/gtx-convert.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\modules\gx2\gx2_enum_string.cpp" />
<ClCompile Include="..\tools\gfd.cpp" />
<ClCompile Include="..\tools\gtx-convert\gtx-convert.cpp" />
<ClCompile Include="..\tools\gtx-convert\untile.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\tools\gfd.h" />
<ClInclude Include="..\tools\gtx-convert\untile.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{7CB8D060-968B-4173-B2BF-1E29088107F2}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>gshdisassemble</RootNamespace>
<WindowsTargetPlatformVersion>10.0.10240.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(SolutionDir)\tools;$(SolutionDir)\src;$(SolutionDir)\libraries\docopt;$(SolutionDir)\libraries\gsl\include;$(SolutionDir)\libraries\spdlog\include;$(IncludePath)</IncludePath>
<OutDir>$(SolutionDir)\obj\$(Configuration)\</OutDir>
<IntDir>obj\$(ProjectName)\$(Configuration)\</IntDir>
<LibraryPath>$(SolutionDir)\obj\$(Configuration);$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)\obj\$(Configuration)\</OutDir>
<IntDir>obj\$(ProjectName)\$(Configuration)\</IntDir>
<IncludePath>$(SolutionDir)\tools;$(SolutionDir)\src;$(SolutionDir)\libraries\docopt;$(SolutionDir)\libraries\gsl\include;$(SolutionDir)\libraries\spdlog\include;$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)\obj\$(Configuration);$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>NOMINMAX;_CONSOLE;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>docopt.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NOMINMAX;_CONSOLE;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>docopt.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
33 changes: 33 additions & 0 deletions build/gtx-convert.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Header Files">
<UniqueIdentifier>{f39f532d-a857-4aa2-a25d-773b4f6cb60a}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files">
<UniqueIdentifier>{b728fa72-a1fd-4056-9b35-afd40bc2003d}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\tools\gtx-convert\gtx-convert.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\tools\gfd.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\modules\gx2\gx2_enum_string.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\tools\gtx-convert\untile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\tools\gfd.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\tools\gtx-convert\untile.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
7 changes: 7 additions & 0 deletions decaf.sln
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "decaf", "build\decaf.vcxpro
{94C92AF7-B8C5-4F0B-A7F4-F80A32DCEC8E} = {94C92AF7-B8C5-4F0B-A7F4-F80A32DCEC8E}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtx-convert", "build\gtx-convert.vcxproj", "{7CB8D060-968B-4173-B2BF-1E29088107F2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Expand Down Expand Up @@ -77,6 +79,10 @@ Global
{D528F1B0-3DA2-496D-9E59-CE80141BD149}.Debug|x64.Build.0 = Debug|x64
{D528F1B0-3DA2-496D-9E59-CE80141BD149}.Release|x64.ActiveCfg = Release|x64
{D528F1B0-3DA2-496D-9E59-CE80141BD149}.Release|x64.Build.0 = Release|x64
{7CB8D060-968B-4173-B2BF-1E29088107F2}.Debug|x64.ActiveCfg = Debug|x64
{7CB8D060-968B-4173-B2BF-1E29088107F2}.Debug|x64.Build.0 = Debug|x64
{7CB8D060-968B-4173-B2BF-1E29088107F2}.Release|x64.ActiveCfg = Release|x64
{7CB8D060-968B-4173-B2BF-1E29088107F2}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -90,5 +96,6 @@ Global
{CD2AFBB6-5A6C-4FC6-B76B-F618193AEFC8} = {4E2164E9-068E-44D0-BC5B-E8A68B30D4CE}
{CDFC321E-07C6-44E1-B145-02749935DDFE} = {4E2164E9-068E-44D0-BC5B-E8A68B30D4CE}
{01016351-42D4-4D49-A433-00CF4E1F7A8C} = {A7137181-83E5-46FB-A880-B4FB4F4BF3C3}
{7CB8D060-968B-4173-B2BF-1E29088107F2} = {4E2164E9-068E-44D0-BC5B-E8A68B30D4CE}
EndGlobalSection
EndGlobal
48 changes: 48 additions & 0 deletions tools/gfd.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include "gfd.h"
#include "utils/binaryfile.h"

namespace gfd
{

bool
readFile(const std::string &filename, File &out)
{
BinaryFile file;

if (!file.open(filename)) {
return false;
}

file.read(out.header);

if (out.header.magic != FileHeader::Magic) {
return false;
}

if (out.header.headerSize != sizeof(FileHeader)) {
return false;
}

while (!file.eof()) {
Block block;
file.read(block.header);

if (block.header.magic != BlockHeader::Magic) {
return false;
}

if (block.header.headerSize != sizeof(BlockHeader)) {
return false;
}

if (block.header.dataSize) {
file.read(block.data, block.header.dataSize);
}

out.blocks.emplace_back(block);
}

return true;
}

} // namespace gsh
70 changes: 70 additions & 0 deletions tools/gfd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#include <cstdint>
#include <vector>
#include "utils/be_val.h"

namespace gfd
{

#pragma pack(push, 1)

namespace BlockType
{
enum Type : uint32_t
{
VertexShaderHeader = 3,
VertexShaderProgram = 5,
PixelShaderHeader = 6,
PixelShaderProgram = 7,
GeometryShaderHeader = 8,
GeometryShaderProgram = 9,
TextureHeader = 11,
TextureImage = 12,
TextureMipmap = 13,
};
}

struct FileHeader
{
static const uint32_t Magic = 0x47667832;
be_val<uint32_t> magic;
be_val<uint32_t> headerSize;
be_val<uint32_t> version1;
be_val<uint32_t> version2;
be_val<uint32_t> version3;
be_val<uint32_t> align;
be_val<uint32_t> unk1;
be_val<uint32_t> unk2;
};

struct BlockHeader
{
static const uint32_t Magic = 0x424C4B7B;
be_val<uint32_t> magic;
be_val<uint32_t> headerSize;
be_val<uint32_t> version1;
be_val<uint32_t> version2;
be_val<BlockType::Type> type;
be_val<uint32_t> dataSize;
be_val<uint32_t> id;
be_val<uint32_t> index;
};

#pragma pack(pop)

struct Block
{
BlockHeader header;
std::vector<uint8_t> data;
};

struct File
{
FileHeader header;
std::vector<Block> blocks;
};

bool
readFile(const std::string &filename, File &out);

} // namespace gfd

File renamed without changes.

0 comments on commit f4fe207

Please sign in to comment.