Fixed RUI resizing.

This commit is contained in:
IcePixelx 2021-08-13 16:24:09 +02:00
parent 2ec2ace1b6
commit 028ef8b5ab

View File

@ -266,23 +266,25 @@ void DrawImGui()
ImGui::NewFrame();
if (g_bShowConsole)
if (g_bShowConsole || g_bShowBrowser)
{
GameGlobals::InputSystem->EnableInput(false); // Disable input.
}
else
{
GameGlobals::InputSystem->EnableInput(true); // Enable input.
}
if (g_bShowConsole)
{
DrawConsole();
}
if (g_bShowBrowser)
{
GameGlobals::InputSystem->EnableInput(false); // Disable input.
DrawBrowser();
}
if (!g_bShowConsole && !g_bShowBrowser)
{
GameGlobals::InputSystem->EnableInput(true); // Enable input.
}
ImGui::EndFrame();
ImGui::Render();
@ -312,25 +314,6 @@ void CreateRenderTarget(IDXGISwapChain* pSwapChain)
pBackBuffer->Release();
}
void CreateViewPort( UINT nWidth, UINT nHeight)
{
float width = *(float*)(&nWidth);
float height = *(float*)(&nHeight);
D3D11_VIEWPORT vp;
///////////////////////////////////////////////////////////////////////////////
vp.Width = width;
vp.Height = height;
vp.MinDepth = 0.0f;
vp.MaxDepth = 1.0f;
vp.TopLeftX = 0;
vp.TopLeftY = 0;
///////////////////////////////////////////////////////////////////////////////
g_pDeviceContext->RSSetViewports(1, &vp);
}
void DestroyRenderTarget()
{
if (nullptr != g_pRenderTargetView)
@ -368,12 +351,9 @@ HRESULT __stdcall GetResizeBuffers(IDXGISwapChain* pSwapChain, UINT nBufferCount
g_bPresentHooked = false;
///////////////////////////////////////////////////////////////////////////////
ImGui_ImplDX11_InvalidateDeviceObjects();
DestroyRenderTarget();
CreateViewPort(nWidth, nHeight);
ImGui_ImplDX11_CreateDeviceObjects();
///////////////////////////////////////////////////////////////////////////////
return originalResizeBuffers(pSwapChain, nBufferCount, nWidth, nHeight, dxFormat, nSwapChainFlags);
}
@ -484,14 +464,14 @@ void InstallDXHooks()
///////////////////////////////////////////////////////////////////////////////
// Hook SwapChain
MH_CreateHook(g_fnIDXGISwapChainPresent, &Present, reinterpret_cast<void**>(&originalPresent));
// MH_CreateHook(g_oResizeBuffers, &GetResizeBuffers, reinterpret_cast<void**>(&originalResizeBuffers));
MH_CreateHook(g_oResizeBuffers, &GetResizeBuffers, reinterpret_cast<void**>(&originalResizeBuffers));
///////////////////////////////////////////////////////////////////////////////
// Enable hooks
MH_EnableHook(PostMessageA);
MH_EnableHook(PostMessageW);
MH_EnableHook(g_fnIDXGISwapChainPresent);
// MH_EnableHook(g_oResizeBuffers);
MH_EnableHook(g_oResizeBuffers);
}
void RemoveDXHooks()
@ -512,7 +492,7 @@ void RemoveDXHooks()
///////////////////////////////////////////////////////////////////////////////
// Unhook SwapChain
MH_RemoveHook(g_fnIDXGISwapChainPresent);
// MH_RemoveHook(g_oResizeBuffers);
MH_RemoveHook(g_oResizeBuffers);
///////////////////////////////////////////////////////////////////////////////
// Shutdown ImGui