mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-14 03:59:36 +00:00
Add FreeType, progress to title screen
This commit is contained in:
114
CompileShadersD3D11/CompileShadersD3D11.cpp
Normal file
114
CompileShadersD3D11/CompileShadersD3D11.cpp
Normal file
@@ -0,0 +1,114 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <d3dcompiler.h>
|
||||
|
||||
#pragma comment(lib, "D3DCompiler.lib")
|
||||
|
||||
struct CompileJob
|
||||
{
|
||||
LPCWSTR m_filename;
|
||||
LPCWSTR m_outputFilename;
|
||||
LPCSTR m_shaderVarName;
|
||||
const D3D_SHADER_MACRO *m_defs;
|
||||
LPCSTR m_entryPoint;
|
||||
LPCSTR m_target;
|
||||
};
|
||||
|
||||
const D3D_SHADER_MACRO drawQuadDefs[] =
|
||||
{
|
||||
{ nullptr }
|
||||
};
|
||||
|
||||
const CompileJob kCompileJobs[] =
|
||||
{
|
||||
{
|
||||
L"ShaderSrc\\DrawQuadV.hlsl",
|
||||
L"GpD3D\\ShadersD3D11\\DrawQuadV_D3D11.cpp",
|
||||
"g_drawQuadV_D3D11",
|
||||
drawQuadDefs,
|
||||
"VSMain",
|
||||
"vs_4_0"
|
||||
},
|
||||
{
|
||||
L"ShaderSrc\\DrawQuadRGBP.hlsl",
|
||||
L"GpD3D\\ShadersD3D11\\DrawQuadRGBP_D3D11.cpp",
|
||||
"g_drawQuadRGBP_D3D11",
|
||||
drawQuadDefs,
|
||||
"PSMain",
|
||||
"ps_4_0"
|
||||
},
|
||||
{
|
||||
L"ShaderSrc\\DrawQuadPaletteP.hlsl",
|
||||
L"GpD3D\\ShadersD3D11\\DrawQuadPaletteP_D3D11.cpp",
|
||||
"g_drawQuadPaletteP_D3D11",
|
||||
drawQuadDefs,
|
||||
"PSMain",
|
||||
"ps_4_0"
|
||||
},
|
||||
{
|
||||
L"ShaderSrc\\DrawQuad15BitP.hlsl",
|
||||
L"GpD3D\\ShadersD3D11\\DrawQuad15BitP_D3D11.cpp",
|
||||
"g_drawQuad15BitP_D3D11",
|
||||
drawQuadDefs,
|
||||
"PSMain",
|
||||
"ps_4_0"
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
const size_t numJobs = sizeof(kCompileJobs) / sizeof(kCompileJobs[0]);
|
||||
|
||||
UINT flags = D3DCOMPILE_ENABLE_STRICTNESS | D3DCOMPILE_OPTIMIZATION_LEVEL3;
|
||||
for (size_t i = 0; i < numJobs; i++)
|
||||
{
|
||||
const CompileJob &job = kCompileJobs[i];
|
||||
|
||||
ID3DBlob *code = nullptr;
|
||||
ID3DBlob *errorMsgs = nullptr;
|
||||
|
||||
HRESULT result = D3DCompileFromFile(job.m_filename, job.m_defs, D3D_COMPILE_STANDARD_FILE_INCLUDE, job.m_entryPoint, job.m_target, flags, 0, &code, &errorMsgs);
|
||||
|
||||
if (result != S_OK)
|
||||
{
|
||||
fprintf(stderr, "Compile failure error: %x", static_cast<int>(result));
|
||||
}
|
||||
|
||||
if (errorMsgs)
|
||||
{
|
||||
fputs(static_cast<const char*>(errorMsgs->GetBufferPointer()), stderr);
|
||||
errorMsgs->Release();
|
||||
}
|
||||
|
||||
if (code)
|
||||
{
|
||||
FILE *f = nullptr;
|
||||
errno_t errorCode = _wfopen_s(&f, job.m_outputFilename, L"wb");
|
||||
|
||||
if (!errorCode)
|
||||
{
|
||||
fprintf(f, "static unsigned char gs_shaderData[] = {");
|
||||
|
||||
const uint8_t *bytes = static_cast<const uint8_t *>(code->GetBufferPointer());
|
||||
const size_t size = code->GetBufferSize();
|
||||
|
||||
for (size_t i = 0; i < size; i++)
|
||||
{
|
||||
if (i % 15 == 0)
|
||||
fputs("\n\t", f);
|
||||
fprintf(f, "%3i, ", static_cast<int>(bytes[i]));
|
||||
}
|
||||
|
||||
fprintf(f, "\n};\n\n");
|
||||
fprintf(f, "namespace GpBinarizedShaders\n{\n");
|
||||
fprintf(f, "\tconst unsigned char *%s[2] = { gs_shaderData, gs_shaderData + sizeof(gs_shaderData) }; \n", job.m_shaderVarName);
|
||||
fprintf(f, "};\n");
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
code->Release();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
123
CompileShadersD3D11/CompileShadersD3D11.vcxproj
Normal file
123
CompileShadersD3D11/CompileShadersD3D11.vcxproj
Normal file
@@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.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>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{ED2F91E1-673A-4590-82B2-EB157927D3E3}</ProjectGuid>
|
||||
<RootNamespace>CompileShadersD3D11</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<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|Win32'">
|
||||
<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)'=='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 />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="CompileShadersD3D11.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
22
CompileShadersD3D11/CompileShadersD3D11.vcxproj.filters
Normal file
22
CompileShadersD3D11/CompileShadersD3D11.vcxproj.filters
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="CompileShadersD3D11.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user