Skip to content

Commit

Permalink
Reorder example add-ons by complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
crosire committed Dec 1, 2022
1 parent 40ea60b commit 330bc45
Show file tree
Hide file tree
Showing 41 changed files with 131 additions and 144 deletions.
2 changes: 1 addition & 1 deletion ReShade.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ClCompile Include="examples\07-generic_depth\generic_depth.cpp">
<ClCompile Include="examples\09-depth\generic_depth.cpp">
<!-- Force include "reshade.hpp" before anything else when creating built-in add-on, so that no Dear ImGui functions are created. -->
<ForcedIncludeFiles>reshade.hpp;%(ForcedIncludeFiles)</ForcedIncludeFiles>
<PreprocessorDefinitions>BUILTIN_ADDON;%(PreprocessorDefinitions)</PreprocessorDefinitions>
Expand Down
2 changes: 1 addition & 1 deletion ReShade.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<ClCompile Include="source\addon_manager.cpp">
<Filter>core\runtime</Filter>
</ClCompile>
<ClCompile Include="examples\07-generic_depth\generic_depth.cpp">
<ClCompile Include="examples\09-depth\generic_depth.cpp">
<Filter>core\runtime</Filter>
</ClCompile>
<ClCompile Include="source\input.cpp">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Patrick Mours
* Copyright (C) 2022 Patrick Mours
* SPDX-License-Identifier: BSD-3-Clause OR MIT
*/

Expand Down Expand Up @@ -59,21 +59,8 @@ static void draw_settings(reshade::api::effect_runtime *)
s_enabled = s_started = false;
}

void register_addon_framerate_limit()
{
reshade::register_overlay(nullptr, draw_settings);

reshade::register_event<reshade::addon_event::present>(on_present);
}
void unregister_addon_framerate_limit()
{
reshade::unregister_overlay(nullptr, draw_settings);

reshade::unregister_event<reshade::addon_event::present>(on_present);
}

extern "C" __declspec(dllexport) const char *NAME = "Framerate Limiter";
extern "C" __declspec(dllexport) const char *DESCRIPTION = "Limits the framerate of an application to a specified FPS value.";
extern "C" __declspec(dllexport) const char *DESCRIPTION = "Example add-on that limits the framerate of an application to a specified FPS value.";

BOOL APIENTRY DllMain(HMODULE hModule, DWORD fdwReason, LPVOID)
{
Expand All @@ -82,10 +69,10 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD fdwReason, LPVOID)
case DLL_PROCESS_ATTACH:
if (!reshade::register_addon(hModule))
return FALSE;
register_addon_framerate_limit();
reshade::register_overlay(nullptr, draw_settings);
reshade::register_event<reshade::addon_event::present>(on_present);
break;
case DLL_PROCESS_DETACH:
unregister_addon_framerate_limit();
reshade::unregister_addon(hModule);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition="'$(VisualStudioVersion)'&gt;='16.0'">10.0</WindowsTargetPlatformVersion>
<ProjectName>12-framerate_limit</ProjectName>
<ProjectName>01-framerate_limit</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
Expand Down Expand Up @@ -59,7 +59,7 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;NOMINMAX;ImTextureID=ImU64;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>..\..\include;..\..\deps\stb;..\..\deps\imgui;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\include;..\..\deps\imgui;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
Expand All @@ -75,7 +75,7 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;NOMINMAX;ImTextureID=ImU64;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>..\..\include;..\..\deps\stb;..\..\deps\imgui;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\include;..\..\deps\imgui;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
Expand All @@ -92,7 +92,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;NOMINMAX;ImTextureID=ImU64;_CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>..\..\include;..\..\deps\stb;..\..\deps\imgui;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\include;..\..\deps\imgui;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
Expand All @@ -111,7 +111,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;NOMINMAX;ImTextureID=ImU64;_CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>..\..\include;..\..\deps\stb;..\..\deps\imgui;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\include;..\..\deps\imgui;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2014 Patrick Mours
* SPDX-License-Identifier: BSD-3-Clause
* Copyright (C) 2022 Patrick Mours
* SPDX-License-Identifier: BSD-3-Clause OR MIT
*/

