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.
This commit is contained in:
Kawe Mazidjatari 2023-12-26 02:37:07 +01:00
parent 77a20f4d9e
commit 365448b8c7
2 changed files with 15 additions and 11 deletions

View File

@ -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;
}

View File

@ -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