From be53feed657f06cfa09a3a30d2f42c3fafba10bd Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Tue, 26 Dec 2023 02:37:07 +0100 Subject: [PATCH] MaterialSystem: fix console not drawing in the 4:3/5:4 aspect ratio modes DrawImGui should be called BEFORE ID3D11DeviceContext::ClearRenderTargetView() or ID3D11DeviceContext::End(). Moved drawing code to SpinPresent which is just before the clear/end calls are being made. Console now draws in the 4:3/5:4 aspect ratio video modes. --- src/materialsystem/cmaterialsystem.cpp | 15 +++++++++++++++ src/windows/id3dx.cpp | 11 ----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/materialsystem/cmaterialsystem.cpp b/src/materialsystem/cmaterialsystem.cpp index 5ec2da93..f3a96579 100644 --- a/src/materialsystem/cmaterialsystem.cpp +++ b/src/materialsystem/cmaterialsystem.cpp @@ -10,6 +10,7 @@ #include "vpc/keyvalues.h" #include "rtech/rtech_utils.h" #include "engine/cmodel_bsp.h" +#include "engine/sys_engine.h" #include "geforce/reflex.h" #ifndef MATERIALSYSTEM_NODX #include "windows/id3dx.h" @@ -115,6 +116,20 @@ void* __fastcall DispatchDrawCall(int64_t a1, uint64_t a2, int a3, int a4, int64 //--------------------------------------------------------------------------------- ssize_t SpinPresent(void) { + // TODO[ AMOS ]: move imgui code to a separate file. + extern void DrawImGui(); + extern void ImGui_Init(); + + if (!g_bImGuiInitialized) + { + ImGui_Init(); + g_ThreadRenderThreadID = GetCurrentThreadId(); + g_bImGuiInitialized = true; + } + + if (g_pEngine->GetQuitting() == IEngine::QUIT_NOTQUITTING) + DrawImGui(); + const ssize_t val = v_SpinPresent(); return val; } diff --git a/src/windows/id3dx.cpp b/src/windows/id3dx.cpp index 49f64115..c395c278 100644 --- a/src/windows/id3dx.cpp +++ b/src/windows/id3dx.cpp @@ -10,7 +10,6 @@ #include "gameui/IConsole.h" #include "gameui/IBrowser.h" #include "engine/framelimit.h" -#include "engine/sys_engine.h" #include "engine/sys_mainwind.h" #include "inputsystem/inputsystem.h" #include "materialsystem/cmaterialsystem.h" @@ -136,18 +135,8 @@ void DrawImGui() HRESULT __stdcall Present(IDXGISwapChain* pSwapChain, UINT nSyncInterval, UINT nFlags) { - if (!g_bImGuiInitialized) - { - ImGui_Init(); - g_ThreadRenderThreadID = GetCurrentThreadId(); - g_bImGuiInitialized = true; - } - g_FrameLimiter.Run(); - if (g_pEngine->GetQuitting() == IEngine::QUIT_NOTQUITTING) - DrawImGui(); - /////////////////////////////////////////////////////////////////////////////// // NOTE: -1 since we need to sync this with its corresponding frame, g_FrameNum // gets incremented in CMaterialSystem::SwapBuffers, which is after the markers