#include <reshade.hpp>
Expand Down Expand Up @@ -68,7 +68,7 @@ struct freepie_io_shared_data
freepie_io_data data;
};

bool freepie_io_read(uint32_t index, freepie_io_data *output)
static bool freepie_io_read(uint32_t index, freepie_io_data *output)
{
const size_t FREEPIE_IO_MAX_SLOTS = 4;
if (index >= FREEPIE_IO_MAX_SLOTS)
Expand All @@ -92,26 +92,17 @@ static void update_uniform_variables(reshade::api::effect_runtime *runtime, resh
int index = 0;
runtime->get_annotation_int_from_uniform_variable(variable, "index", &index, 1);

if (freepie_io_data data;
freepie_io_read(index, &data))
freepie_io_data data;
if (freepie_io_read(index, &data))
{
runtime->set_uniform_value_float(variable, &data.yaw, 3 * 2);
}
}
});
}

void register_addon_freepie()
{
reshade::register_event<reshade::addon_event::reshade_begin_effects>(update_uniform_variables);
}
void unregister_addon_freepie()
{
reshade::unregister_event<reshade::addon_event::reshade_begin_effects>(update_uniform_variables);
}

extern "C" __declspec(dllexport) const char *NAME = "FreePIE";
extern "C" __declspec(dllexport) const char *DESCRIPTION = "Adds support for reading FreePIE input data in effects.";
extern "C" __declspec(dllexport) const char *DESCRIPTION = "Example add-on that adds support for reading FreePIE input data in effects via uniform variables.";

BOOL APIENTRY DllMain(HMODULE hModule, DWORD fdwReason, LPVOID)
{
Expand All @@ -120,10 +111,9 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD fdwReason, LPVOID)
case DLL_PROCESS_ATTACH:
if (!reshade::register_addon(hModule))
return FALSE;
register_addon_freepie();
reshade::register_event<reshade::addon_event::reshade_begin_effects>(update_uniform_variables);
break;
case DLL_PROCESS_DETACH:
unregister_addon_freepie();
reshade::unregister_addon(hModule);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition="'$(VisualStudioVersion)'&gt;='16.0'">10.0</WindowsTargetPlatformVersion>
<ProjectName>13-freepie</ProjectName>
<ProjectName>02-freepie</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
Expand Down Expand Up @@ -59,7 +59,7 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;NOMINMAX;ImTextureID=ImU64;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>..\..\include;..\..\deps\stb;..\..\deps\imgui;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
Expand All @@ -75,7 +75,7 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;NOMINMAX;ImTextureID=ImU64;_CRT_SECURE_NO_WARNINGS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>..\..\include;..\..\deps\stb;..\..\deps\imgui;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
Expand All @@ -92,7 +92,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;NOMINMAX;ImTextureID=ImU64;_CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>..\..\include;..\..\deps\stb;..\..\deps\imgui;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
Expand All @@ -111,7 +111,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;NOMINMAX;ImTextureID=ImU64;_CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>..\..\include;..\..\deps\stb;..\..\deps\imgui;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition="'$(VisualStudioVersion)'&gt;='16.0'">10.0</WindowsTargetPlatformVersion>
<ProjectName>06-history_window</ProjectName>
<ProjectName>03-history_window</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ static bool on_copy_query_pool_results(command_list *cmd_list, query_pool pool,
return false;
}

