2024-02-03 20:40:17 +02:00
|
|
|
|
#include <assert.h>
|
2023-08-05 05:22:20 +03:00
|
|
|
|
#include <backends\imgui_impl_dx11.h>
|
2024-02-03 20:40:17 +02:00
|
|
|
|
#include <backends\imgui_impl_win32.h>
|
|
|
|
|
#include <d3d11.h>
|
|
|
|
|
#include <imgui.h>
|
2023-08-05 05:22:20 +03:00
|
|
|
|
#include "..\..\kiero.h"
|
2024-02-03 20:40:17 +02:00
|
|
|
|
#include "..\..\menu\menu.h"
|
2023-07-30 06:14:30 +03:00
|
|
|
|
#include "d3d11_impl.h"
|
|
|
|
|
#include "win32_impl.h"
|
|
|
|
|
|
|
|
|
|
HRESULT(__stdcall* oPresent)(IDXGISwapChain*, UINT, UINT);
|
|
|
|
|
HRESULT __stdcall hkPresent11(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags) {
|
|
|
|
|
static bool init = false;
|
|
|
|
|
|
|
|
|
|
if (!init)
|
|
|
|
|
{
|
2023-08-05 05:22:20 +03:00
|
|
|
|
DXGI_SWAP_CHAIN_DESC desc{};
|
2023-07-30 06:14:30 +03:00
|
|
|
|
pSwapChain->GetDesc(&desc);
|
|
|
|
|
|
|
|
|
|
ID3D11Device* device = nullptr;
|
|
|
|
|
pSwapChain->GetDevice(__uuidof(ID3D11Device), (void**)&device);
|
|
|
|
|
|
|
|
|
|
ID3D11DeviceContext* context = nullptr;
|
|
|
|
|
device->GetImmediateContext(&context);
|
|
|
|
|
|
|
|
|
|
impl::win32::init(desc.OutputWindow);
|
|
|
|
|
|
|
|
|
|
ImGui::CreateContext();
|
2023-08-05 05:22:20 +03:00
|
|
|
|
ImGui::GetIO().IniFilename = nullptr;
|
|
|
|
|
|
2023-07-30 06:14:30 +03:00
|
|
|
|
ImGui_ImplWin32_Init(desc.OutputWindow);
|
|
|
|
|
ImGui_ImplDX11_Init(device, context);
|
|
|
|
|
|
|
|
|
|
init = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui_ImplDX11_NewFrame();
|
|
|
|
|
ImGui_ImplWin32_NewFrame();
|
|
|
|
|
ImGui::NewFrame();
|
|
|
|
|
|
2024-01-27 19:59:26 +02:00
|
|
|
|
if (Menu::menuToggle.GetValue())
|
2023-07-30 06:14:30 +03:00
|
|
|
|
Menu::Render();
|
|
|
|
|
|
|
|
|
|
ImGui::EndFrame();
|
|
|
|
|
ImGui::Render();
|
|
|
|
|
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
|
|
|
|
|
|
|
|
|
|
return oPresent(pSwapChain, SyncInterval, Flags);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void impl::d3d11::init() {
|
2023-08-05 05:22:20 +03:00
|
|
|
|
assert(kiero::bind(8, (LPVOID*)&oPresent, hkPresent11) == kiero::Status::Success);
|
2023-07-30 06:14:30 +03:00
|
|
|
|
}
|