r5sdk/r5dev/engine/sys_getmodes.cpp
Kawe Mazidjatari 6cf88dc16c Engine: render ImGui in main thread and fix many threading bugs
ImGui drawing code now takes place in the main thread, a snapshot of the render data is created in CMaterialSystem::SwapBuffers(), and is being rendered in the render thread right before SpinPresent().

The reason why this was necessary, is because ConVar::GetString() isn't thread safe if its not marked FCVAR_MATERIAL_SYSTEM_THREAD or FCVAR_ACCESSIBLE_FROM_THREADS, and we used it for the console suggestions window, which iterates over every ConVar, accessible from threads or not.
2024-04-05 18:17:12 +02:00

31 lines
994 B
C++

//===========================================================================//
//
// Purpose:
//
//===========================================================================//
#include "core/stdafx.h"
#include "windows/id3dx.h"
#include "engine/sys_getmodes.h"
#include "gameui/imgui_system.h"
//-----------------------------------------------------------------------------
// Purpose: creates the game window, obtains the rect and plays the startup movie.
//-----------------------------------------------------------------------------
bool HCVideoMode_Common__CreateGameWindow(int* pnRect)
{
g_nWindowRect[0] = pnRect[0];
g_nWindowRect[1] = pnRect[1];
const bool ret = CVideoMode_Common__CreateGameWindow(pnRect);
if (!ImguiSystem_Init())
Error(eDLL_T::MS, 0, "ImGui system initialization failed!\n");
return ret;
}
void HVideoMode_Common::Detour(const bool bAttach) const
{
DetourSetup(&CVideoMode_Common__CreateGameWindow, &HCVideoMode_Common__CreateGameWindow, bAttach);
}