static void on_present(command_queue *, swapchain *, const rect *, const rect *, uint32_t, const rect *)
static void on_present(effect_runtime *runtime)
{
if (s_do_capture)
{
Expand All @@ -895,7 +895,7 @@ static void on_present(command_queue *, swapchain *, const rect *, const rect *,
else
{
// The keyboard shortcut to trigger logging
if (GetAsyncKeyState(VK_F10) & 0x80000000)
if (runtime->is_key_pressed(VK_F10))
{
s_do_capture = true;
reshade::log_message(3, "--- Frame ---");
Expand Down Expand Up @@ -957,7 +957,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD fdwReason, LPVOID)
reshade::register_event<reshade::addon_event::end_query>(on_end_query);
reshade::register_event<reshade::addon_event::copy_query_pool_results>(on_copy_query_pool_results);

reshade::register_event<reshade::addon_event::present>(on_present);
reshade::register_event<reshade::addon_event::reshade_present>(on_present);
break;
case DLL_PROCESS_DETACH:
reshade::unregister_addon(hModule);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition="'$(VisualStudioVersion)'&gt;='16.0'">10.0</WindowsTargetPlatformVersion>
<ProjectName>01-api_trace</ProjectName>
<ProjectName>04-api_trace</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition="'$(VisualStudioVersion)'&gt;='16.0'">10.0</WindowsTargetPlatformVersion>
<ProjectName>02-shader_dump</ProjectName>
<ProjectName>05-shader_dump</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
Expand Down Expand Up @@ -123,7 +123,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="shader_dump.cpp" />
<ClCompile Include="shader_dump_addon.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="crc32_hash.hpp" />
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition="'$(VisualStudioVersion)'&gt;='16.0'">10.0</WindowsTargetPlatformVersion>
<ProjectName>03-shader_replace</ProjectName>
<ProjectName>06-shader_replace</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
Expand Down Expand Up @@ -123,7 +123,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="shader_replace.cpp" />
<ClCompile Include="shader_replace_addon.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="crc32_hash.hpp" />
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ static void on_unmap_texture(device *, resource resource, uint32_t subresource)
dump_texture(s_current_mapping.desc, s_current_mapping.data);
}

extern "C" __declspec(dllexport) const char *NAME = "TextureMod Dump";
extern "C" __declspec(dllexport) const char *NAME = "Texture Dump";
extern "C" __declspec(dllexport) const char *DESCRIPTION = "Example add-on that dumps all textures used by the application to image files on disk.";

BOOL APIENTRY DllMain(HMODULE hModule, DWORD fdwReason, LPVOID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition="'$(VisualStudioVersion)'&gt;='16.0'">10.0</WindowsTargetPlatformVersion>
<ProjectName>04-texture_dump</ProjectName>
<ProjectName>07-texture_dump</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
Expand All @@ -49,7 +49,7 @@
<PropertyGroup>
<OutDir>..\..\bin\$(Platform)\$(Configuration) Examples\</OutDir>
<IntDir>..\..\intermediate\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
<TargetName>texturemod_dump</TargetName>
<TargetName>texture_dump</TargetName>
<TargetExt>.addon</TargetExt>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
Expand Down Expand Up @@ -124,7 +124,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="dump_texture.cpp" />
<ClCompile Include="texturemod_dump.cpp" />
<ClCompile Include="texture_dump_addon.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="crc32_hash.hpp" />
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ static void on_unmap_texture(device *, resource resource, uint32_t subresource)
}
}

extern "C" __declspec(dllexport) const char *NAME = "TextureMod Replace";
extern "C" __declspec(dllexport) const char *NAME = "Texture Replace";
extern "C" __declspec(dllexport) const char *DESCRIPTION = "Example add-on that replaces textures before they are used by the application with image files from disk.";

BOOL APIENTRY DllMain(HMODULE hModule, DWORD fdwReason, LPVOID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition="'$(VisualStudioVersion)'&gt;='16.0'">10.0</WindowsTargetPlatformVersion>
<ProjectName>05-texture_replace</ProjectName>
<ProjectName>08-texture_replace</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
Expand All @@ -49,7 +49,7 @@
<PropertyGroup>
<OutDir>..\..\bin\$(Platform)\$(Configuration) Examples\</OutDir>
<IntDir>..\..\intermediate\$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
<TargetName>texturemod_replace</TargetName>
<TargetName>texture_replace</TargetName>
<TargetExt>.addon</TargetExt>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
Expand Down Expand Up @@ -124,7 +124,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="replace_texture.cpp" />
<ClCompile Include="texturemod_replace.cpp" />
<ClCompile Include="texture_replace_addon.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="crc32_hash.hpp" />
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition="'$(VisualStudioVersion)'&gt;='16.0'">10.0</WindowsTargetPlatformVersion>
<ProjectName>07-generic_depth</ProjectName>
<ProjectName>09-depth</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
Expand Down
Loading

0 comments on commit 330bc45

Please sign in to comment.