mirror of
https://github.com/orange-cpp/omath.git
synced 2026-05-06 10:03:28 +00:00
fixed code style
This commit is contained in:
@@ -1,12 +1,11 @@
|
|||||||
|
#include "omath/hooks/hooks_manager.hpp"
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <d3d12.h>
|
#include <d3d12.h>
|
||||||
#include <dxgi1_4.h>
|
#include <dxgi1_4.h>
|
||||||
#include <vector>
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <imgui_impl_dx12.h>
|
#include <imgui_impl_dx12.h>
|
||||||
#include <imgui_impl_win32.h>
|
#include <imgui_impl_win32.h>
|
||||||
|
#include <vector>
|
||||||
#include "omath/hooks/hooks_manager.hpp"
|
|
||||||
|
|
||||||
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND, UINT, WPARAM, LPARAM);
|
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND, UINT, WPARAM, LPARAM);
|
||||||
bool show_menu = true;
|
bool show_menu = true;
|
||||||
@@ -80,8 +79,7 @@ namespace
|
|||||||
rtv_handle.ptr += rtv_size;
|
rtv_handle.ptr += rtv_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FAILED(g_device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT,
|
if (FAILED(g_device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, g_command_allocator, nullptr,
|
||||||
g_command_allocator, nullptr,
|
|
||||||
IID_PPV_ARGS(&g_command_list))))
|
IID_PPV_ARGS(&g_command_list))))
|
||||||
return;
|
return;
|
||||||
g_command_list->Close();
|
g_command_list->Close();
|
||||||
@@ -93,21 +91,22 @@ namespace
|
|||||||
ImGui::GetIO().ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
|
ImGui::GetIO().ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
|
||||||
|
|
||||||
ImGui_ImplWin32_Init(desc.OutputWindow);
|
ImGui_ImplWin32_Init(desc.OutputWindow);
|
||||||
ImGui_ImplDX12_Init(g_device, static_cast<int>(buffer_count),
|
ImGui_ImplDX12_Init(g_device, static_cast<int>(buffer_count), desc.BufferDesc.Format, g_srv_heap,
|
||||||
desc.BufferDesc.Format, g_srv_heap,
|
|
||||||
g_srv_heap->GetCPUDescriptorHandleForHeapStart(),
|
g_srv_heap->GetCPUDescriptorHandleForHeapStart(),
|
||||||
g_srv_heap->GetGPUDescriptorHandleForHeapStart());
|
g_srv_heap->GetGPUDescriptorHandleForHeapStart());
|
||||||
ImGui_ImplDX12_CreateDeviceObjects();
|
ImGui_ImplDX12_CreateDeviceObjects();
|
||||||
|
|
||||||
auto& mgr = omath::hooks::HooksManager::get();
|
auto& mgr = omath::hooks::HooksManager::get();
|
||||||
mgr.set_on_wnd_proc([](HWND h, UINT msg, WPARAM wp, LPARAM lp) -> std::optional<LRESULT> {
|
mgr.set_on_wnd_proc(
|
||||||
|
[](HWND h, UINT msg, WPARAM wp, LPARAM lp) -> std::optional<LRESULT>
|
||||||
|
{
|
||||||
if (!show_menu)
|
if (!show_menu)
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|
||||||
ImGui_ImplWin32_WndProcHandler(h, msg, wp, lp);
|
ImGui_ImplWin32_WndProcHandler(h, msg, wp, lp);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
mgr.hook_wnd_proc(desc.OutputWindow);
|
std::ignore = mgr.hook_wnd_proc(desc.OutputWindow);
|
||||||
|
|
||||||
g_initialized = true;
|
g_initialized = true;
|
||||||
}
|
}
|
||||||
@@ -176,15 +175,43 @@ namespace
|
|||||||
{
|
{
|
||||||
for (auto& fc : g_frames)
|
for (auto& fc : g_frames)
|
||||||
{
|
{
|
||||||
if (fc.render_target) { fc.render_target->Release(); fc.render_target = nullptr; }
|
if (fc.render_target)
|
||||||
|
{
|
||||||
|
fc.render_target->Release();
|
||||||
|
fc.render_target = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
g_frames.clear();
|
g_frames.clear();
|
||||||
if (g_command_allocator) { g_command_allocator->Release(); g_command_allocator = nullptr; }
|
if (g_command_allocator)
|
||||||
if (g_command_list) { g_command_list->Release(); g_command_list = nullptr; }
|
{
|
||||||
if (g_srv_heap) { g_srv_heap->Release(); g_srv_heap = nullptr; }
|
g_command_allocator->Release();
|
||||||
if (g_rtv_heap) { g_rtv_heap->Release(); g_rtv_heap = nullptr; }
|
g_command_allocator = nullptr;
|
||||||
if (g_swap_chain) { g_swap_chain->Release(); g_swap_chain = nullptr; }
|
}
|
||||||
if (g_device) { g_device->Release(); g_device = nullptr; }
|
if (g_command_list)
|
||||||
|
{
|
||||||
|
g_command_list->Release();
|
||||||
|
g_command_list = nullptr;
|
||||||
|
}
|
||||||
|
if (g_srv_heap)
|
||||||
|
{
|
||||||
|
g_srv_heap->Release();
|
||||||
|
g_srv_heap = nullptr;
|
||||||
|
}
|
||||||
|
if (g_rtv_heap)
|
||||||
|
{
|
||||||
|
g_rtv_heap->Release();
|
||||||
|
g_rtv_heap = nullptr;
|
||||||
|
}
|
||||||
|
if (g_swap_chain)
|
||||||
|
{
|
||||||
|
g_swap_chain->Release();
|
||||||
|
g_swap_chain = nullptr;
|
||||||
|
}
|
||||||
|
if (g_device)
|
||||||
|
{
|
||||||
|
g_device->Release();
|
||||||
|
g_device = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@@ -193,7 +220,9 @@ BOOL WINAPI DllMain(HINSTANCE h_instance, DWORD reason, LPVOID)
|
|||||||
if (reason == DLL_PROCESS_ATTACH)
|
if (reason == DLL_PROCESS_ATTACH)
|
||||||
{
|
{
|
||||||
DisableThreadLibraryCalls(h_instance);
|
DisableThreadLibraryCalls(h_instance);
|
||||||
CreateThread(nullptr, 0, [](LPVOID) -> DWORD
|
CreateThread(
|
||||||
|
nullptr, 0,
|
||||||
|
[](LPVOID) -> DWORD
|
||||||
{
|
{
|
||||||
while (!GetModuleHandle("d3d12.dll"))
|
while (!GetModuleHandle("d3d12.dll"))
|
||||||
Sleep(100);
|
Sleep(100);
|
||||||
@@ -203,7 +232,8 @@ BOOL WINAPI DllMain(HINSTANCE h_instance, DWORD reason, LPVOID)
|
|||||||
mgr.set_on_execute_command_lists(on_execute_command_lists);
|
mgr.set_on_execute_command_lists(on_execute_command_lists);
|
||||||
mgr.hook_dx12();
|
mgr.hook_dx12();
|
||||||
return 0;
|
return 0;
|
||||||
}, nullptr, 0, nullptr);
|
},
|
||||||
|
nullptr, 0, nullptr);
|
||||||
}
|
}
|
||||||
else if (reason == DLL_PROCESS_DETACH)
|
else if (reason == DLL_PROCESS_DETACH)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user