Files
EGameTools/DL2GameOverhaulScript/source/ImGui/impl/d3d11_impl.cpp

56 lines
1.4 KiB
C++
Raw Normal View History

#include <pch.h>
#include "..\menu\menu.h"
namespace impl {
namespace d3d11 {
ID3D11Device* d3d11Device = nullptr;
static ID3D11DeviceContext* d3d11DeviceContext = nullptr;
HRESULT(__stdcall* oPresent)(IDXGISwapChain*, UINT, UINT);
HRESULT __stdcall hkPresent11(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags) {
static bool init = false;
if (!init) {
DXGI_SWAP_CHAIN_DESC desc{};
pSwapChain->GetDesc(&desc);
pSwapChain->GetDevice(__uuidof(ID3D11Device), (void**)&d3d11Device);
d3d11Device->GetImmediateContext(&d3d11DeviceContext);
2023-07-30 06:14:30 +03:00
#ifndef LLMH_IMPL_DISABLE_DEBUG
std::thread([&desc]() { impl::win32::init(desc.OutputWindow); }).detach();
#else
impl::win32::init(desc.OutputWindow);
#endif
2023-07-30 06:14:30 +03:00
ImGui::CreateContext();
ImGui::GetIO().IniFilename = nullptr;
ImGui_ImplWin32_Init(desc.OutputWindow);
ImGui_ImplDX11_Init(d3d11Device, d3d11DeviceContext);
Menu::InitImGuiStyle();
2023-07-30 06:14:30 +03:00
init = true;
}
2023-07-30 06:14:30 +03:00
ImGui_ImplDX11_NewFrame();
ImGui_ImplWin32_NewFrame();
ImGui::NewFrame();
2023-07-30 06:14:30 +03:00
Menu::FirstTimeRunning();
if (Menu::menuToggle.GetValue())
Menu::Render();
2023-07-30 06:14:30 +03:00
ImGui::EndFrame();
ImGui::Render();
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
2023-07-30 06:14:30 +03:00
return oPresent(pSwapChain, SyncInterval, Flags);
}
2023-07-30 06:14:30 +03:00
void init() {
assert(kiero::bind(8, (LPVOID*)&oPresent, hkPresent11) == kiero::Status::Success);
}
}
2023-07-30 06:14:30 +03:00
}